Compare commits
5 Commits
2c676eb153
...
d0de05cfb0
| Author | SHA1 | Date | |
|---|---|---|---|
| d0de05cfb0 | |||
| 8a4e6691d4 | |||
| adc98200cb | |||
| 26a16fa8d7 | |||
| 093d4279d9 |
@@ -17,10 +17,10 @@ const NoteIcon = ({ className, onClick }: NoteIconType) => {
|
||||
<path
|
||||
d="M12 16H12.008M12 8V13M3.23005 7.913L7.91005 3.23C8.06005 3.08 8.26005 3 8.48005 3H15.53C15.74 3 15.95 3.08 16.1 3.23L20.77 7.903C20.92 8.053 21 8.253 21 8.473V15.527C21 15.737 20.92 15.947 20.77 16.097L16.1 20.77C15.95 20.92 15.75 21 15.53 21H8.47005C8.36456 21.0011 8.2599 20.9814 8.16208 20.9419C8.06425 20.9025 7.9752 20.844 7.90005 20.77L3.23005 16.097C3.15602 16.0218 3.09759 15.9328 3.05812 15.835C3.01865 15.7371 2.99891 15.6325 3.00005 15.527V8.473C3.00005 8.263 3.08005 8.053 3.23005 7.903V7.913Z"
|
||||
stroke="#3D3B4A"
|
||||
stroke-width="1.5"
|
||||
stroke-miterlimit="10"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
strokeWidth="1.5"
|
||||
strokeMiterlimit="10"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
22
src/components/publicRoute/PublicRoute.tsx
Normal file
22
src/components/publicRoute/PublicRoute.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Loader } from "components/Loader/Loader";
|
||||
import { Navigate, useParams } from "react-router-dom";
|
||||
import { useAppSelector } from "redux/hooks";
|
||||
|
||||
export const PublicRoute = ({
|
||||
children,
|
||||
}: {
|
||||
children: JSX.Element;
|
||||
}) => {
|
||||
const { token, loading } = useAppSelector((state) => state.auth);
|
||||
const { subdomain } = useParams();
|
||||
|
||||
if (loading) {
|
||||
return <Loader />;
|
||||
}
|
||||
|
||||
if (token) {
|
||||
return <Navigate to={`/${subdomain}`} replace />;
|
||||
}
|
||||
|
||||
return children;
|
||||
};
|
||||
@@ -702,7 +702,7 @@ const orderSlice = createSlice({
|
||||
}
|
||||
},
|
||||
updateOrder(state, action: PayloadAction<any>) {
|
||||
state.order = action.payload;
|
||||
state.order = { ...state.order, ...action.payload };
|
||||
if (typeof window !== "undefined") {
|
||||
localStorage.setItem(
|
||||
CART_STORAGE_KEYS.ORDER,
|
||||
|
||||
@@ -54,6 +54,8 @@ export default function useOrder() {
|
||||
|
||||
const [createOrder] = useCreateOrderMutation();
|
||||
|
||||
console.log(order);
|
||||
|
||||
const getDeliveryMethod = useCallback(() => {
|
||||
if (orderType === OrderType.Delivery) return 1;
|
||||
if (orderType === OrderType.Pickup) return 2;
|
||||
@@ -93,8 +95,8 @@ export default function useOrder() {
|
||||
order_item_comment: i.comment || "",
|
||||
variant: (i.variant as Variant)?.id || "",
|
||||
})),
|
||||
office_no: order?.officeNumber || "",
|
||||
room_no: order?.roomNumber || "",
|
||||
office_no: order?.officeNumber,
|
||||
room_no: order?.roomNumber,
|
||||
...(discount.isDiscount ? { couponID: coupon } : {}),
|
||||
...(discount.isGift ? { discountGiftCode: coupon } : {}),
|
||||
discountAmount: discountAmount || 0,
|
||||
|
||||
@@ -35,7 +35,15 @@ export default function CheckoutPage() {
|
||||
} = useAppSelector(selectCart);
|
||||
const { token } = useAppSelector((state) => state.auth);
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({ coupon, collectionMethod, phone, customerName, tip });
|
||||
form.setFieldsValue({
|
||||
coupon,
|
||||
collectionMethod,
|
||||
phone,
|
||||
customerName,
|
||||
tip,
|
||||
officeNumber: order?.officeNumber,
|
||||
roomNumber: order?.roomNumber,
|
||||
});
|
||||
}, [form, phone, coupon, collectionMethod, customerName, tip]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function Extra({
|
||||
}}
|
||||
>
|
||||
<ProText style={{ fontSize: "1.25rem" }}>
|
||||
{t("menu.youMightAlsoLike")}
|
||||
{t("menu.choose1")}
|
||||
</ProText>
|
||||
|
||||
<ProText strong style={{ fontSize: "0.75rem" }}>
|
||||
@@ -40,10 +40,6 @@ export default function Extra({
|
||||
</ProText>
|
||||
</div>
|
||||
|
||||
<ProText strong style={{ fontSize: "0.75rem" }}>
|
||||
{t("menu.choose1")}
|
||||
</ProText>
|
||||
|
||||
<div className={styles.productContainer}>
|
||||
<ProCheckboxGroups
|
||||
options={extrasList.map((value) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Grid } from "antd";
|
||||
import { Loader } from "components/Loader/Loader";
|
||||
import { PrivateRoute } from "components/privateRoute/PrivateRoute";
|
||||
import { PublicRoute } from "components/publicRoute/PublicRoute";
|
||||
import { AppLayout } from "layouts";
|
||||
import HeaderMenuDrawer from "layouts/app/HeaderMenuDrawer";
|
||||
import AddressPage from "pages/address/page";
|
||||
@@ -132,13 +133,29 @@ export const router = createHashRouter([
|
||||
},
|
||||
{
|
||||
path: "login",
|
||||
element: <PageWrapper children={<LoginPage />} />,
|
||||
element: (
|
||||
<PageWrapper
|
||||
children={
|
||||
<PublicRoute>
|
||||
<LoginPage />
|
||||
</PublicRoute>
|
||||
}
|
||||
/>
|
||||
),
|
||||
errorElement: <ErrorPage />,
|
||||
},
|
||||
|
||||
{
|
||||
path: "otp",
|
||||
element: <PageWrapper children={<OtpPage />} />,
|
||||
element: (
|
||||
<PageWrapper
|
||||
children={
|
||||
<PublicRoute>
|
||||
<OtpPage />
|
||||
</PublicRoute>
|
||||
}
|
||||
/>
|
||||
),
|
||||
errorElement: <ErrorPage />,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user