diff --git a/.changeset/split-meow-mixed-currency-proactive-guard.md b/.changeset/split-meow-mixed-currency-proactive-guard.md new file mode 100644 index 000000000..3f01214d5 --- /dev/null +++ b/.changeset/split-meow-mixed-currency-proactive-guard.md @@ -0,0 +1,5 @@ +--- +'@app/split-meow': patch +--- + +切換幣別或記帳若會使同一行程混用多種幣別,改在當下以確認對話框提示;編輯舊費用時改以行程主導幣別解析符號,避免顯示錯誤幣別。時區自動偵測幣別若會造成混幣則靜默跳過,不再覆寫使用者幣別。 diff --git a/apps/split-meow/src/components/Calculator.tsx b/apps/split-meow/src/components/Calculator.tsx index 7c53222f4..09713dfd1 100644 --- a/apps/split-meow/src/components/Calculator.tsx +++ b/apps/split-meow/src/components/Calculator.tsx @@ -2,6 +2,7 @@ import { useTranslation } from 'react-i18next'; import { useStore } from '../store/useStore'; import { cn } from '../lib/utils'; import { evaluateExpression } from '../lib/evaluateExpression'; +import { confirmMixedCurrencyIfNeeded } from '../config/currencies'; interface CalculatorProps { onPawParticle?: (x: number, y: number) => void; @@ -17,6 +18,9 @@ export function Calculator({ onPawParticle }: CalculatorProps = {}) { setCalculatorValue, setItemizedValue, saveExpense, + expenses, + currentTripId, + currency, } = useStore(); const currentValue = @@ -31,6 +35,21 @@ export function Calculator({ onPawParticle }: CalculatorProps = {}) { ? evaluateExpression(currentValue) > 0 : Object.values(itemizedValues).some((v) => evaluateExpression(v) > 0); + const handleSave = () => { + const tripExpenses = expenses.filter((e) => e.tripId === currentTripId); + if ( + !confirmMixedCurrencyIfNeeded( + tripExpenses, + currency, + currency, + t('history.mixed_currency_confirm'), + ) + ) { + return; + } + saveExpense(); + }; + const handlePress = (key: string) => { if (splitMode === 'itemized' && !focusedMemberId) return; if ('vibrate' in navigator) navigator.vibrate(8); @@ -191,7 +210,7 @@ export function Calculator({ onPawParticle }: CalculatorProps = {}) { ))}