Commit 121ccfc2 authored by Alex Pinto's avatar Alex Pinto

got rid of frontend files

parent 9a9126d9
No preview for this file type
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci
RUN npm install react-scripts@3.4.1 -g
COPY . ./
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "warehouse",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-google-login": "^5.2.2",
"react-icons": "^4.2.0",
"react-redux": "^7.2.4",
"react-scripts": "4.0.3",
"redux": "^4.1.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"web-vitals": "^1.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="stylesheet" href="./stylesheets/master.css">
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Ascend Warehouse</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
<svg id="Layer_3" enable-background="new 0 0 64 64" height="512" viewBox="0 0 64 64" width="512" xmlns="http://www.w3.org/2000/svg"><g><path d="m2 15.054h60.001v46.946h-60.001z" fill="#c1c8d1"/><path d="m1.999 15.054h60.002c-7.485-8.031-18.156-13.054-30.001-13.054s-22.516 5.023-30.001 13.054z" fill="#8892a0"/><path d="m12 29h40v33h-40z" fill="#e7e4dd"/><path d="m12 50h12v12h-12z" fill="#976947"/><path d="m12 25h40v8h-40z" fill="#758190"/><g><path d="m12 28h40v2h-40z" fill="#a8b0bc"/></g><path d="m54 25h-44v-4c0-1.105.895-2 2-2h40c1.105 0 2 .895 2 2z" fill="#243242"/><g><path d="m22 10h20v2h-20z" fill="#a8b0bc"/></g><g><path d="m22 6h20v2h-20z" fill="#a8b0bc"/></g><path d="m12 38h12v12h-12z" fill="#c18e59"/><path d="m16 38v4h4v-4" fill="#f7d881"/><path d="m16 50v4h4v-4" fill="#f7d881"/><path d="m24 50h12v12h-12z" fill="#c18e59"/><path d="m28 50v4h4v-4" fill="#f7d881"/><g><path d="m15 45h6v2h-6z" fill="#f7d881"/></g><g><path d="m27 57h6v2h-6z" fill="#f7d881"/></g><g><path d="m15 57h6v2h-6z" fill="#f7d881"/></g><path d="m62 35h-6v10h6" fill="#c66b60"/><g><path d="m6 35h2v2h-2z" fill="#758190"/></g><g><path d="m6 39h2v2h-2z" fill="#758190"/></g><g><path d="m6 43h2v2h-2z" fill="#758190"/></g><g><path d="m59 39h3v2h-3z" fill="#f7d881"/></g><path d="m32 .999c-11.612 0-22.813 4.875-30.733 13.373-.172.185-.269.429-.269.682l.002 46.946c0 .552.448 1 1 1h60c.552 0 1-.448 1-1l.001-46.945c0-.253-.096-.497-.269-.682-7.92-8.499-19.121-13.374-30.732-13.374zm27.602 13.055h-55.205c7.405-7.052 17.335-11.055 27.603-11.055 10.267 0 20.197 4.003 27.602 11.055zm-8.602 17.946h-38v-2h38zm-34 7h2v2h-2zm-1 3.999h4c.553 0 1-.447 1-1v-3h2v10h-10v-9.999h2v3c0 .552.447.999 1 .999zm1 8.001h2v2h-2zm-4 0h2v3c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-3h2v10h-10zm16 0h2v2h-2zm-1 3.999h4c.553 0 1-.447 1-1v-3h2v10h-10v-9.999h2v3c0 .552.447.999 1 .999zm8-5.999h-11v-11c0-.553-.447-1-1-1h-11v-3h38v27h-14v-11c0-.553-.448-1-1-1zm-25-25.001v-3c0-.552.448-1 1-1h40c.552 0 1 .448 1 1v3zm40 2v2h-38v-2zm2 35.001v-32-3h1c.553 0 1-.447 1-1v-4c0-1.654-1.346-3-3-3h-40c-1.654 0-3 1.346-3 3v4c0 .553.447 1 1 1h1v3 9 12 11h-8v-44.945h58v17.945h-5c-.553 0-1 .447-1 1v10c0 .553.447 1 1 1h5v15zm8-20.001v3h-4v-8h4v3h-2v2z"/><path d="m22 10h20v2h-20z"/><path d="m22 6h20v2h-20z"/><path d="m15 57h6v2h-6z"/><path d="m15 45h6v2h-6z"/><path d="m27 57h6v2h-6z"/><path d="m6 35h2v2h-2z"/><path d="m6 39h2v2h-2z"/><path d="m6 43h2v2h-2z"/></g></svg>
\ No newline at end of file
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
.filter-search {
display: flex;
align-items: center;
padding: 20px;
}
.filter-search .text {
font-size: 20px;
font-weight: 700;
}
.filter-search > * ~ * {
margin-left: 50px;
}
.filter {
display: flex;
align-items: center;
}
.filter > * ~ * {
margin-left: 10px;
}
.filter-btns {
display: flex;
justify-content: space-between;
align-items: center;
}
.filter-btns > *,
.search-btn,
.collapse-btn,
.expand-btn {
cursor: pointer;
display: flex;
align-items: center;
padding: 10px 20px;
border-radius: 5px;
border: 1px solid black;
}
.filter-btns > * ~ * {
margin-left: 10px;
}
.selected {
color: white;
}
.filter-all:hover {
background: #2b4162;
color: white;
}
.filter-all.selected {
background: #2b4162;
}
.filter-rec:hover {
background: #2292A4;
color: white;
}
.filter-rec.selected {
background: #2292A4;
}
.filter-ful:hover {
background: #4daa57;
color: white;
}
.filter-ful.selected {
background: #4daa57;
}
.filter-can:hover {
background: #c1292e;
color: white;
}
.filter-can.selected {
background: #c1292e;
}
.search {
display: flex;
align-items: center;
}
.search > * ~ * {
margin-left: 10px;
}
.search > select {
cursor: pointer;
padding: 10px 0;
font-size: 16px;
font-family: "Times New Roman", Times, serif;
}
.search > input {
padding: 10px;
font-size: 16px;
font-family: "Times New Roman", Times, serif;
}
.search-btn:hover,
.collapse-btn:hover,
.expand-btn:hover {
color: white;
background: #2b4162;
}
.search-select-error,
.search-input-error {
border: 2px solid #c1292e;
}
.fs-collapse {
display: flex;
justify-content: space-between;
}
.collapse-expand {
display: flex;
padding: 20px;
}
.collapse-expand > * ~ * {
margin-left: 10px;
}
.footer {
display: flex;
align-items: center;
height: 50px;
background: gray;
color: white;
}
\ No newline at end of file
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
height: 50px;
background: #2b4162;
color: #fff;;
font-size: 28px;
font-weight: 700;
}
.header > div {
display: flex;
align-items: center;
}
.header img {
margin-right: 10px;
width: 32px;
height: 32px;
}
\ No newline at end of file
@import './reset.css';
@import './header.css';
@import './footer.css';
@import './filter.css';
@import './order.css';
@import './session.css';
/* background: #2b4162; */
/* background: #4daa57 */
/* background: #c1292e */
/* background: #2292A4; */
/* background: #f5f0f6; */
/* background: #acb0bd; */
.order-index {
padding: 0 20px 20px;
}
.order-index > h1 {
padding: 10px 20px;
margin-bottom: 2px;
background: #2b4162;
color: white;
font-size: 24px;
font-weight: 700;
}
.order-index .oii ~ .oii {
margin-top: 15px;
}
.oii {
display: flex;
flex-direction: column;
justify-content: center;
min-height: 70px;
background: #eee;
border-radius: 5px;
font-size: 24px;
}
.oii-container {
width: 100%;
display: flex;
justify-content: space-between;
padding: 15px;
box-sizing: border-box;
}
.oii-left {
display: flex;
align-items: center;
}
.oii-drop {
transition: transform 1s;
cursor: pointer;
margin-right: 10px;
padding: 5px;
font-size: 20px;
background: white;
border-radius: 50%;
}
.oii-drop.rotate {
transition: transform 1s;
transform: rotate(90deg);
}
.oii-num {
display: flex;
align-items: center;
}
.oii-buttons, .oii-status {
display: flex;
justify-content: center;
align-items: center;
width: 200px;
font-size: 20px;
}
.oii-buttons > div {
cursor: pointer;
display: flex;
align-items: center;
background: white;
border-radius: 5px;
padding: 10px 20px;
}
.oii-buttons > * ~ * {
margin-left: 10px;
}
.oii-status.fulfilled {
color: #4daa57;
}
.oii-status.cancelled {
color: #c1292e;
}
.fulfill-btn {
position: relative;
border: 1px solid #4daa57;
color: #4daa57;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
0 1px 1px rgba(0, 0, 0, 0.5);
}
.fulfill-btn:hover {
color: white;
background: #4daa57;
box-shadow: none;
}
.cancel-btn {
position: relative;
border: 1px solid #c1292e;
color: #c1292e;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
0 1px 1px rgba(0, 0, 0, 0.5);
}
.cancel-btn:hover {
color: white;
background: #c1292e;
}
.fulfill-btn:active, .cancel-btn:active {
top: 2px;
}
.order-details {
display: flex;
flex-direction: column;
font-size: 18px;
max-height: 0px;
overflow: hidden;
transition: max-height 1s ease-out;
}
.order-details-container {
overflow: hidden;
padding: 20px 50px;
box-sizing: border-box;
overflow: auto;
}
.animate {
transition: max-height 0.75s ease-in-out;
max-height: 400px;
}
.order-details-header {
padding: 4px 0;
font-size: 20px;
font-weight: 700;
border-bottom: 2px solid black;
display: flex;
justify-content: space-between;
}
.order-details-name {
display: flex;
align-items: center;
}
.order-details-dates {
display: flex;
flex-direction: column;
font-weight: 400;
font-size: 16px;
font-style: italic;
width: 275px;
}
.order-details-dates > div {
display: flex;
justify-content: space-between;
}
.order-detail-table {
margin: 15px;
}
.order-detail-table thead {
font-weight: 700;
border-bottom: 1px solid black;
}
.order-detail-table th,
.order-detail-table td {
padding: 5px 20px;
}
.item-sku, .item-qty {
text-align: center;
}
.item-price {
text-align: end;
}
.order-detail-table th ~ th,
.order-detail-table td ~ td {
border-left: 1px solid black;
}
.no-orders {
padding: 50px;
display: flex;
justify-content: center;
font-size: 28px;
}
\ No newline at end of file
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
select:focus, input:focus {
outline: none;
}
\ No newline at end of file
.login {
padding: 50px;
display: flex;
justify-content: center;
}
\ No newline at end of file
import { useEffect, useState } from "react";
import { connect } from "react-redux";
import OrderIndex from "./components/order/OrderIndex";
import NoOrders from "./components/order/NoOrders";
import { fetchOrders } from "./actions/order_actions";
import FilterSearch from "./components/filter/FilterSearch";
import Button from "./components/atoms/Button";
const App = ({ orders, fetchOrders }) => {
const [ordersToShow, setOrdersToShow] = useState(orders);
const [fetchAttempted, setFetchAttempted] = useState(false);
const [collapseAll, setCollapseAll] = useState(false);
const [expandAll, setExpandAll] = useState(false);
useEffect(() => {
if (!fetchAttempted) {
fetchOrders();
setFetchAttempted(true);
}
setOrdersToShow(orders);
}, [orders, fetchOrders, fetchAttempted]);
return (
<div className="app">
<div className="fs-collapse">
<FilterSearch setOrdersToShow={setOrdersToShow} />
<div className="collapse-expand">
<Button
className="collapse-btn"
onClick={() => setCollapseAll(true)}
text={`Collapse All`}
/>
<Button
className="expand-btn"
onClick={() => setExpandAll(true)}
text={`Expand All`}
/>
</div>
</div>
{ordersToShow.allIds.length ? (
<OrderIndex
orders={ordersToShow}
collapseAll={collapseAll}
expandAll={expandAll}
setCollapseAll={setCollapseAll}
setExpandAll={setExpandAll}
/>
) : (
<NoOrders />
)}
</div>
);
};
const mapStateToProps = (state) => ({
orders: state.entities.orders,
});
const mapDispatchToProps = (dispatch) => ({
fetchOrders: () => dispatch(fetchOrders()),
});
export default connect(mapStateToProps, mapDispatchToProps)(App);
import { connect } from "react-redux";
import Header from "./components/header/Header";
import App from "./App"
import Login from "./components/session/Login";
const Root = ({ isLoggedIn }) => {
return (
<div>
<Header />
{isLoggedIn ?
<App /> :
<Login />
}
</div>
);
}
const mapStateToProps = (state) => ({
isLoggedIn: state.session.isAuthenticated,
});
const mapDispatchToProps = (dispatch) => ({
});
export default connect(mapStateToProps, mapDispatchToProps)(Root);
\ No newline at end of file
import * as OrderAPIUtil from '../util/orders_api_util';
export const RECEIVE_ORDERS = 'RECEIVE_ORDERS';
export const UPDATE_ORDER = 'UPDATE_ORDER';
const receiveOrders = (orders) => ({
type: RECEIVE_ORDERS,
orders,
})
const updateOrder = (order) => ({
type: UPDATE_ORDER,
order,
})
export const fetchOrders = () => (dispatch) => {
OrderAPIUtil.getOrders()
.then(res => {
dispatch(receiveOrders(res.data))
});
}
export const editOrder = (order) => (dispatch) => {
OrderAPIUtil.editOrder(order)
.then(res => {
dispatch(updateOrder(res.data))
});
}
\ No newline at end of file
import * as SessionAPIUtil from "../util/session_api_util";
export const LOGIN_USER = "LOGIN_USER";
export const LOGOUT_USER = "LOGOUT_USER";
const receiveLogin = (user) => ({
type: LOGIN_USER,
user,
});
const receiveLogout = () => ({
type: LOGOUT_USER,
});
export const login = (payload) => (dispatch) => {
SessionAPIUtil.createSession(payload).then((res) => {
const { status, data } = res;
if (status < 299) {
dispatch(receiveLogin(data));
}
});
};
export const logout = () => (dispatch) => {
dispatch(receiveLogout());
};
const Button = ({ className, onClick, text }) => (
<div className={className} onClick={onClick}>
{text}
</div>
)
export default Button;
\ No newline at end of file
const Error = ({ text, className }) => (
<div className={`error ${className || ""}`}>
{text}
</div>
)
export default Error;
\ No newline at end of file
const Image = ({ src }) => (
<img src={src} alt=""/>
)
export default Image;
\ No newline at end of file
const Input = ({
className,
type,
placeholder,
value,
onChange,
onBlur,
onKeyPress,
}) => (
<input
type={type || "text"}
className={className}
placeholder={placeholder}
value={value}
onChange={onChange}
onBlur={onBlur}
onKeyPress={onKeyPress}
/>
);
export default Input;
const Select = ({ className, defaultVal, value, onChange, options }) => (
<select
className={className}
value={value ? value : defaultVal}
onChange={onChange}
>
{defaultVal ? (
<option disabled>{defaultVal}</option>
) : null}
{options.map(option => (
<option key={option} value={option}>
{option}
</option>
))}
</select>
)
export default Select;
\ No newline at end of file
import { useEffect, useState } from "react";
import { connect } from "react-redux";
import Button from "../atoms/Button";
const Filter = ({ orders, filtersOn, setFiltersOn, setOrdersToShow }) => {
const [all, setAll] = useState(false);
const [received, setReceived] = useState(false);
const [fulfilled, setFulfilled] = useState(false);
const [cancelled, setCancelled] = useState(false);
const RECEIVED = "RECEIVED";
const FULFILLED = "FULFILLED";
const CANCELLED = "CANCELLED";
const reset = () => {
setAll(true);
setFiltersOn(true);
setReceived(false);
setFulfilled(false);
setCancelled(false);
};
const receive = () => {
setAll(false);
setFiltersOn(true);
setReceived(!received);
if (received && !fulfilled && !cancelled) {
setAll(true);
}
};
const fulfill = () => {
setAll(false);
setFiltersOn(true);
setFulfilled(!fulfilled);
if (!received && fulfilled && !cancelled) {
setAll(true);
}
};
const cancel = () => {
setAll(false);
setFiltersOn(true);
setCancelled(!cancelled);
if (!received && !fulfilled && cancelled) {
setAll(true);
}
};
useEffect(() => {
if (!filtersOn) {
setAll(false);
setReceived(false);
setFulfilled(false);
setCancelled(false);
} else if (all || (!all && !received && !fulfilled && !cancelled)) {
setOrdersToShow(orders);
} else {
const newOrders = { allIds: [], byId: {} };
orders.allIds.forEach((wareId) => {
const order = orders.byId[wareId];
switch (order.status) {
case RECEIVED:
if (all || received) {
newOrders.allIds.push(wareId);
newOrders.byId[wareId] = order;
}
break;
case FULFILLED:
if (all || fulfilled) {
newOrders.allIds.push(wareId);
newOrders.byId[wareId] = order;
}
break;
case CANCELLED:
if (all || cancelled) {
newOrders.allIds.push(wareId);
newOrders.byId[wareId] = order;
}
break;
default:
break;
}
});
setOrdersToShow(newOrders);
}
}, [orders, setOrdersToShow, filtersOn, all, received, fulfilled, cancelled]);
if (!orders.allIds.length) return null;
return (
<div className="filter">
<div className="text">Filter:</div>
<div className="filter-btns">
<Button
className={`filter-all ${all ? "selected" : ""}`}
onClick={reset}
text="All"
/>
<Button
className={`filter-rec ${received ? "selected" : ""}`}
onClick={receive}
text="Received"
/>
<Button
className={`filter-ful ${fulfilled ? "selected" : ""}`}
onClick={fulfill}
text="Fulfilled"
/>
<Button
className={`filter-can ${cancelled ? "selected" : ""}`}
onClick={cancel}
text="Cancelled"
/>
</div>
</div>
);
};
const mapStateToProps = (state) => ({
orders: state.entities.orders,
});
const mapDispatchToProps = (dispatch) => ({});
export default connect(mapStateToProps, mapDispatchToProps)(Filter);
import { useState } from "react";
import Filter from "./Filter";
import Search from "./Search";
const FilterSearch = ({ setOrdersToShow }) => {
const [filtersOn, setFiltersOn] = useState(true);
return (
<div className="filter-search">
<Filter
filtersOn={filtersOn}
setFiltersOn={setFiltersOn}
setOrdersToShow={setOrdersToShow}
/>
<Search setOrdersToShow={setOrdersToShow} setFiltersOn={setFiltersOn} />
</div>
);
};
export default FilterSearch;
import { useState } from "react";
import { connect } from "react-redux";
import Select from "../atoms/Select";
import Input from "../atoms/Input";
import Button from "../atoms/Button";
const Search = ({ orders, setOrdersToShow, setFiltersOn }) => {
const [searchInput, setSearchInput] = useState("");
const [searchBy, setSearchBy] = useState("");
const [inputError, setInputError] = useState(false);
const [byError, setByError] = useState(false);
const searchOptions = ["Warehouse ID", "Order ID"];
const search = () => {
setInputError(false);
setByError(false);
if (!searchInput.length && !searchBy.length) {
setInputError(true);
setByError(true);
} else if (!searchInput.length) {
setInputError(true);
} else if (!searchBy.length) {
setByError(true);
} else {
const searchResult = { allIds: [], byId: {} };
const searchedOrder =
searchBy === searchOptions[0]
? orders.byId[searchInput]
: searchBy === searchOptions[1]
? orders.byOrderId[searchInput]
: null;
if (searchedOrder) {
searchResult.allIds.push(searchedOrder.id);
searchResult.byId[searchedOrder.id] = searchedOrder;
}
if (searchBy.length) {
setOrdersToShow(searchResult);
}
setSearchInput("");
setFiltersOn(false);
}
};
const handleInputBlur = (e) => {
if (!e.target.value.length) {
setInputError(true);
}
};
const handleSearchEnter = (e) => {
if (e.key === "Enter") {
search();
}
};
return (
<div className="search">
<div className="text">Search:</div>
<Select
className={byError ? "search-select-error" : ""}
defaultVal={"Choose one.."}
value={searchBy}
options={searchOptions}
onChange={(e) => {
setByError(false);
setSearchBy(e.target.selectedOptions[0].value);
}}
/>
<Input
className={inputError ? "search-input-error" : ""}
placeholder={"Search by ID"}
value={searchInput}
onChange={(e) => {
setInputError(false);
setSearchInput(e.target.value);
}}
onBlur={handleInputBlur}
onKeyPress={handleSearchEnter}
/>
<Button className="search-btn" text="Search" onClick={search} />
</div>
);
};
const mapStateToProps = (state) => ({
orders: state.entities.orders,
});
const mapDispatchToProps = (dispatch) => ({});
export default connect(mapStateToProps, mapDispatchToProps)(Search);
import React from "react";
const Footer = () => {
return (
<div className="footer">
Footer
</div>
);
};
export default Footer;
import { connect } from "react-redux";
import Image from "../atoms/Image";
import Logout from "../session/Logout";
const Header = ({ isLoggedIn, logout }) => {
return (
<div className="header">
<div>
<Image src="./logo.svg" />
<div>Warehouse Management</div>
</div>
{isLoggedIn ? <Logout onClick={logout} /> : null}
</div>
);
};
const mapStateToProps = (state) => ({
isLoggedIn: state.session.isAuthenticated,
});
const mapDispatchToProps = (dispatch) => ({});
export default connect(mapStateToProps, mapDispatchToProps)(Header);
const ItemDetails = ({ item }) => {
const { itemName, itemQuantity, itemPrice, itemSku } = item;
return (
<tr className="item-detail">
<td className="item-sku">{itemSku}</td>
<td className="item-name">{itemName}</td>
<td className="item-qty">{itemQuantity}</td>
<td className="item-price">{`$${itemPrice.toFixed(2)}`}</td>
</tr>
);
};
export default ItemDetails;
const NoOrders = () => (
<div className="no-orders">
Hmm, it doesn't seem like there were any orders found...
</div>
)
export default NoOrders;
\ No newline at end of file
import React from "react";
import { connect } from "react-redux";
import { editOrder } from "../../actions/order_actions";
import Button from "../atoms/Button";
const OrderButtons = ({ order, editOrder }) => {
const handleUpdate = (action) => {
console.log(action);
if (action === "FULFILL") {
editOrder({ ...order, status: "FULFILLED" });
} else if (action === "CANCEL") {
editOrder({ ...order, status: "CANCELLED" });
}
};
return (
<div className="oii-buttons">
<Button className="fulfill-btn" onClick={() => handleUpdate("FULFILL")} text="Fulfill"/>
<Button className="cancel-btn" onClick={() => handleUpdate("CANCEL")} text="Cancel"/>
</div>
);
};
const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({
editOrder: (order) => dispatch(editOrder(order)),
});
export default connect(mapStateToProps, mapDispatchToProps)(OrderButtons);
import ItemDetails from "./ItemDetails";
const OrderDetails = ({ order, showDetails }) => {
const createdDate = new Date(order.createdAt);
const modifiedDate = new Date(order.modifiedAt);
const status =
order.status[0].toUpperCase() + order.status.substr(1).toLowerCase();
const dateToString = (date) => {
const month = date.toLocaleString("default", { month: "short" });
const day = date.getDate();
const year = date.getFullYear();
const hour = date.getHours();
const cHour = hour > 12 ? hour - 12 : hour;
const minute = date.getMinutes();
const time = `${cHour > 9 ? cHour : `0${cHour}`}:${minute > 9 ? minute : `0${minute}`}`;
return `${month} ${day > 9 ? day : `0${day}`}, ${year} at ${time} ${hour > 11 ? "PM" : "AM"}`;
};
return (
<div className={`order-details ${showDetails ? "animate" : ""}`}>
<div className="order-details-container">
<div className="order-details-header">
<div className="order-details-name">Order Details:</div>
<div className="order-details-dates">
<div>
<div>Created on:</div>
<div>{dateToString(createdDate)}</div>
</div>
{order.modifiedAt ? (
<div>
<div>{`${status} on:`}</div>
<div>{dateToString(modifiedDate)}</div>
</div>
) : null}
</div>
</div>
<table className="order-detail-table">
<thead>
<tr>
<th>SKU #</th>
<th>Name</th>
<th>Quantity</th>
<th>Price</th>
</tr>
</thead>
<tbody>
{order.orderItems.map((item) => (
<ItemDetails key={item.itemId} item={item} />
))}
</tbody>
</table>
{`Warehouse Order #: ${order.id}`}
</div>
</div>
);
};
export default OrderDetails;
import OrderIndexItem from './OrderIndexItem';
const OrderIndex = ({
orders,
collapseAll,
expandAll,
setCollapseAll,
setExpandAll,
}) => {
return (
<div className="order-index">
<h1>Orders</h1>
{orders.allIds.map((orderId) => {
const order = orders.byId[orderId];
return (
<OrderIndexItem
key={order.id}
order={order}
collapseAll={collapseAll}
expandAll={expandAll}
setCollapseAll={setCollapseAll}
setExpandAll={setExpandAll}
/>
);
})}
</div>
);
}
export default OrderIndex;
\ No newline at end of file
import React, { useEffect, useState } from "react";
import OrderButtons from "./OrderButtons";
import { FiChevronRight } from "react-icons/fi";
import OrderDetails from "./OrderDetails";
const OrderIndexItem = ({
order,
collapseAll,
expandAll,
setCollapseAll,
setExpandAll,
}) => {
const { orderId, status } = order;
const [showDetails, setShowDetails] = useState(false);
useEffect(() => {
if (collapseAll) {
setShowDetails(false);
}
if (expandAll) {
setShowDetails(true);
}
setCollapseAll(false);
setExpandAll(false);
}, [showDetails, collapseAll, expandAll, setCollapseAll, setExpandAll]);
const handleDropDown = () => {
setShowDetails(!showDetails);
};
const actions =
status === "FULFILLED" || status === "CANCELLED" ? (
<div className={`oii-status ${status.toLowerCase()}`}>{status}</div>
) : (
<OrderButtons order={order} />
);
return (
<div className="oii">
<div className="oii-container">
<div className="oii-left">
<FiChevronRight
className={`oii-drop ${showDetails ? "rotate" : ""}`}
onClick={handleDropDown}
/>
<div className="oii-num">{`Order #: ${orderId}`}</div>
</div>
{actions}
</div>
<OrderDetails showDetails={showDetails} order={order} />
</div>
);
};
export default OrderIndexItem;
import React from "react";
import { connect } from "react-redux";
import { GoogleLogin } from "react-google-login";
import keys from "../../config/keys_dev";
import { login } from "../../actions/session_actions";
const clientId = keys.clientId;
const Login = ({ login }) => {
const responseGoogle = (googleResponse) => {
const { tokenId, profileObj } = googleResponse;
login({ token: tokenId, user: profileObj });
};
return (
<div className="login">
<GoogleLogin
clientId={clientId}
buttonText="Login with Google"
onSuccess={responseGoogle}
onFailure={responseGoogle}
cookiePolicy={"single_host_origin"}
isSignedIn={true}
/>
</div>
);
};
const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({
login: (token) => dispatch(login(token)),
});
export default connect(mapStateToProps, mapDispatchToProps)(Login);
import { connect } from "react-redux";
import { GoogleLogout } from "react-google-login";
import { logout } from "../../actions/session_actions";
import keys from "../../config/keys_dev";
const clientId = keys.clientId;
const Logout = ({ logout }) => {
const responseGoogle = (googleResponse) => {
logout();
};
return (
<div>
<GoogleLogout
clientId={clientId}
buttonText="Logout"
onLogoutSuccess={responseGoogle}
/>
</div>
);
};
const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({
logout: () => dispatch(logout()),
});
export default connect(mapStateToProps, mapDispatchToProps)(Logout);
import React from 'react';
import ReactDOM from 'react-dom';
import reportWebVitals from './reportWebVitals';
import configureStore from './store/store';
import { Provider } from 'react-redux';
import Root from './Root';
document.addEventListener('DOMContentLoaded', () => {
const store = configureStore();
ReactDOM.render(
<Provider store={store}>
<Root />
</Provider>,
document.getElementById('root')
);
});
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
import { combineReducers } from "redux";
import orders from "./orders_reducer";
const EntitiesReducer = combineReducers({
orders,
});
export default EntitiesReducer;
import {
RECEIVE_ORDERS,
UPDATE_ORDER,
} from "../../actions/order_actions";
const initialState = {
byId: {},
allIds: [],
};
const OrdersReducer = (oldState = initialState, action) => {
Object.freeze(oldState);
const newState = { ...oldState };
const order = action.order || null;
switch (action.type) {
case RECEIVE_ORDERS:
const orderState = {
byId: {},
allIds: [],
byOrderId: {},
};
action.orders.forEach( order => {
orderState.allIds.push(order.id);
orderState.byId[order.id] = order;
orderState.byOrderId[order.orderId] = order;
})
return orderState;
case UPDATE_ORDER:
newState.byId[order.id] = order;
return newState;
default:
return oldState;
}
};
export default OrdersReducer;
import { combineReducers } from "redux";
import entities from "./entities/entities_reducer";
import session from "./session/session_reducer";
const RootReducer = combineReducers({
entities,
session,
});
export default RootReducer;
import { LOGIN_USER, LOGOUT_USER } from "../../actions/session_actions";
const initialState = {
isAuthenticated: false,
user: null
}
const SessionState = (oldState = initialState, action) => {
Object.freeze(oldState);
switch (action.type) {
case LOGIN_USER:
return {
isAuthenticated: !!action.user,
user: action.user,
}
case LOGOUT_USER:
return initialState;
default:
return oldState;
}
}
export default SessionState;
\ No newline at end of file
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
import { createStore, applyMiddleware } from 'redux';
import { createLogger } from 'redux-logger';
import thunk from 'redux-thunk';
import rootReducer from '../reducers/root_reducer';
const logger = createLogger();
const configureStore = (preloadedState = {}) => (
createStore(
rootReducer,
preloadedState,
applyMiddleware(thunk, logger),
)
)
export default configureStore;
\ No newline at end of file
import axios from 'axios';
export const getOrders =() => {
return axios.get(`http://localhost:8080/api/orders`);
}
export const editOrder = (order) => {
return axios.put(`http://localhost:8080/api/orders/${order.id}`, order)
}
import axios from "axios";
export const createSession = (payload) => {
return axios
.post("http://localhost:8080/api/auth", payload)
.catch((err) => err.response);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment