working on tip card and BS

This commit is contained in:
2026-01-05 20:00:54 +03:00
parent ab265bf09a
commit c8bf8ff621
5 changed files with 59 additions and 43 deletions

View File

@@ -3,21 +3,22 @@ import WaiterRewardingIcon from "components/Icons/waiter/WaiterRewardingIcon";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet";
import { updateTip } from "features/order/orderSlice";
import { useAppDispatch } from "redux/hooks";
interface TipBottomSheetProps {
isOpen: boolean;
onClose: () => void;
initialValue: string;
onSave: (value: string) => void;
}
export function TipBottomSheet({
isOpen,
onClose,
initialValue,
onSave,
}: TipBottomSheetProps) {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const [value, setValue] = useState(initialValue);
useEffect(() => {
@@ -25,7 +26,8 @@ export function TipBottomSheet({
}, [initialValue]);
const handleSave = () => {
onSave(value);
const numAmount = parseFloat(value) || 0;
dispatch(updateTip(numAmount.toString()));
onClose();
};
@@ -39,7 +41,6 @@ export function TipBottomSheet({
isOpen={isOpen}
onClose={handleCancel}
title={t("cart.tip")}
showCloseButton={false}
initialSnap={1}
height={370}
snapPoints={[370]}
@@ -64,6 +65,7 @@ export function TipBottomSheet({
placeholder={t("cart.amount")}
autoFocus={false}
size="large"
style={{ height: 48 }}
/>
<br />

View File

@@ -2,29 +2,27 @@ import { Button, Input, Modal } from "antd";
import WaiterRewardingIcon from "components/Icons/waiter/WaiterRewardingIcon";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useAppDispatch } from "redux/hooks";
import { updateTip } from "features/order/orderSlice";
interface TipDialogProps {
isOpen: boolean;
onClose: () => void;
initialValue: string;
onSave: (value: string) => void;
}
export function TipDialog({
isOpen,
onClose,
initialValue,
onSave,
}: TipDialogProps) {
export function TipDialog({ isOpen, onClose, initialValue }: TipDialogProps) {
const { t } = useTranslation();
const [value, setValue] = useState(initialValue);
const dispatch = useAppDispatch();
useEffect(() => {
setValue(initialValue);
}, [initialValue]);
const handleSave = () => {
onSave(value);
const numAmount = parseFloat(value) || 0;
dispatch(updateTip(numAmount.toString()));
onClose();
};