Skip to content

Commit

Permalink
(#5) Arrumando conflitos
Browse files Browse the repository at this point in the history
Co-authored-by: ServidioEC <52542729+ServidioEC@users.noreply.github.com>
  • Loading branch information
2 people authored and sergiosacj committed Sep 17, 2021
1 parent 7cb2fba commit c56435a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 38 deletions.
6 changes: 0 additions & 6 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }],
"import/prefer-default-export": "off",
"import/no-duplicates": "off",
"@typescript-eslint/interface-name-prefix": [
"error",
{
"prefixWithI": "always"
}
],
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": [
"error",
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@types/react-dom": "^17.0.9",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-scripts": "4.0.3",
"styled-components": "^5.3.1",
"typescript": "^4.3.5",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/MenuItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const MenuItem: React.FC<Props> = ({
<p>{description}</p>
<h5>R${price}</h5>
<button
type="button"
onClick={() => {
console.log('addItem here');
}}
Expand Down
32 changes: 0 additions & 32 deletions frontend/src/helpers/useFetch.tsx

This file was deleted.

32 changes: 32 additions & 0 deletions frontend/src/hooks/useFetch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { useState, useEffect, useCallback } from 'react';

type Hook = (url: string, setMenuItem: (menuItem: string) => void) => boolean;

interface IuseFetch {
loading: boolean;
}

const useFetch: Hook = (url, setMenuItem) => {
const [loading, setLoading] = useState(true);

const getMenuItems = useCallback(async () => {
try {
const response = await fetch(url);
const data = await response.json();
setLoading(false);
setMenuItem(data);
} catch (error) {
setLoading(false);
throw new Error("useFetch: Can't access url");
}
}, [url, setMenuItem]);

useEffect(() => {
getMenuItems();
}, [getMenuItems]);

return loading;
};

export default useFetch;
5 changes: 5 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10041,6 +10041,11 @@ react-error-overlay@^6.0.9:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==

react-icons@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.2.0.tgz#6dda80c8a8f338ff96a1851424d63083282630d0"
integrity sha512-rmzEDFt+AVXRzD7zDE21gcxyBizD/3NqjbX6cmViAgdqfJ2UiLer8927/QhhrXQV7dEj/1EGuOTPp7JnLYVJKQ==

react-is@^16.7.0, react-is@^16.8.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down

0 comments on commit c56435a

Please sign in to comment.