Skip to content

Instantly share code, notes, and snippets.

@Eraden
Created February 9, 2019 17:42
Show Gist options
  • Save Eraden/4b27c3e6c09f7037ebcd919f87c95556 to your computer and use it in GitHub Desktop.
Save Eraden/4b27c3e6c09f7037ebcd919f87c95556 to your computer and use it in GitHub Desktop.
import { DELETE_FILE_ENTITY, GET_FILE_ENTITIES, GET_FILE_ENTITY } from "./types"; // NO!
import * as types from "./types"; // YES
// NO!
export const getFile = filename => {
const res = await axios.get(`http://localhost:8080/api/files/${filename}`);
dispatch({
type: GET_FILE_ENTITY,
payload: res.data
});
};
// YES
export const getFile = filename => {
const { data } = await axios.get(`http://localhost:8080/api/files/${filename}`);
dispatch({
type: types.GET_FILE_ENTITY,
payload: data
});
};
// NO
if (
window.confirm(
`You are deleting file_entity task ${file_entity_id}, this action cannot be undone`
)
) {}
// YES
const confirmDeleteFile = () => window.confirm(`You are deleting file_entity task ${file_entity_id}, this action cannot be undone`)
if (confirmDeleteFile()) {}
/// GOOOOOD!
export const GET_FILE_ENTITY = "GET_FILE_ENTITY";
export const GET_FILE_ENTITIES = "GET_FILE_ENTITIES"
export const DELETE_FILE_ENTITY = "DELETE_FILE_ENTITY";
export const GET_ERRORS = "GET_ERRORS";
/////
// Consider i18next
// https://www.i18next.com/overview/getting-started
<th>File Name</th>
<th>Content Type:</th>
<th>Uploaded</th>
/// NOOOO!
https://github.com/Jaguarete1011/RiaFullApp/blob/dev/ria_app_client/src/components/Service/FileService.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment