CustomAmountChoiceBottomSheet: update UI
This commit is contained in:
@@ -425,7 +425,11 @@
|
|||||||
"yourAmount": "مبلغك",
|
"yourAmount": "مبلغك",
|
||||||
"selectedTotal": "المجموع المحدد",
|
"selectedTotal": "المجموع المحدد",
|
||||||
"splitBillAmount": "مبلغ تقسيم الفاتورة",
|
"splitBillAmount": "مبلغ تقسيم الفاتورة",
|
||||||
"removeSplitWay": "إزالة طريقة التقسيم",
|
"removeSplit": "إزالة التقسيم",
|
||||||
"amount": "المبلغ"
|
"amount": "المبلغ",
|
||||||
|
"howMuchWouldYouLikeToPay": "كم مبلغ تريد دفعه؟",
|
||||||
|
"confirm": "تأكيد",
|
||||||
|
"totalBill": "الفاتورة الكلية",
|
||||||
|
"remainingToPay": "المبلغ المتبقي"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,7 +437,11 @@
|
|||||||
"yourAmount": "Your Amount",
|
"yourAmount": "Your Amount",
|
||||||
"selectedTotal": "Selected Total",
|
"selectedTotal": "Selected Total",
|
||||||
"splitBillAmount": "Split Bill Amount",
|
"splitBillAmount": "Split Bill Amount",
|
||||||
"removeSplitWay": "Remove Split Way",
|
"removeSplit": "Remove Split",
|
||||||
"amount": "Amount"
|
"amount": "Amount",
|
||||||
|
"howMuchWouldYouLikeToPay": "How much would you like to pay?",
|
||||||
|
"confirm": "Confirm",
|
||||||
|
"totalBill": "Total Bill",
|
||||||
|
"remainingToPay": "Remaining to Pay"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ interface ProBottomSheetProps {
|
|||||||
initialSnap?: number;
|
initialSnap?: number;
|
||||||
className?: string;
|
className?: string;
|
||||||
themeName?: "light" | "dark";
|
themeName?: "light" | "dark";
|
||||||
|
contentStyle?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ProBottomSheet({
|
export function ProBottomSheet({
|
||||||
@@ -30,6 +31,7 @@ export function ProBottomSheet({
|
|||||||
snapPoints = [500],
|
snapPoints = [500],
|
||||||
initialSnap = 0,
|
initialSnap = 0,
|
||||||
className = "",
|
className = "",
|
||||||
|
contentStyle = {},
|
||||||
}: ProBottomSheetProps) {
|
}: ProBottomSheetProps) {
|
||||||
const [currentSnap, setCurrentSnap] = useState(initialSnap);
|
const [currentSnap, setCurrentSnap] = useState(initialSnap);
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
@@ -231,12 +233,13 @@ export function ProBottomSheet({
|
|||||||
backdropFilter: themeName === "dark" ? "blur(8px)" : "none",
|
backdropFilter: themeName === "dark" ? "blur(8px)" : "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
const contentStyle: React.CSSProperties = {
|
const contentWrapperStyle: React.CSSProperties = {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
padding: "0 20px",
|
padding: "0 20px",
|
||||||
backgroundColor: themeName === "dark" ? "#0a0a0a" : "#ffffff",
|
backgroundColor: themeName === "dark" ? "#0a0a0a" : "#ffffff",
|
||||||
color: themeName === "dark" ? "#ffffff" : "#000000",
|
color: themeName === "dark" ? "#ffffff" : "#000000",
|
||||||
|
...contentStyle,
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeButtonStyle: React.CSSProperties = {
|
const closeButtonStyle: React.CSSProperties = {
|
||||||
@@ -315,7 +318,7 @@ export function ProBottomSheet({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div style={contentStyle}>{children}</div>
|
<div style={contentWrapperStyle}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import {
|
|||||||
updateSplitBillAmount,
|
updateSplitBillAmount,
|
||||||
} from "features/order/orderSlice";
|
} from "features/order/orderSlice";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import ProInputCard from "components/ProInputCard/ProInputCard";
|
import ProText from "components/ProText";
|
||||||
|
import ArabicPrice from "components/ArabicPrice";
|
||||||
|
import styles from "./SplitBill.module.css";
|
||||||
|
|
||||||
interface SplitBillChoiceBottomSheetProps {
|
interface SplitBillChoiceBottomSheetProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@@ -50,6 +52,14 @@ export function CustomAmountChoiceBottomSheet({
|
|||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Calculate preview values using local amount state for real-time updates
|
||||||
|
const currentAmount = parseFloat(amount) || 0;
|
||||||
|
// Original total bill (before split) = grandTotal + splitBillAmount (from Redux)
|
||||||
|
const originalTotalBill = grandTotal + splitBillAmount;
|
||||||
|
// Preview: total bill stays the same, remaining = original - current amount being typed
|
||||||
|
const previewTotalBill = originalTotalBill;
|
||||||
|
const previewRemaining = originalTotalBill - currentAmount;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProBottomSheet
|
<ProBottomSheet
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
@@ -57,19 +67,32 @@ export function CustomAmountChoiceBottomSheet({
|
|||||||
title={t("splitBill.payAsCustomAmount")}
|
title={t("splitBill.payAsCustomAmount")}
|
||||||
showCloseButton={true}
|
showCloseButton={true}
|
||||||
initialSnap={1}
|
initialSnap={1}
|
||||||
height={400}
|
height={430}
|
||||||
snapPoints={[400]}
|
snapPoints={[430]}
|
||||||
|
contentStyle={{
|
||||||
|
padding: 0,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
padding: "20px 0",
|
padding: "20px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
gap: 20,
|
gap: 20,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<ProInputCard title={t("splitBill.payAsCustomAmount")}>
|
<ProText
|
||||||
|
style={{
|
||||||
|
fontWeight: 400,
|
||||||
|
fontStyle: "Regular",
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: "140%",
|
||||||
|
letterSpacing: "0%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("splitBill.howMuchWouldYouLikeToPay")}
|
||||||
|
</ProText>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("splitBill.amount")}
|
label={t("splitBill.amount")}
|
||||||
name="amount"
|
name="amount"
|
||||||
@@ -77,14 +100,63 @@ export function CustomAmountChoiceBottomSheet({
|
|||||||
>
|
>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
value={amount}
|
value={amount}
|
||||||
onChange={(value) => setAmount(value?.toString() || "")}
|
onChange={(value) => {
|
||||||
|
setAmount(value?.toString() || "");
|
||||||
|
dispatch(updateSplitBillAmount(Number(value) || 0));
|
||||||
|
}}
|
||||||
placeholder={t("splitBill.amount")}
|
placeholder={t("splitBill.amount")}
|
||||||
max={grandTotal.toString()}
|
max={(grandTotal + splitBillAmount).toString()}
|
||||||
min={"0"}
|
min={"0"}
|
||||||
style={{ width: "100%", fontSize: "1rem" }}
|
style={{ width: "100%", fontSize: "1rem" }}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</ProInputCard>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
backgroundColor: "var(--background)",
|
||||||
|
padding: "20px",
|
||||||
|
opacity: 1,
|
||||||
|
gap: 8,
|
||||||
|
borderTopLeftRadius: 24,
|
||||||
|
borderTopRightRadius: 24,
|
||||||
|
paddingTop: 12,
|
||||||
|
paddingRight: 24,
|
||||||
|
paddingBottom: 24,
|
||||||
|
paddingLeft: 24,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={styles.summaryRow}>
|
||||||
|
<ProText
|
||||||
|
style={{
|
||||||
|
fontWeight: 400,
|
||||||
|
fontStyle: "Regular",
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: "140%",
|
||||||
|
letterSpacing: "0%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("splitBill.totalBill")}
|
||||||
|
</ProText>
|
||||||
|
<ArabicPrice price={previewTotalBill} />
|
||||||
|
</div>
|
||||||
|
<div className={styles.summaryRow}>
|
||||||
|
<ProText
|
||||||
|
style={{
|
||||||
|
fontWeight: 400,
|
||||||
|
fontStyle: "Regular",
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: "140%",
|
||||||
|
letterSpacing: "0%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("splitBill.remainingToPay")}
|
||||||
|
</ProText>
|
||||||
|
<ArabicPrice price={Math.max(0, previewRemaining)} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -94,19 +166,30 @@ export function CustomAmountChoiceBottomSheet({
|
|||||||
marginTop: 20,
|
marginTop: 20,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button style={{ flex: 1 }} onClick={handleRemoveSplitWay}>
|
<Button
|
||||||
{t("splitBill.removeSplitWay")}
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "#FEEDED",
|
||||||
|
color: "#DD4143",
|
||||||
|
boxShadow: "none",
|
||||||
|
border: "none",
|
||||||
|
}}
|
||||||
|
onClick={handleRemoveSplitWay}
|
||||||
|
>
|
||||||
|
{t("splitBill.removeSplit")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
style={{ flex: 1, boxShadow: "none" }}
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
boxShadow: "none",
|
||||||
|
}}
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
disabled={!amount || parseFloat(amount) <= 0}
|
disabled={!amount || parseFloat(amount) <= 0}
|
||||||
>
|
>
|
||||||
{t("cart.save")}
|
{t("splitBill.confirm")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</ProBottomSheet>
|
</ProBottomSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,8 +192,17 @@ export function PayForYourItemsChoiceBottomSheet({
|
|||||||
marginTop: 20,
|
marginTop: 20,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button style={{ flex: 1 }} onClick={handleRemoveSplitWay}>
|
<Button
|
||||||
{t("splitBill.removeSplitWay")}
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "#FEEDED",
|
||||||
|
color: "#DD4143",
|
||||||
|
boxShadow: "none",
|
||||||
|
border: "none",
|
||||||
|
}}
|
||||||
|
onClick={handleRemoveSplitWay}
|
||||||
|
>
|
||||||
|
{t("splitBill.removeSplit")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|||||||
@@ -46,3 +46,10 @@
|
|||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.summaryRow {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user