working on tip card and BS
This commit is contained in:
@@ -3,21 +3,22 @@ import WaiterRewardingIcon from "components/Icons/waiter/WaiterRewardingIcon";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet";
|
import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet";
|
||||||
|
import { updateTip } from "features/order/orderSlice";
|
||||||
|
import { useAppDispatch } from "redux/hooks";
|
||||||
|
|
||||||
interface TipBottomSheetProps {
|
interface TipBottomSheetProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
initialValue: string;
|
initialValue: string;
|
||||||
onSave: (value: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TipBottomSheet({
|
export function TipBottomSheet({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
initialValue,
|
initialValue,
|
||||||
onSave,
|
|
||||||
}: TipBottomSheetProps) {
|
}: TipBottomSheetProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
const [value, setValue] = useState(initialValue);
|
const [value, setValue] = useState(initialValue);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -25,7 +26,8 @@ export function TipBottomSheet({
|
|||||||
}, [initialValue]);
|
}, [initialValue]);
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
onSave(value);
|
const numAmount = parseFloat(value) || 0;
|
||||||
|
dispatch(updateTip(numAmount.toString()));
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -39,7 +41,6 @@ export function TipBottomSheet({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onClose={handleCancel}
|
onClose={handleCancel}
|
||||||
title={t("cart.tip")}
|
title={t("cart.tip")}
|
||||||
showCloseButton={false}
|
|
||||||
initialSnap={1}
|
initialSnap={1}
|
||||||
height={370}
|
height={370}
|
||||||
snapPoints={[370]}
|
snapPoints={[370]}
|
||||||
@@ -64,6 +65,7 @@ export function TipBottomSheet({
|
|||||||
placeholder={t("cart.amount")}
|
placeholder={t("cart.amount")}
|
||||||
autoFocus={false}
|
autoFocus={false}
|
||||||
size="large"
|
size="large"
|
||||||
|
style={{ height: 48 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -2,29 +2,27 @@ import { Button, Input, Modal } from "antd";
|
|||||||
import WaiterRewardingIcon from "components/Icons/waiter/WaiterRewardingIcon";
|
import WaiterRewardingIcon from "components/Icons/waiter/WaiterRewardingIcon";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useAppDispatch } from "redux/hooks";
|
||||||
|
import { updateTip } from "features/order/orderSlice";
|
||||||
|
|
||||||
interface TipDialogProps {
|
interface TipDialogProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
initialValue: string;
|
initialValue: string;
|
||||||
onSave: (value: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TipDialog({
|
export function TipDialog({ isOpen, onClose, initialValue }: TipDialogProps) {
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
initialValue,
|
|
||||||
onSave,
|
|
||||||
}: TipDialogProps) {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [value, setValue] = useState(initialValue);
|
const [value, setValue] = useState(initialValue);
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setValue(initialValue);
|
setValue(initialValue);
|
||||||
}, [initialValue]);
|
}, [initialValue]);
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
onSave(value);
|
const numAmount = parseFloat(value) || 0;
|
||||||
|
dispatch(updateTip(numAmount.toString()));
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { Button, Form } from "antd";
|
import { Button, Form } from "antd";
|
||||||
import { ProBottomSheet } from "components/ProBottomSheet/ProBottomSheet.tsx";
|
import { ProBottomSheet } from "components/ProBottomSheet/ProBottomSheet.tsx";
|
||||||
import { useState, useEffect } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import {
|
import { selectCart, updateGiftDetails } from "features/order/orderSlice";
|
||||||
selectCart,
|
|
||||||
selectGrandTotal,
|
|
||||||
updateGiftDetails,
|
|
||||||
updateSplitBillAmount,
|
|
||||||
} from "features/order/orderSlice";
|
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import ProText from "components/ProText";
|
import ProText from "components/ProText";
|
||||||
import { ProInputNumber } from "components/Inputs/ProInputNumber";
|
import { ProInputNumber } from "components/Inputs/ProInputNumber";
|
||||||
|
|||||||
@@ -602,12 +602,16 @@
|
|||||||
top: 1px;
|
top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editIcon {
|
.editIconOnSide {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -7px;
|
top: -7px;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editIconMiddle {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
:global(.ant-app-rtl) .editIcon {
|
:global(.ant-app-rtl) .editIcon {
|
||||||
right: auto;
|
right: auto;
|
||||||
left: 5px;
|
left: 5px;
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import { TipDialog } from "components/CustomBottomSheet/TipDialog.tsx";
|
|||||||
import DonateHandIcon from "components/Icons/cart/DonateHandIcon.tsx";
|
import DonateHandIcon from "components/Icons/cart/DonateHandIcon.tsx";
|
||||||
import EditIcon from "components/Icons/EditIcon.tsx";
|
import EditIcon from "components/Icons/EditIcon.tsx";
|
||||||
import ProText from "components/ProText.tsx";
|
import ProText from "components/ProText.tsx";
|
||||||
import ProTitle from "components/ProTitle.tsx";
|
|
||||||
import { selectCart, updateTip } from "features/order/orderSlice.ts";
|
import { selectCart, updateTip } from "features/order/orderSlice.ts";
|
||||||
import useBreakPoint from "hooks/useBreakPoint.ts";
|
import useBreakPoint from "hooks/useBreakPoint.ts";
|
||||||
import styles from "pages/cart/cart.module.css";
|
import styles from "pages/cart/cart.module.css";
|
||||||
import { useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks.ts";
|
import { useAppDispatch, useAppSelector } from "redux/hooks.ts";
|
||||||
|
|
||||||
@@ -18,12 +17,18 @@ export default function RewardWaiterCard() {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { tip } = useAppSelector(selectCart);
|
const { tip } = useAppSelector(selectCart);
|
||||||
const { isDesktop } = useBreakPoint();
|
const { isDesktop } = useBreakPoint();
|
||||||
|
const [selectedTip, setSelectedTip] = useState<number | null>(null);
|
||||||
|
|
||||||
const [isTipOpen, setIsTipOpen] = useState(false);
|
const [isTipOpen, setIsTipOpen] = useState(false);
|
||||||
|
|
||||||
const handleTipSave = (value: string) => {
|
const isDefaultTip = useMemo(() => {
|
||||||
dispatch(updateTip(value));
|
const amount = parseFloat(tip);
|
||||||
message.success(t("cart.tip") + " " + t("updatedSuccessfully"));
|
return amount === 0.5 || amount === 1.0 || amount === 3.0;
|
||||||
|
}, [tip]);
|
||||||
|
|
||||||
|
const handleTipClick = (value: number) => {
|
||||||
|
setSelectedTip(value);
|
||||||
|
dispatch(updateTip(value.toString()));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTipClose = () => {
|
const handleTipClose = () => {
|
||||||
@@ -86,9 +91,9 @@ export default function RewardWaiterCard() {
|
|||||||
<Divider style={{ margin: "15px 0 15px 0" }} />
|
<Divider style={{ margin: "15px 0 15px 0" }} />
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "grid",
|
||||||
flexDirection: "row",
|
gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
|
||||||
justifyContent: "space-around",
|
gap: 16,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
@@ -96,8 +101,11 @@ export default function RewardWaiterCard() {
|
|||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
height: 32,
|
height: 32,
|
||||||
border: "none",
|
border: "none",
|
||||||
backgroundColor: "#5F6C7B0D",
|
backgroundColor:
|
||||||
|
selectedTip === 0.5 && isDefaultTip ? "#FFB7001F" : "#5F6C7B0D",
|
||||||
}}
|
}}
|
||||||
|
iconPlacement="end"
|
||||||
|
onClick={() => handleTipClick(0.5)}
|
||||||
>
|
>
|
||||||
<ArabicPrice
|
<ArabicPrice
|
||||||
price={0.5}
|
price={0.5}
|
||||||
@@ -108,7 +116,8 @@ export default function RewardWaiterCard() {
|
|||||||
lineHeight: "140%",
|
lineHeight: "140%",
|
||||||
letterSpacing: "0%",
|
letterSpacing: "0%",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
color: "#5F6C7B",
|
color:
|
||||||
|
selectedTip === 0.5 && isDefaultTip ? "#CC9300" : "#5F6C7B",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -117,8 +126,10 @@ export default function RewardWaiterCard() {
|
|||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
height: 32,
|
height: 32,
|
||||||
border: "none",
|
border: "none",
|
||||||
backgroundColor: "#5F6C7B0D",
|
backgroundColor:
|
||||||
|
selectedTip === 1 && isDefaultTip ? "#FFB7001F" : "#5F6C7B0D",
|
||||||
}}
|
}}
|
||||||
|
onClick={() => handleTipClick(1)}
|
||||||
>
|
>
|
||||||
<ArabicPrice
|
<ArabicPrice
|
||||||
price={1.0}
|
price={1.0}
|
||||||
@@ -129,7 +140,8 @@ export default function RewardWaiterCard() {
|
|||||||
lineHeight: "140%",
|
lineHeight: "140%",
|
||||||
letterSpacing: "0%",
|
letterSpacing: "0%",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
color: "#5F6C7B",
|
color:
|
||||||
|
selectedTip === 1 && isDefaultTip ? "#CC9300" : "#5F6C7B",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -137,24 +149,31 @@ export default function RewardWaiterCard() {
|
|||||||
style={{
|
style={{
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
height: 32,
|
height: 32,
|
||||||
border: "none",
|
backgroundColor: tip && !isDefaultTip ? "#FFB7001F" : "inherit",
|
||||||
backgroundColor: "#FFB7001F",
|
border: tip && !isDefaultTip ? "none" : "1px solid #C0BFC4",
|
||||||
}}
|
}}
|
||||||
icon={<EditIcon className={styles.editIcon} />}
|
icon={
|
||||||
iconPlacement="end"
|
<EditIcon
|
||||||
|
className={styles.editIcon}
|
||||||
|
color={tip && !isDefaultTip ? "#CC9300" : "#3D3B4A"}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
iconPlacement="start"
|
||||||
|
onClick={() => setIsTipOpen(true)}
|
||||||
>
|
>
|
||||||
<ArabicPrice
|
<ProText
|
||||||
price={3.0}
|
style={{
|
||||||
textStyle={{
|
color: tip && !isDefaultTip ? "#CC9300" : "#FFB700",
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
fontStyle: "Medium",
|
fontStyle: "Medium",
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
lineHeight: "140%",
|
lineHeight: "140%",
|
||||||
letterSpacing: "0%",
|
letterSpacing: "0%",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
color: "#CC9300",
|
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
{tip && !isDefaultTip ? tip : t("cart.other")}
|
||||||
|
</ProText>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -163,14 +182,12 @@ export default function RewardWaiterCard() {
|
|||||||
isOpen={isTipOpen}
|
isOpen={isTipOpen}
|
||||||
onClose={handleTipClose}
|
onClose={handleTipClose}
|
||||||
initialValue={tip}
|
initialValue={tip}
|
||||||
onSave={handleTipSave}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TipBottomSheet
|
<TipBottomSheet
|
||||||
isOpen={isTipOpen}
|
isOpen={isTipOpen}
|
||||||
onClose={handleTipClose}
|
onClose={handleTipClose}
|
||||||
initialValue={tip}
|
initialValue={tip}
|
||||||
onSave={handleTipSave}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user