Skip to main content

calcDiscount

5000

import { calcDiscount } from 'app-functions';
export const calcDiscount = (discount_amount, price) =>
discount_amount > 100 ? discount_amount : (discount_amount / 100) * price;
export const App = () => {
const [value, setValue] = React.useState('100000');
const [discountAmount, setDiscountAmount] = React.useState('5');
return (
<div className="box-border">
<Input
onChange={(e) => setValue(e.target.value)}
value={value}
className="w-25"
placeholder="قیمت وارد کنید"
/>
<Input
onChange={(e) => setDiscountAmount(e.target.value)}
value={discountAmount}
className="w-25 mr-8"
placeholder="مقدار تخفیف را وارد کنید"
/>
<Typography className="mt-24">
{calcDiscount(discountAmount, value)}
</Typography>
</div>
);
};