Skip to content

Commit

Permalink
feat:support ratio 0 (labring#5286)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou authored Dec 13, 2024
1 parent 4a6fcd0 commit 6e6f940
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function CurrencySymbol({
} & IconProps &
TextProps) {
return type === 'shellCoin' ? (
<Img src={sealosCoin.src} boxSize={'16px'} maxW={'unset'} {...props}></Img>
<Img src={sealosCoin.src} boxSize={'16px'} maxW={'unset'} {...props} w={'auto'}></Img>
) : type === 'cny' ? (
<Text {...props}></Text>
) : (
Expand Down
13 changes: 11 additions & 2 deletions frontend/providers/costcenter/src/components/RechargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const BonusBox = (props: {
</Flex>
</Flex>
</Flex>
) : (
) : props.bouns !== 0 ? (
<Flex
position={'absolute'}
minW={'max-content'}
Expand All @@ -216,6 +216,8 @@ const BonusBox = (props: {
<CurrencySymbol boxSize={'10px'} mr={'2px'} />
<Text> {props.bouns}</Text>
</Flex>
) : (
<></>
)}
<Flex align={'center'}>
<Currencysymbol boxSize="20px" type={currency} />
Expand Down Expand Up @@ -345,6 +347,7 @@ const RechargeModal = forwardRef(
>('/api/price/bonus'),
{}
);

const [defaultSteps, ratios, steps, specialBonus] = useMemo(() => {
const defaultSteps = Object.entries(bonuses?.data?.discount.defaultSteps || {}).sort(
(a, b) => +a[0] - +b[0]
Expand Down Expand Up @@ -377,7 +380,12 @@ const RechargeModal = forwardRef(
const { stripeEnabled, wechatEnabled } = useEnvStore();
useEffect(() => {
if (steps && steps.length > 0) {
setAmount(steps[0]);
const result = steps.map((v, idx) => [v, getBonus(v), idx]).filter(([k, v]) => v > 0);
if (result.length > 0) {
const [key, bouns, idx] = result[0];
setSelectAmount(idx);
setAmount(key);
}
}
}, [steps]);
const handleWechatConfirm = () => {
Expand Down Expand Up @@ -674,6 +682,7 @@ const RechargeModal = forwardRef(
.filter(([_, _2, ratio], idx) => {
return ratio > 0;
})

.map(([pre, next, ratio], idx) => (
<>
<Text key={idx} pl={'24px'} color={'grayModern.900'}>
Expand Down

0 comments on commit 6e6f940

Please sign in to comment.