-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web-app: Separating checkout components and adding checkout completed…
… page
- Loading branch information
Showing
24 changed files
with
316 additions
and
214 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
155 changes: 0 additions & 155 deletions
155
src/backend/web/web.client/web-app-new/src/app/checkout/checkout.tsx
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
src/backend/web/web.client/web-app-new/src/app/checkout/complete/page.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { CheckCircleIcon } from '@heroicons/react/24/solid'; | ||
|
||
const OrderCompletionPage: React.FC = () => { | ||
// Replace with your actual data | ||
const orderDetails = { | ||
address: '24 Lexington Drive, Bella Vista, NSW 22353', | ||
deliveryTime: 'Ready at 2:20 PM 03 March 2020', | ||
orderNumber: 45, | ||
orderTotal: '$33.89', | ||
paymentMethod: 'Master Card ending **** 0987', | ||
estimatedDeliveryTime: '11:53 AM', | ||
email: '[email protected]', | ||
helpNumber: '+02 9629 4884', | ||
}; | ||
|
||
return ( | ||
<div className="max-w-md mx-auto bg-white p-6 shadow-lg rounded-lg"> | ||
<div className="text-center"> | ||
<CheckCircleIcon className="h-12 w-12 text-green-500 mx-auto" /> | ||
<h2 className="text-lg font-semibold my-2">Order Submitted</h2> | ||
<p className="text-gray-600">{orderDetails.orderTotal} Paid with {orderDetails.paymentMethod}</p> | ||
<button className="bg-orange-500 text-white px-4 py-2 rounded my-4">Track order</button> | ||
</div> | ||
<div className="my-4"> | ||
<h3 className="font-bold">Delivery Address</h3> | ||
<p>{orderDetails.address}</p> | ||
<p>{orderDetails.deliveryTime}</p> | ||
</div> | ||
<div className="my-4"> | ||
<h3 className="font-bold">Order Number</h3> | ||
<p>#{orderDetails.orderNumber}</p> | ||
<p>Estimated Delivery Time: {orderDetails.estimatedDeliveryTime}</p> | ||
</div> | ||
<div className="my-4"> | ||
<p>An email confirmation will be sent to {orderDetails.email}</p> | ||
</div> | ||
<div className="my-4"> | ||
<p>Need help with anything?</p> | ||
<p>Call {orderDetails.helpNumber}</p> | ||
</div> | ||
<button className="w-full bg-gray-200 text-gray-800 px-4 py-2 rounded my-4">Start a new order</button> | ||
</div> | ||
); | ||
}; | ||
|
||
|
||
export default OrderCompletionPage;; |
17 changes: 13 additions & 4 deletions
17
src/backend/web/web.client/web-app-new/src/app/checkout/page.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,20 +1,29 @@ | ||
'use server'; | ||
|
||
import { CheckoutComponent } from './checkout'; | ||
import { getServerSession } from 'next-auth'; | ||
import { redirect } from 'next/navigation'; | ||
import { authOptions } from '@/lib/auth'; | ||
import { headers } from 'next/headers'; | ||
import { CheckoutForm } from '@/components/checkout/checkout-form'; | ||
|
||
const Page = async () => { | ||
const session = await getServerSession(authOptions); | ||
if (!session?.user) { | ||
const headersList = headers(); | ||
const callbackUrl = headersList.get('referer') || ''; //after sign redirect into checkout page again | ||
const host = headers().get('x-forwarded-host'); | ||
const protocol = headers().get('x-forwarded-proto') || 'http'; | ||
const callbackUrl = `${protocol}://${host}/checkout`; | ||
|
||
const urlParam = new URLSearchParams({ callbackUrl }); | ||
return redirect(`api/auth/signin/web-app?${urlParam}`); | ||
} | ||
return <CheckoutComponent />; | ||
return ( | ||
<div className="container mx-auto p-6"> | ||
<h1 className="mb-6 text-3xl font-bold">Checkout</h1> | ||
<div className="rounded-lg bg-white p-6 shadow-lg"> | ||
<CheckoutForm /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Page; |
2 changes: 1 addition & 1 deletion
2
src/backend/web/web.client/web-app-new/src/app/foods/[category]/page.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
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
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
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
2 changes: 1 addition & 1 deletion
2
src/backend/web/web.client/web-app-new/src/components/cart/add-to-cart.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
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
9 changes: 9 additions & 0 deletions
9
src/backend/web/web.client/web-app-new/src/components/checkout/actions.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { authOptions } from '@/lib/auth'; | ||
import { getServerSession } from 'next-auth'; | ||
|
||
export async function checkoutServer() { | ||
const session = await getServerSession(authOptions); | ||
if (!session?.user) { | ||
throw new Error('User is not authenticated'); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/backend/web/web.client/web-app-new/src/components/checkout/checkout-form.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use client'; | ||
import { PaymentDetails } from '@/components/checkout/payment-details'; | ||
import { ShippingAddressDetails } from '@/components/checkout/shipping-address-details'; | ||
import React, { useState } from 'react'; | ||
|
||
export const CheckoutForm: React.FC = () => { | ||
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: '' | ||
}); | ||
|
||
console.log(setFormData); | ||
|
||
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
// setFormData({ ...formData, [e.target.name]: e.target.value }); | ||
// }; | ||
|
||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
// TODO: Implement the checkout functionality here | ||
console.log(formData); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={handleSubmit} className="mx-auto max-w-lg"> | ||
<PaymentDetails /> | ||
<ShippingAddressDetails /> | ||
<button | ||
type="submit" | ||
className="rounded w-full bg-orange-500 px-4 py-2 font-bold text-white hover:bg-orange-600" | ||
> | ||
Complete | ||
</button> | ||
</form> | ||
); | ||
}; |
Oops, something went wrong.