Skip to content

Commit

Permalink
some good updates (now im happy)
Browse files Browse the repository at this point in the history
  • Loading branch information
imkarimkarim committed Aug 19, 2021
1 parent f9b198f commit 42b661d
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 418 deletions.
2 changes: 1 addition & 1 deletion src/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export default function App() {
<Route path="/editFactor/:id" component={EditFactor} />
<Route path="/editProduct/:id" component={EditProduct} />
<Route path="/editCar/:id" component={EditCar} />
<Route path="/productDetails/:id" component={ProductDetails} />
<Route path="/printProducts/:ids" component={PrintProducts} />
<Route path="/printCar/:id" component={PrintCar} />
<Route path="/printFactors/:date/:date2" component={PrintFactors} />
<Route path="/productDetails/:id" component={ProductDetails} />
<Route
path="/printRemainingProducts"
component={PrintRemainingProducts}
Expand Down
37 changes: 23 additions & 14 deletions src/App/Components/Loading.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import React from "react";
import React, { useState } from "react";
import Button from "@material-ui/core/Button";
import CircularProgress from "@material-ui/core/CircularProgress";
import "./Loading.css";
import { Redirect } from "react-router-dom";

export default function Loading({ history }) {
const [goBack, setGoBack] = useState(false);

return (
<div className="loadingLoading">
<CircularProgress />
<p className="hint">درحال دریافت اطلاعات...</p>
<Button variant="outlined">
<span
className="button-title"
onClick={() => {
history.goBack();
}}
>
انصراف
</span>
</Button>
<div>
{goBack ? (
<Redirect to="/welcome" />
) : (
<div className="loadingLoading">
<CircularProgress />
<p className="hint">درحال دریافت اطلاعات...</p>
<Button variant="outlined">
<span
className="button-title"
onClick={() => {
setGoBack(true);
}}
>
انصراف
</span>
</Button>
</div>
)}
</div>
);
}
185 changes: 111 additions & 74 deletions src/App/Components/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";
import MenuIcon from "@material-ui/icons/Menu";
import ArrowForwardIcon from "@material-ui/icons/ArrowForward";
import HomeIcon from "@material-ui/icons/Home";
Expand All @@ -7,16 +7,47 @@ import ImportExportIcon from "@material-ui/icons/ImportExport";
import EqualizerIcon from "@material-ui/icons/Equalizer";
import ShoppingCartIcon from "@material-ui/icons/ShoppingCart";
import NoteIcon from "@material-ui/icons/Note";
import { Redirect } from "react-router-dom";

import { Link } from "react-router-dom";
import "./Nav.css";
import Button from "@material-ui/core/Button";
import Menu from "@material-ui/core/Menu";
import MenuItem from "@material-ui/core/MenuItem";

export default function Nav({ title, history }) {
const [anchorEl, setAnchorEl] = React.useState(null);
const fidnParentPath = (path) => {
const extractParentPath = (path) => {
return "/" + path.split("/")[1];
};
const extractChildPath = (path) => {
return "/" + path.split("/")[2];
};

if (path === "/welcome") return "/welcome";
else if (path === "/includeCar") return "/welcome";
else if (path === "/newFactor") return "/welcome";
else if (path === "/newName") return "/welcome";
else if (path === "/reports") return "/welcome";
else if (path === "/searchProducts") return "/reports";
else if (path === "/searchCars") return "/reports";
else if (path === "/searchFactors") return "/reports";
else if (extractParentPath(path) === "/product") return "/searchProducts";
else if (extractParentPath(path) === "/car") return "/searchCars";
else if (extractParentPath(path) === "/factor") return "/searchFactors";
else if (extractParentPath(path) === "/editFactor")
return "/factor" + extractChildPath(path);
else if (extractParentPath(path) === "/editProduct")
return "/product" + extractChildPath(path);
else if (extractParentPath(path) === "/editCar")
return "/car" + extractChildPath(path);
else if (extractParentPath(path) === "/productDetails")
return "/product" + extractChildPath(path);
else return "/welcome";
};

export default function Nav({ title, history }) {
const [anchorEl, setAnchorEl] = useState();
const [goBack, setGoBack] = useState(false);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
Expand All @@ -26,78 +57,84 @@ export default function Nav({ title, history }) {
};

return (
<nav>
<ArrowForwardIcon
color="action"
className="goBack"
fontSize="large"
onClick={() => {
history.goBack();
}}
/>
<div>
<Link to="/welcome">
<HomeIcon color="action" fontSize="large" />
</Link>
<div
aria-controls="simple-menu"
aria-haspopup="true"
onClick={handleClick}
>
<MenuIcon color="action" fontSize="large" />
</div>
<Menu
id="simple-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleClose}
>
<MenuItem onClick={handleClose}>
<div>
{goBack ? (
<Redirect to={fidnParentPath(history.location.pathname)} />
) : (
<nav>
<ArrowForwardIcon
color="action"
className="goBack"
fontSize="large"
onClick={() => {
setGoBack(true);
}}
/>
<div>
<Link to="/welcome">
<HomeIcon />
خانه
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/reports">
<EqualizerIcon />
گزارشات
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/searchProducts">
<ShoppingCartIcon />
بارها
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/searchCars">
<ShoppingCartIcon />
صافی ها
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/includeCar">
<ImportExportIcon />
ورود بار
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/searchFactors">
<NoteIcon />
فاکتورها
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/newFactor">
<NoteAddIcon />
فاکتور جدید
<HomeIcon color="action" fontSize="large" />
</Link>
</MenuItem>
</Menu>
</div>
<Link to="/welcome"></Link>
</nav>
<div
aria-controls="simple-menu"
aria-haspopup="true"
onClick={handleClick}
>
<MenuIcon color="action" fontSize="large" />
</div>
<Menu
id="simple-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleClose}
>
<MenuItem onClick={handleClose}>
<Link to="/welcome">
<HomeIcon />
خانه
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/reports">
<EqualizerIcon />
گزارشات
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/searchProducts">
<ShoppingCartIcon />
بارها
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/searchCars">
<ShoppingCartIcon />
صافی ها
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/includeCar">
<ImportExportIcon />
ورود بار
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/searchFactors">
<NoteIcon />
فاکتورها
</Link>
</MenuItem>
<MenuItem onClick={handleClose}>
<Link to="/newFactor">
<NoteAddIcon />
فاکتور جدید
</Link>
</MenuItem>
</Menu>
</div>
<Link to="/welcome"></Link>
</nav>
)}
</div>
);
}
41 changes: 25 additions & 16 deletions src/App/Components/NotFound.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
import React from "react";
import React, { useState } from "react";
import ErrorIcon from "@material-ui/icons/Error";
import Button from "@material-ui/core/Button";
import Nav from "./Nav.jsx";
import "./NotFound.css";
import { Redirect } from "react-router-dom";


export default function NotFound({ history }) {
const [goBack, setGoBack] = useState(false);
return (
<div>
<Nav history={history} />
<div className="notFound">
<ErrorIcon />
<p className="hint">مشکلی پیش آمده است! با پشتیبانی تماس بگیرید.</p>
<Button variant="outlined">
<span
className="button-title"
onClick={() => {
history.goBack();
}}
>
انصراف
</span>
</Button>
</div>
{goBack ? (
<Redirect to="/welcome" />
) : (
<div>
<Nav history={history} />
<div className="notFound">
<ErrorIcon />
<p className="hint">مشکلی پیش آمده است! با پشتیبانی تماس بگیرید.</p>
<Button variant="outlined">
<span
className="button-title"
onClick={() => {
setGoBack(true);
}}
>
انصراف
</span>
</Button>
</div>
</div>
)}
</div>
);
}
1 change: 0 additions & 1 deletion src/App/Pages/Product/Product.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import ShowDate from "../../Components/ShowDate.jsx";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Switch from "@material-ui/core/Switch";
import "./Product.css";
import html2pdf from "html2pdf.js";

// TODO: add delete button

Expand Down
Loading

0 comments on commit 42b661d

Please sign in to comment.