add plateCar

This commit is contained in:
2025-11-12 23:34:09 +03:00
parent c1f2f1a6a6
commit df43d46ed2
3 changed files with 26 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ interface CartState {
loyaltyValidationError: string | null; loyaltyValidationError: string | null;
scheduledDate: string; scheduledDate: string;
discount: DiscountData; discount: DiscountData;
plateCar: string;
} }
// localStorage keys // localStorage keys
@@ -89,6 +90,7 @@ export const CART_STORAGE_KEYS = {
RESTAURANT: "fascano_restaurant", RESTAURANT: "fascano_restaurant",
SCHEDULED_DATE: "fascano_scheduled_date", SCHEDULED_DATE: "fascano_scheduled_date",
DISCOUNT: "fascano_discount", DISCOUNT: "fascano_discount",
PLATE: "fascano_plate_car",
} as const; } as const;
// Utility functions for localStorage // Utility functions for localStorage
@@ -170,6 +172,7 @@ const initialState: CartState = {
isGift: false, isGift: false,
isDiscount: false, isDiscount: false,
}), }),
plateCar: getFromLocalStorage(CART_STORAGE_KEYS.PLATE, ""),
}; };
const orderSlice = createSlice({ 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>) { updateOrderType(state, action: PayloadAction<OrderType>) {
state.orderType = action.payload; state.orderType = action.payload;
@@ -598,6 +611,7 @@ export const {
updateCollectionMethod, updateCollectionMethod,
updatePhone, updatePhone,
updatePaymentMethod, updatePaymentMethod,
updatePlateCar,
updateOrderType, updateOrderType,
updateUseLoyaltyPoints, updateUseLoyaltyPoints,
validateLoyaltyPoints, validateLoyaltyPoints,

View File

@@ -1,9 +1,14 @@
import { Form, Input } from "antd"; import { Form, Input } from "antd";
import ProInputCard from "components/ProInputCard/ProInputCard.tsx"; import ProInputCard from "components/ProInputCard/ProInputCard.tsx";
import { updatePlateCar } from "features/order/orderSlice";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAppDispatch, useAppSelector } from "redux/hooks";
export default function CarPlateCard() { export default function CarPlateCard() {
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useAppDispatch()
const {plateCar} = useAppSelector(state => state.order)
return ( return (
<> <>
<ProInputCard <ProInputCard
@@ -16,6 +21,10 @@ export default function CarPlateCard() {
size="large" size="large"
autoFocus={false} autoFocus={false}
style={{ padding: "7px 11px", height: 50, borderRadius: 888 }} style={{ padding: "7px 11px", height: 50, borderRadius: 888 }}
value={plateCar}
onChange={(e) => {
dispatch(updatePlateCar(e.target.value));
}}
/> />
</Form.Item> </Form.Item>
</ProInputCard> </ProInputCard>

View File

@@ -36,6 +36,7 @@ export default function useOrder() {
giftDetails, giftDetails,
location, location,
discount, discount,
plateCar,
} = useAppSelector(selectCart); } = useAppSelector(selectCart);
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem); const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
const { useLoyaltyPoints } = useAppSelector(selectCart); const { useLoyaltyPoints } = useAppSelector(selectCart);
@@ -83,6 +84,7 @@ export default function useOrder() {
uuid: user_uuid, uuid: user_uuid,
pickup_comments: "", pickup_comments: "",
pickup_time: estimateTime, pickup_time: estimateTime,
car_plate: plateCar,
delivery_pickup_interval: "", delivery_pickup_interval: "",
orderPrice: orderPrice, orderPrice: orderPrice,
use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0, use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0,