Skip to content

Commit 1a1bc6f

Browse files
committed
Fix platform fee display
1 parent 075d1ca commit 1a1bc6f

File tree

1 file changed

+4
-6
lines changed
  • frontend/src/components/common/PlatformFeesSettings

1 file changed

+4
-6
lines changed

frontend/src/components/common/PlatformFeesSettings/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {t} from "@lingui/macro";
22
import {Anchor, Button, Grid, Group, NumberInput, SegmentedControl, Stack, Text, Title} from "@mantine/core";
3-
import {useEffect, useRef, useState} from "react";
3+
import {useEffect, useState} from "react";
44
import {Card} from "../Card";
55
import {HeadingWithDescription} from "../Card/CardHeading";
66
import {formatCurrency} from "../../../utilites/currency.ts";
@@ -92,8 +92,7 @@ export const PlatformFeesSettings = ({
9292
feeHandlingDescription,
9393
}: PlatformFeesSettingsProps) => {
9494
const [samplePrice, setSamplePrice] = useState<number | string>(50);
95-
const [selectedOption, setSelectedOption] = useState<'pass' | 'absorb'>('absorb');
96-
const initializedRef = useRef(false);
95+
const [selectedOption, setSelectedOption] = useState<'pass' | 'absorb'>(currentValue ? 'pass' : 'absorb');
9796

9897
const feePercentage = configuration?.application_fees?.percentage || 0;
9998
const fixedFee = configuration?.application_fees?.fixed || 0;
@@ -105,11 +104,10 @@ export const PlatformFeesSettings = ({
105104
onSave(selectedOption === 'pass');
106105
};
107106

108-
// Initialize selected option from currentValue only once after data loads
107+
// Sync selected option when currentValue changes (e.g., after data loads)
109108
useEffect(() => {
110-
if (!isLoading && !initializedRef.current) {
109+
if (!isLoading) {
111110
setSelectedOption(currentValue ? 'pass' : 'absorb');
112-
initializedRef.current = true;
113111
}
114112
}, [isLoading, currentValue]);
115113

0 commit comments

Comments
 (0)