Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
57a9c64
adding message when meals catalog is empty
hftamayo Apr 26, 2022
f5ec513
fixing bug on post orders
hftamayo Apr 26, 2022
a69060d
minor updates on order details
hftamayo Apr 26, 2022
99545ef
validating materialui autocomplete part1
hftamayo Apr 26, 2022
7b52023
changing order details workflow part1
hftamayo Apr 28, 2022
e50c400
showing button set depends on conditional
hftamayo Apr 28, 2022
d703f52
changing order details workflow final part
hftamayo Apr 28, 2022
6e70624
fixing sending order confirmation part1
hftamayo Apr 28, 2022
f79c6f9
fixing bug on showing order sent fragment
hftamayo May 2, 2022
b09b8b9
trying to validate autocomplete control
hftamayo May 4, 2022
c74c20c
adding catch to http responses
hftamayo May 4, 2022
58ff181
starting classes and components for login model
hftamayo May 4, 2022
d20459e
last login integration before go to experimental
hftamayo May 4, 2022
dd1f9c7
filtering shoppingCart display based on login
hftamayo May 9, 2022
988016d
integrating classes and objects on Header bundle
hftamayo May 9, 2022
966a2a2
filtering addToCart is not logged in
hftamayo May 9, 2022
3421575
adding login component
hftamayo May 12, 2022
f6127ae
including LoginIcon component
hftamayo May 12, 2022
ceddb28
updating handlers for LoginForm
hftamayo May 12, 2022
b7a95e2
FoodOrder with loginchecking and UI for Login Form
hftamayo May 18, 2022
6b8bda7
login form: pre alpha, switching to modal
hftamayo May 23, 2022
ac4be44
updating login form to modal part 1
hftamayo May 23, 2022
8c931cb
updating login form to modal part 2
hftamayo May 24, 2022
9f643e4
adjusting objects on foodorder component
hftamayo May 24, 2022
476cc06
displaying login form as modal
hftamayo May 24, 2022
4cc8e9a
adjusting login css for buttons
hftamayo May 24, 2022
76cb848
component for signup process
hftamayo May 30, 2022
43036a7
adjusting handlers and states names
hftamayo May 30, 2022
5b26028
updating signup form objects
hftamayo May 30, 2022
eb5dfb3
adding signup button component
hftamayo May 30, 2022
b441608
adding signupicon component
hftamayo May 30, 2022
c3ee2e0
updating login icon
hftamayo May 30, 2022
40e08d3
updating signup icon
hftamayo May 30, 2022
1061413
adding callback to signupbutton on header comp.
hftamayo May 30, 2022
ee4fc9d
updating foodorder with signup callback
hftamayo May 30, 2022
0e6b34d
minor bug on signup
hftamayo May 30, 2022
1586585
displaying signup and login buttons on desktop p1
hftamayo May 30, 2022
42aad3c
displaying signup and login buttons on desktop p2
hftamayo May 31, 2022
ba2ced8
disabling autcomplete on inputs (test on incogn)
hftamayo Jun 4, 2022
ff4333c
disabling autcomplete on inputs (test on incogn)
hftamayo Jun 4, 2022
48b1cc6
signup form: add address button
hftamayo Jun 4, 2022
5dc7c5d
adding developer log file - cherrytree
hftamayo Jun 4, 2022
e1ade2c
updating dev notes
hftamayo Jun 6, 2022
c696c07
removing add address button
hftamayo Jun 6, 2022
cd22bc1
updating app port runtime
hftamayo Jun 6, 2022
f79125d
getting meals from ror
hftamayo Jun 6, 2022
e6b19a8
updating app port runtime
hftamayo Jun 6, 2022
da663a6
minor change on getting meals
hftamayo Jun 6, 2022
ef3dddb
updating endpoint address on available meals
hftamayo Jun 7, 2022
712b014
keep working on cors and getting json data
hftamayo Jun 8, 2022
db327a7
keep working on cors and getting json data
hftamayo Jun 8, 2022
14867e3
cleaning response object for get request
hftamayo Jun 9, 2022
abf3fcf
linking proxy var to rails ip and port
hftamayo Jun 9, 2022
36a2fbe
adjusting price variable to parse the value
hftamayo Jun 9, 2022
bde9b69
minor adjust on signup component
hftamayo Jun 9, 2022
b11db9e
fixing price on CartItem
hftamayo Jun 9, 2022
33e4531
preparing components for testing with backend
hftamayo Jun 18, 2022
323fb80
updating components during signup testing
hftamayo Jun 19, 2022
d5b27f7
fixing minor bug on signup component
hftamayo Jun 20, 2022
edb7a8d
minor updates for login handshake
hftamayo Jun 20, 2022
c63059d
adding authprovider context component
hftamayo Jun 20, 2022
6f671be
enabling AuthContext on App Component
hftamayo Jun 20, 2022
a609686
adjusting authprovider component
hftamayo Jun 20, 2022
247fbce
adding onValidSession method
hftamayo Jun 20, 2022
73c2ccc
minor changes on auth context
hftamayo Jun 20, 2022
5be19db
minor updates on authprovider and index components
hftamayo Jun 20, 2022
12d0cb7
adding logout component
hftamayo Jun 20, 2022
9e3a3e5
clearing an uneeded code sentence
hftamayo Jun 21, 2022
5c22052
adding localendpoint and fixing buttons display
hftamayo Jun 21, 2022
5b4a73a
fixing minor bug on cart
hftamayo Jun 21, 2022
7c38d0f
removing temporary paymentmethod validation
hftamayo Jun 21, 2022
65c6931
removing temporary paymentmethod validation
hftamayo Jun 21, 2022
7b66b8d
updating signup for user data entry
hftamayo Jun 21, 2022
f785229
minor changes on signup: bug on fetch entered data
hftamayo Jun 21, 2022
502ef37
adding useref to login component part1
hftamayo Jun 21, 2022
99d2d77
adding useRef to login component part2
hftamayo Jun 21, 2022
3fd86af
fixing a bug related to useref in input component
hftamayo Jun 21, 2022
0f2b974
handling user data input
hftamayo Jun 21, 2022
6cd3ec1
fixing last bug on signup component
hftamayo Jun 21, 2022
b167c74
login process handling user data input
hftamayo Jun 21, 2022
729e163
adding scrum screenshots
hftamayo Jul 4, 2022
48dba0f
replacing autocomplete with materialui select
hftamayo Jul 7, 2022
76d96f8
pre-alpha of validating method of payment
hftamayo Jul 7, 2022
f8237ce
fixing css classes for method of payment
hftamayo Jul 8, 2022
26e4c76
alpha version of method of payment validation
hftamayo Jul 8, 2022
cf8dde6
re-enabling props.input.id to display spinner
hftamayo Jul 8, 2022
be705b3
fixing a new bug in method of payment
hftamayo Jul 8, 2022
a8135c4
debugging cart items part1
hftamayo Jul 10, 2022
ce1953b
polishing the function to manage cart items
hftamayo Jul 26, 2022
1caa945
merging place order button in cart component
hftamayo Jul 26, 2022
43507b4
removing confirm button from order det component
hftamayo Jul 26, 2022
26ffd29
catching the status of the post request
hftamayo Jul 27, 2022
cf32942
displaying a brief message of sending data
hftamayo Jul 27, 2022
c958cbc
simplify header button management part1
hftamayo Jul 27, 2022
2b65a86
updates on signupicon component
hftamayo Jul 27, 2022
15e20f0
updating loginicon to usericon component
hftamayo Jul 27, 2022
a39d4ff
removing logout button
hftamayo Jul 27, 2022
5c57acb
moving header buttons comps to a single dir
hftamayo Jul 27, 2022
a87bff3
moving headercart button UI to buttons dir
hftamayo Jul 27, 2022
7febba8
moving headercart buttons ui to buttons dir
hftamayo Jul 27, 2022
ad2c2b6
adjusting components calling
hftamayo Jul 27, 2022
1f80928
renaming base component for buttons actions
hftamayo Jul 27, 2022
04f6038
assemble header with headeractionbutton comps
hftamayo Jul 27, 2022
1a02fe3
adding props to HeaderActionButton
hftamayo Jul 27, 2022
0543ac3
passing props from hader to headeractionbutton
hftamayo Jul 27, 2022
658bbd9
removing buttons joined in headeractionbutton
hftamayo Jul 27, 2022
39a3141
moving carticon to buttons directory
hftamayo Jul 27, 2022
513d6c5
moving carticon to buttons directory
hftamayo Jul 27, 2022
622cc27
removing unneeded login version
hftamayo Jul 28, 2022
5319a98
removing card component old version
hftamayo Jul 28, 2022
9f13867
removing unneeded button component
hftamayo Jul 28, 2022
96e0cb1
moving card component to a specific dir
hftamayo Jul 28, 2022
418f346
moving modal comp to a specific dir
hftamayo Jul 28, 2022
71e2407
renaming input to spinner component
hftamayo Jul 28, 2022
cfc7e03
minor change on spinner component
hftamayo Jul 28, 2022
d8c3444
moving header action buttons to ui dir
hftamayo Jul 28, 2022
262fdab
putting together elements for logout handler
hftamayo Jul 28, 2022
c4001f4
removing home component
hftamayo Jul 28, 2022
f9b16cf
minor changes to food component
hftamayo Jul 28, 2022
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design/scrum/step02_adding labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design/scrum/step03_epics categorized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dev/reactletsorder.ctb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"web-vitals": "^1.1.0"
},
"scripts": {
"start": "react-scripts start",
"start": "PORT=3005 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
144 changes: 96 additions & 48 deletions src/components/FoodOrder/Cart/Cart.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import React, { useContext, useState } from "react";
import Modal from "../UI/Modal";
import Modal from "../UI/Modal/Modal";
import CartItem from "./CartItem";
import classes from "./Cart.module.css";
import CartContext from "../store/cart-context";
import OrderDetails from "./OrderDetails";

const Cart = (props) => {

const userData = {
"clientName": "Marvin the Martian",
"clientId": "123"
};
/*
const pruebaData = {
"ordersDate": "26-09-2021",
"ordersStatus": "ON KITCHEN",
"ordersDelivaddress": "Comunidad El Pino",
"idPayment": "1",
"idUser": "1"
};
*/
const [isCheckout, setIsCheckout] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const [didSubmit, setDidSubmit] = useState(false);
const [isErrorOnSentOrder, setIsErrorOnSentOrder] = useState(false);
const cartCtx = useContext(CartContext);

const totalAmount = `$${cartCtx.totalAmount.toFixed(2)}`;
Expand All @@ -33,37 +20,46 @@ const Cart = (props) => {
};

const cartItemAddHandler = (item) => {
cartCtx.addItem({...item, amount: 1});
cartCtx.addItem({ ...item, amount: 1 });
};

const orderHandler = () => {
setIsCheckout(true);
};

const showCartHandler = () => {
setIsCheckout(false);
};

const errorOnSentOrderHandler = () => {
setIsErrorOnSentOrder(true);
};

const submitOrderHandler = async (userData) => {
/*
await fetch("http://localhost:8080/api/orders", {
credentials: "include",
setIsSubmitting(true);
const rawData = cartCtx.items;
const cleanData = rawData.map(({id, ...restOfTheFields}) => restOfTheFields);

const response = await fetch("http://localhost:3000/ordertemps", {
//
method: "POST",
body: JSON.stringify(pruebaData),
headers: {
'Content-Type': 'application/json',
// 'Access-Control-Allow-Origin': '*',
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0MUBmYWtlbWFpbC5jb20iLCJleHAiOjE2MzI3NTAzODYsImlhdCI6MTYzMjcxNDM4Nn0.2tvdnG9B0HdpUpV0xsOKKaATFkyuNVKMpzYE8sXBFtw',
}
*/

setIsSubmitting(true);
await fetch("https://movieserp-default-rtdb.firebaseio.com/orders.json", {
method: 'POST',
BODY: JSON.stringify({
user: userData,
orderedItems: cartCtx.items,
}),
"Content-Type": "application/json",
},
body: JSON.stringify({
ordertemp: cleanData,
}), //please include user: userData
});
setIsSubmitting(false);
setDidSubmit(true);
cartCtx.clearCart();

if (!response.ok){
errorOnSentOrderHandler();
}
else{
setIsSubmitting(false);
setIsCheckout(false);
setDidSubmit(true);
cartCtx.clearCart();
}
};

const cartItems = (
Expand All @@ -81,16 +77,46 @@ const Cart = (props) => {
</ul>
);

const modalActions = (
<div className={classes.actions}>
const cartEmptyButtons = (
<React.Fragment>
<button className={classes["button--alt"]} onClick={props.onClose}>
Close
</button>
{hasItems && (
<button className={classes.button} onClick={orderHandler}>
Order
</button>
)}
</React.Fragment>
);

const cartContentButtons = (
<React.Fragment>
<button className={classes["button--alt"]} onClick={orderHandler}>
Order's Details
</button>
<button className={classes["button--alt"]} onClick={props.onClose}>
Close
</button>
</React.Fragment>
);

const orderDetailsButtons = (
<React.Fragment>
<button className={classes["button--alt"]} onClick={submitOrderHandler}>
Confirm Order
</button>
<button className={classes["button--alt"]} onClick={showCartHandler}>
Cart's Content
</button>
<button className={classes["button--alt"]} onClick={props.onClose}>
Close
</button>
</React.Fragment>
);

const modalActions = (
<div className={classes.actions}>
{!isCheckout && hasItems
? cartContentButtons
: !isCheckout && !hasItems
? cartEmptyButtons
: orderDetailsButtons}
</div>
);

Expand All @@ -101,16 +127,36 @@ const Cart = (props) => {
<span>Total Amount</span>
<span>{totalAmount}</span>
</div>
{modalActions}
</React.Fragment>
);

const OrderDetailsModalContent = (
<React.Fragment>
{isCheckout && (
<OrderDetails onConfirm={submitOrderHandler} onCancel={props.onClose} />
<OrderDetails />
)}
{!isCheckout && modalActions}
{modalActions}
</React.Fragment>
);

const isSubmittingModalContent = <p>Sending order data...</p>;
/* incluir transaccion para verificar si es exitoso o hubo algun error */
const isSubmittingModalContent = (
<React.Fragment>
<p>Sending order data...</p>
</React.Fragment>
);

const errorOnSentOrderModalContent = (
<React.Fragment>
<p>Process failed. An error occurs sending the order!</p>
<div className={classes.actions}>
<button className={classes.button} onClick={props.onClose}>
Close
</button>
</div>
</React.Fragment>
);

const didSubmitModalContent = (
<React.Fragment>
Expand All @@ -125,8 +171,10 @@ const Cart = (props) => {

return (
<Modal onClose={props.onClose}>
{!isSubmitting && !didSubmit && CartModalContent}
{isSubmitting && isSubmittingModalContent}
{!isSubmitting && !didSubmit && !isCheckout && CartModalContent}
{isCheckout && !isSubmitting && OrderDetailsModalContent}
{isSubmitting && !isErrorOnSentOrder && !didSubmit && isSubmittingModalContent}
{isErrorOnSentOrder && errorOnSentOrderModalContent}
{!isSubmitting && didSubmit && didSubmitModalContent}
</Modal>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/FoodOrder/Cart/CartItem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import classes from './CartItem.module.css';

const CartItem = (props) => {
const price = `$${props.price.toFixed(2)}`;
//const price = `$${props.price.toFixed(2)}`;
const price = `$${parseFloat(props.price).toFixed(2)}`;

return (
<li className={classes['cart-item']}>
Expand Down
Loading