Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grading PR #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Buttons/MinusButton.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import React, { useEffect } from 'react';
import { loadCSS } from 'fg-loadcss';
import { red } from '@mui/material/colors';
import Icon from '@mui/material/Icon';
import IconButton from '@mui/material/IconButton';

export default function MinusButton() {
React.useEffect(() => {
useEffect(() => {
const node = loadCSS(
'https://use.fontawesome.com/releases/v5.14.0/css/all.css',
document.querySelector('#font-awesome-css') || document.head.firstChild
Expand Down
4 changes: 2 additions & 2 deletions src/components/Buttons/PlusButton.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import React, { useEffect } from 'react';
import { loadCSS } from 'fg-loadcss';
import { green } from '@mui/material/colors';
import Icon from '@mui/material/Icon';
import IconButton from '@mui/material/IconButton';

export default function PlusButton() {
React.useEffect(() => {
useEffect(() => {
const node = loadCSS(
'https://use.fontawesome.com/releases/v5.14.0/css/all.css',
// Inject before JSS
Expand Down
4 changes: 2 additions & 2 deletions src/components/Buttons/PlusButtonSmall.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import React, { useEffect } from 'react';
import { loadCSS } from 'fg-loadcss';
import { green } from '@mui/material/colors';
import IconButton from '@mui/material/IconButton';
import Icon from '@mui/material/Icon';
import PropTypes from 'prop-types';

export default function PlusButtonSmall({ onClick }) {
React.useEffect(() => {
useEffect(() => {
const node = loadCSS(
'https://use.fontawesome.com/releases/v5.14.0/css/all.css',
// Inject before JSS
Expand Down
1 change: 1 addition & 0 deletions src/components/app/About.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Avatar } from '@mui/material';
import React from 'react';

// Each .bio-item here could be extracted into a presentational component
export default function About() {
return (
<div>
Expand Down
10 changes: 0 additions & 10 deletions src/components/app/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
/* eslint-disable max-len */
import React, { useEffect, useState } from 'react';
import Box from '@mui/material/Box';
// import { Link } from '@mui/material';
import { Link } from 'react-router-dom';
import { DataGrid } from '@mui/x-data-grid';
import { useUser } from '../../hooks/LoginProvider';

const apiUrl = 'https://bienventory.herokuapp.com/api/v1/inventory/';

// const rowsArray = dataArray.map((item) => {
// return {
// id: item.id,
// col1: item.item_name,
// col2: item.total_on_hand,
// col3: item.unit_type,
// };
// });

export default function Dashboard() {
const user = useUser();
const [userData, setUserData] = useState([]);
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/Dashboard.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('Dashboard Component', () => {

const inventoryGrid = await screen.findAllByRole('row');

expect(inventoryGrid).not.toBeEmptyDOMElement;
expect(inventoryGrid).not.toBeEmptyDOMElement();
expect(container).toMatchSnapshot();
});
});
6 changes: 0 additions & 6 deletions src/components/app/Inventory/InventoryDetail.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Modal, Typography } from '@mui/material';
import React, { useEffect, useState } from 'react';
import PlusButton from '../../Buttons/PlusButton';
import MinusButton from '../../Buttons/MinusButton';
import { Box } from '@mui/system';
import Button from '@mui/material/Button';
import ButtonGroup from '@mui/material/ButtonGroup';
Expand Down Expand Up @@ -92,10 +90,6 @@ export default function InventoryDetail() {
<Typography variant="h2" align="center">
{total_on_hand} {unit_type}
</Typography>
{/* <Box sx={{ display: 'flex', justifyContent: 'space-around' }}>
<MinusButton />
<PlusButton />
</Box> */}
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/app/Inventory/InventoryDetail.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
Expand Down
1 change: 0 additions & 1 deletion src/components/app/Inventory/InventoryForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '../../../services/fetchUtils';
import { useHistory } from 'react-router-dom';
import { useUser } from '../../../hooks/LoginProvider';
// const handleChange = () => {};

//pass in click handler for either get OR put route depending on parent
export default function InventoryForm(props) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/app/Inventory/InventoryForm.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
Expand Down
1 change: 1 addition & 0 deletions src/components/app/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { uselogInUser } from '../../hooks/LoginProvider';

const responseGoogle = (response) => {
console.log(response);
// Display something to the user that login failed?
};

export default function Login() {
Expand Down
2 changes: 0 additions & 2 deletions src/components/app/Menu/MenuItemForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export default function MenuItemForm() {
setMenuItemName(target.value);
};

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

const handleIngredientArrayChange = (ingredientObj) => {
const updatedArray = [...ingredientsArray, ingredientObj];
setIngredientsArray(updatedArray);
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/LoginProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const LoginProvider = ({ children }) => {
);
};

// These three hooks below could be combined into a `useSession` (or some other name) hook
export const uselogInUser = () => {
const { logInUser } = useContext(Context);
return logInUser;
Expand All @@ -52,6 +53,7 @@ export const useUser = () => {
return user;
};

// This hook could be combined with `useUser`
export const usesetUser = () => {
const { setUser } = useContext(Context);
return setUser;
Expand Down
1 change: 1 addition & 0 deletions src/services/fetchUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Consider moving "https://bienventory.herokuapp.com/api/v1/" into .env
export const createUser = async (userData, phoneNumber) => {
let response = await fetch('https://bienventory.herokuapp.com/api/v1/users', {
method: 'POST',
Expand Down