add plateCar
This commit is contained in:
@@ -64,6 +64,7 @@ interface CartState {
|
||||
loyaltyValidationError: string | null;
|
||||
scheduledDate: string;
|
||||
discount: DiscountData;
|
||||
plateCar: string;
|
||||
}
|
||||
|
||||
// localStorage keys
|
||||
@@ -89,7 +90,8 @@ export const CART_STORAGE_KEYS = {
|
||||
RESTAURANT: "fascano_restaurant",
|
||||
SCHEDULED_DATE: "fascano_scheduled_date",
|
||||
DISCOUNT: "fascano_discount",
|
||||
} as const;
|
||||
PLATE: "fascano_plate_car",
|
||||
} as const;
|
||||
|
||||
// Utility functions for localStorage
|
||||
const getFromLocalStorage = <T>(key: string, defaultValue: T): T => {
|
||||
@@ -170,6 +172,7 @@ const initialState: CartState = {
|
||||
isGift: false,
|
||||
isDiscount: false,
|
||||
}),
|
||||
plateCar: getFromLocalStorage(CART_STORAGE_KEYS.PLATE, ""),
|
||||
};
|
||||
|
||||
const orderSlice = createSlice({
|
||||
@@ -483,6 +486,16 @@ const orderSlice = createSlice({
|
||||
);
|
||||
}
|
||||
},
|
||||
updatePlateCar(state, action: PayloadAction<string>) {
|
||||
state.plateCar = action.payload;
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
localStorage.setItem(
|
||||
CART_STORAGE_KEYS.PLATE,
|
||||
JSON.stringify(state.plateCar),
|
||||
);
|
||||
}
|
||||
},
|
||||
updateOrderType(state, action: PayloadAction<OrderType>) {
|
||||
state.orderType = action.payload;
|
||||
|
||||
@@ -598,6 +611,7 @@ export const {
|
||||
updateCollectionMethod,
|
||||
updatePhone,
|
||||
updatePaymentMethod,
|
||||
updatePlateCar,
|
||||
updateOrderType,
|
||||
updateUseLoyaltyPoints,
|
||||
validateLoyaltyPoints,
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import { Form, Input } from "antd";
|
||||
import ProInputCard from "components/ProInputCard/ProInputCard.tsx";
|
||||
import { updatePlateCar } from "features/order/orderSlice";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||
|
||||
export default function CarPlateCard() {
|
||||
const { t } = useTranslation();
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
const {plateCar} = useAppSelector(state => state.order)
|
||||
return (
|
||||
<>
|
||||
<ProInputCard
|
||||
@@ -16,6 +21,10 @@ export default function CarPlateCard() {
|
||||
size="large"
|
||||
autoFocus={false}
|
||||
style={{ padding: "7px 11px", height: 50, borderRadius: 888 }}
|
||||
value={plateCar}
|
||||
onChange={(e) => {
|
||||
dispatch(updatePlateCar(e.target.value));
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
</ProInputCard>
|
||||
|
||||
@@ -36,6 +36,7 @@ export default function useOrder() {
|
||||
giftDetails,
|
||||
location,
|
||||
discount,
|
||||
plateCar,
|
||||
} = useAppSelector(selectCart);
|
||||
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
|
||||
const { useLoyaltyPoints } = useAppSelector(selectCart);
|
||||
@@ -83,6 +84,7 @@ export default function useOrder() {
|
||||
uuid: user_uuid,
|
||||
pickup_comments: "",
|
||||
pickup_time: estimateTime,
|
||||
car_plate: plateCar,
|
||||
delivery_pickup_interval: "",
|
||||
orderPrice: orderPrice,
|
||||
use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0,
|
||||
|
||||
Reference in New Issue
Block a user