CustomAmountChoiceBottomSheet: update UI

This commit is contained in:
2025-12-17 01:04:45 +03:00
parent 76a06cc3ee
commit c369807f40
6 changed files with 157 additions and 47 deletions

View File

@@ -425,7 +425,11 @@
"yourAmount": "مبلغك", "yourAmount": "مبلغك",
"selectedTotal": "المجموع المحدد", "selectedTotal": "المجموع المحدد",
"splitBillAmount": "مبلغ تقسيم الفاتورة", "splitBillAmount": "مبلغ تقسيم الفاتورة",
"removeSplitWay": "إزالة طريقة التقسيم", "removeSplit": "إزالة التقسيم",
"amount": "المبلغ" "amount": "المبلغ",
"howMuchWouldYouLikeToPay": "كم مبلغ تريد دفعه؟",
"confirm": "تأكيد",
"totalBill": "الفاتورة الكلية",
"remainingToPay": "المبلغ المتبقي"
} }
} }

View File

@@ -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"
} }
} }

View File

@@ -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>
</> </>
); );

View File

@@ -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,56 +67,129 @@ 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
<Form.Item style={{
label={t("splitBill.amount")} fontWeight: 400,
name="amount" fontStyle: "Regular",
style={{ position: "relative", top: -5 }} fontSize: 16,
> lineHeight: "140%",
<InputNumber letterSpacing: "0%",
value={amount} }}
onChange={(value) => setAmount(value?.toString() || "")}
placeholder={t("splitBill.amount")}
max={grandTotal.toString()}
min={"0"}
style={{ width: "100%", fontSize:"1rem" }}
/>
</Form.Item>
</ProInputCard>
</div>
<div
style={{
display: "flex",
gap: 12,
marginTop: 20,
}}
>
<Button style={{ flex: 1 }} onClick={handleRemoveSplitWay}>
{t("splitBill.removeSplitWay")}
</Button>
<Button
type="primary"
style={{ flex: 1, boxShadow: "none" }}
onClick={handleSave}
disabled={!amount || parseFloat(amount) <= 0}
> >
{t("cart.save")} {t("splitBill.howMuchWouldYouLikeToPay")}
</Button> </ProText>
<Form.Item
label={t("splitBill.amount")}
name="amount"
style={{ position: "relative", top: -5 }}
>
<InputNumber
value={amount}
onChange={(value) => {
setAmount(value?.toString() || "");
dispatch(updateSplitBillAmount(Number(value) || 0));
}}
placeholder={t("splitBill.amount")}
max={(grandTotal + splitBillAmount).toString()}
min={"0"}
style={{ width: "100%", fontSize: "1rem" }}
/>
</Form.Item>
</div> </div>
</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
style={{
display: "flex",
gap: 12,
marginTop: 20,
}}
>
<Button
style={{
flex: 1,
backgroundColor: "#FEEDED",
color: "#DD4143",
boxShadow: "none",
border: "none",
}}
onClick={handleRemoveSplitWay}
>
{t("splitBill.removeSplit")}
</Button>
<Button
type="primary"
style={{
flex: 1,
boxShadow: "none",
}}
onClick={handleSave}
disabled={!amount || parseFloat(amount) <= 0}
>
{t("splitBill.confirm")}
</Button>
</div>
</ProBottomSheet> </ProBottomSheet>
); );
} }

View File

@@ -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"

View File

@@ -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;
}