Comission is now hidden from everyone apart from admins

This commit is contained in:
Joao Ramos
2023-12-14 17:34:52 +00:00
parent 73d7ddc4af
commit 6f61fe1564

View File

@@ -57,7 +57,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const columnHelper = createColumnHelper<Payment>(); const columnHelper = createColumnHelper<Payment>();
const PaymentCreator = ({onClose, reload}: {onClose: () => void; reload: () => void}) => { const PaymentCreator = ({onClose, reload, showComission = false}: {onClose: () => void; reload: () => void, showComission: boolean}) => {
const [corporate, setCorporate] = useState<CorporateUser>(); const [corporate, setCorporate] = useState<CorporateUser>();
const [price, setPrice] = useState<number>(0); const [price, setPrice] = useState<number>(0);
const [currency, setCurrency] = useState<string>("EUR"); const [currency, setCurrency] = useState<string>("EUR");
@@ -173,24 +173,25 @@ const PaymentCreator = ({onClose, reload}: {onClose: () => void; reload: () => v
/> />
</div> </div>
</div> </div>
{showComission && (
<div className="flex gap-4 w-full"> <div className="flex gap-4 w-full">
<div className="flex flex-col w-full gap-3"> <div className="flex flex-col w-full gap-3">
<label className="font-normal text-base text-mti-gray-dim">Commission *</label> <label className="font-normal text-base text-mti-gray-dim">Commission *</label>
<Input name="commission" onChange={(e) => setCommission(e ? parseInt(e) : 0)} type="number" defaultValue={0} /> <Input name="commission" onChange={(e) => setCommission(e ? parseInt(e) : 0)} type="number" defaultValue={0} />
</div>
<div className="flex flex-col w-full gap-3">
<label className="font-normal text-base text-mti-gray-dim">Commission Value*</label>
<Input
name="commissionValue"
value={`${(commission / 100) * price} ${CURRENCIES.find((c) => c.currency === currency)?.label}`}
onChange={() => null}
type="text"
defaultValue={0}
disabled
/>
</div>
</div> </div>
<div className="flex flex-col w-full gap-3"> )}
<label className="font-normal text-base text-mti-gray-dim">Commission Value*</label>
<Input
name="commissionValue"
value={`${(commission / 100) * price} ${CURRENCIES.find((c) => c.currency === currency)?.label}`}
onChange={() => null}
type="text"
defaultValue={0}
disabled
/>
</div>
</div>
<div className="flex gap-4"> <div className="flex gap-4">
<div className="flex flex-col w-full gap-3"> <div className="flex flex-col w-full gap-3">
@@ -420,7 +421,11 @@ export default function PaymentRecord() {
</Modal> </Modal>
<Modal isOpen={isCreatingPayment} onClose={() => setIsCreatingPayment(false)}> <Modal isOpen={isCreatingPayment} onClose={() => setIsCreatingPayment(false)}>
<PaymentCreator onClose={() => setIsCreatingPayment(false)} reload={reload} /> <PaymentCreator
onClose={() => setIsCreatingPayment(false)}
reload={reload}
showComission={user.type === "developer" || user.type === "admin"}
/>
</Modal> </Modal>
<div className="w-full flex flex-end justify-between p-2"> <div className="w-full flex flex-end justify-between p-2">