-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nextjs-web-app: Adding session hook and login-logout functionality
- Right side bar for sorting
- Loading branch information
Showing
11 changed files
with
256 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237 changes: 154 additions & 83 deletions
237
src/backend/web/web.client/web-app-new/src/app/checkout/checkout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,161 @@ | ||
'use client' | ||
import React, { useState } from 'react'; | ||
"use client"; | ||
import React, { useState } from "react"; | ||
|
||
export const CheckoutComponent: React.FC = () => { | ||
const [formData, setFormData] = useState({ | ||
fullName: '', | ||
email: '', | ||
address: '', | ||
city: '', | ||
zip: '', | ||
country: '', | ||
cardNumber: '', | ||
cardExpiration: '', | ||
cardCVC: '', | ||
}); | ||
const [formData, setFormData] = useState({ | ||
fullName: "", | ||
email: "", | ||
street_address: "", | ||
city: "", | ||
state: "", | ||
zip_code: "", | ||
country: "", | ||
credit_card_number: "", | ||
credit_card_expiration_month: "", | ||
credit_card_expiration_year: "", | ||
credit_card_cvv: "", | ||
}); | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setFormData({ ...formData, [e.target.name]: e.target.value }); | ||
}; | ||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setFormData({ ...formData, [e.target.name]: e.target.value }); | ||
}; | ||
|
||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
// TODO: checkout | ||
console.log(formData); | ||
}; | ||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
// TODO: Implement the checkout functionality here | ||
console.log(formData); | ||
}; | ||
|
||
return ( | ||
<div className="container mx-auto p-6"> | ||
<h1 className="text-3xl font-bold mb-6">Checkout</h1> | ||
<form onSubmit={handleSubmit} className="max-w-lg mx-auto"> | ||
{/* Full Name */} | ||
<div className="mb-4"> | ||
<label htmlFor="fullName" className="block mb-2">Full Name</label> | ||
<input | ||
type="text" | ||
name="fullName" | ||
id="fullName" | ||
value={formData.fullName} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
{/* ... other input fields */} | ||
{/* Card Details */} | ||
<div className="mb-4"> | ||
<label htmlFor="cardNumber" className="block mb-2">Card Number</label> | ||
<input | ||
type="text" | ||
name="cardNumber" | ||
id="cardNumber" | ||
value={formData.cardNumber} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
<div className="flex gap-4 mb-4"> | ||
<div className="flex-1"> | ||
<label htmlFor="cardExpiration" className="block mb-2">Expiration</label> | ||
<input | ||
type="text" | ||
name="cardExpiration" | ||
id="cardExpiration" | ||
value={formData.cardExpiration} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
<div className="flex-1"> | ||
<label htmlFor="cardCVC" className="block mb-2">CVC</label> | ||
<input | ||
type="text" | ||
name="cardCVC" | ||
id="cardCVC" | ||
value={formData.cardCVC} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
</div> | ||
<button type="submit" className="bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded"> | ||
Complete Order | ||
</button> | ||
</form> | ||
return ( | ||
<div className="container mx-auto p-6"> | ||
<h1 className="text-3xl font-bold mb-6">Checkout</h1> | ||
<form onSubmit={handleSubmit} className="max-w-lg mx-auto"> | ||
{/* Customer Information */} | ||
<div className="mb-4"> | ||
<label htmlFor="fullName" className="block mb-2"> | ||
Full Name | ||
</label> | ||
<input | ||
type="text" | ||
name="fullName" | ||
id="fullName" | ||
value={formData.fullName} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
); | ||
<div className="mb-4"> | ||
<label htmlFor="email" className="block mb-2"> | ||
</label> | ||
<input | ||
type="email" | ||
name="email" | ||
id="email" | ||
value={formData.email} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
|
||
{/* Address Details */} | ||
<fieldset className="mb-4"> | ||
<legend className="text-xl font-semibold mb-4">Address</legend> | ||
<div className="mb-4"> | ||
<label htmlFor="street_address" className="block mb-2"> | ||
Street Address | ||
</label> | ||
<input | ||
type="text" | ||
name="street_address" | ||
id="street_address" | ||
value={formData.street_address} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
{/* ... other address fields such as city, state, zip_code, and country */} | ||
</fieldset> | ||
|
||
{/* Credit Card Details */} | ||
<fieldset> | ||
<legend className="text-xl font-semibold mb-4">Credit Card</legend> | ||
<div className="mb-4"> | ||
<label htmlFor="credit_card_number" className="block mb-2"> | ||
Card Number | ||
</label> | ||
<input | ||
type="text" | ||
name="credit_card_number" | ||
id="credit_card_number" | ||
value={formData.credit_card_number} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
<div className="flex gap-4 mb-4"> | ||
<div className="flex-1"> | ||
<label | ||
htmlFor="credit_card_expiration_month" | ||
className="block mb-2" | ||
> | ||
Expiration Month | ||
</label> | ||
<input | ||
type="text" | ||
name="credit_card_expiration_month" | ||
id="credit_card_expiration_month" | ||
value={formData.credit_card_expiration_month} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
<div className="flex-1"> | ||
<label | ||
htmlFor="credit_card_expiration_year" | ||
className="block mb-2" | ||
> | ||
Expiration Year | ||
</label> | ||
<input | ||
type="text" | ||
name="credit_card_expiration_year" | ||
id="credit_card_expiration_year" | ||
value={formData.credit_card_expiration_year} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
<div className="flex-1"> | ||
<label htmlFor="credit_card_cvv" className="block mb-2"> | ||
CVV | ||
</label> | ||
<input | ||
type="text" | ||
name="credit_card_cvv" | ||
id="credit_card_cvv" | ||
value={formData.credit_card_cvv} | ||
onChange={handleChange} | ||
className="w-full p-2 border border-gray-300 rounded" | ||
required | ||
/> | ||
</div> | ||
</div> | ||
</fieldset> | ||
|
||
<button | ||
type="submit" | ||
className="bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded" | ||
> | ||
Complete | ||
</button> | ||
</form> | ||
</div> | ||
); | ||
}; |
12 changes: 8 additions & 4 deletions
12
src/backend/web/web.client/web-app-new/src/app/foods/foods.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import CategoriesSidebar from "@/components/CategoriesSidebar"; | ||
import FoodItem from "@/components/FoodItem"; | ||
import { FoodItems } from "./fetch"; | ||
import RightSidebar from "@/components/RightSidebar"; | ||
|
||
export const FoodsPage = ({foodItems}: {foodItems: FoodItems}) => { | ||
export const FoodsPage = ({ foodItems }: { foodItems: FoodItems }) => { | ||
return ( | ||
<div className="flex flex-1 min-h-screen"> | ||
<CategoriesSidebar /> | ||
<div className="container mx-auto"> | ||
<div className="mx-auto flex max-w-screen-2xl flex-col gap-8 px-4 pb-4 md:flex-row"> | ||
<div className="order-first w-full flex-none md:max-w-[125px]"> | ||
<CategoriesSidebar /> | ||
</div> | ||
<div className="order-last min-h-screen w-full md:order-none"> | ||
<div className="flex flex-wrap justify-center"> | ||
{foodItems.map((item) => ( | ||
<FoodItem key={item.id} {...item} /> | ||
))} | ||
</div> | ||
</div> | ||
<RightSidebar /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
"use client"; | ||
import { CartProvider } from "@/context/CartContext"; | ||
import { PropsWithChildren } from "react"; | ||
import { ThemeProvider } from "next-themes"; | ||
import { SessionProvider } from "next-auth/react"; | ||
|
||
export const Providers = ({ children }: PropsWithChildren<{}>) => { | ||
return ( | ||
<SessionProvider> | ||
<CartProvider>{children}</CartProvider> | ||
</SessionProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.