From 906d4a3ae6f34ef5161b4c3ebfbff9250e4c5cc3 Mon Sep 17 00:00:00 2001 From: pokhrelashok2 Date: Tue, 28 Nov 2023 10:51:26 +0545 Subject: [PATCH] Customizable units added --- app/fill/page.tsx | 108 +++++++++++++++++++++++++------------- src-tauri/tauri.conf.json | 2 +- 2 files changed, 72 insertions(+), 38 deletions(-) diff --git a/app/fill/page.tsx b/app/fill/page.tsx index 08873fa..06a2d82 100644 --- a/app/fill/page.tsx +++ b/app/fill/page.tsx @@ -29,24 +29,30 @@ export default function OpenShares() { const { handle: apply, loading: isApplying } = useInvoke("apply_share"); const [showConfirmDialog, setShowConfirmDialog] = useState(false); + const [applyUnits, setApplyUnits] = useState(0); + + useEffect(() => { + if (selectedShare && selectedShare.minUnit) + setApplyUnits(selectedShare.minUnit); + }, [selectedShare]); async function applyShare(company: Prospectus) { setShowConfirmDialog(false); setApplyStarted(true); - // for (let index = 0; index < users.length; index++) { - // const user = users[index]; - // await apply({ - // id: company.companyShareId, - // user: user, - // units: company.minUnit, - // }) - // .then((result) => { - // setReport((old) => ({ ...old, [user.id as string]: result.status })); - // }) - // .catch((e: string) => { - // setReport((old) => ({ ...old, [user.id as string]: e })); - // }); - // } + for (let index = 0; index < users.length; index++) { + const user = users[index]; + await apply({ + id: company.companyShareId, + user: user, + units: applyUnits, + }) + .then((result) => { + setReport((old) => ({ ...old, [user.id as string]: result.status })); + }) + .catch((e: string) => { + setReport((old) => ({ ...old, [user.id as string]: e })); + }); + } setSharesApplied((old) => [...old, selectedShare.companyShareId]); } useEffect(() => { @@ -97,24 +103,45 @@ export default function OpenShares() { Share Type:{" "} {selectedShare.shareTypeName} - + setApplyUnits(parseInt(e.target.value))} + /> + + )} {isFetchingProspectus && } @@ -135,12 +162,19 @@ export default function OpenShares() { setShowConfirmDialog(false)} onConfirm={() => applyShare(selectedShare)} - title="Confirm your action!" - subtitle={`Are you share you want to apply ${ - selectedShare.minUnit - } units of share for ${selectedShare.companyName} at Rs ${formatPrice( - selectedShare.sharePerUnit - )} per unit?`} + title="Confirm your action" + subtitle={ +
+ Are you share you want to apply {applyUnits}{" "} + units of share for {selectedShare.companyName} at + Rs {formatPrice(selectedShare.sharePerUnit)} per + unit? (Rs{" "} + + {formatPrice(selectedShare.sharePerUnit * applyUnits)} + + ) +
+ } /> )} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 52fcfce..7978f4e 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "share-sathi", - "version": "2.0.1" + "version": "2.0.2" }, "tauri": { "allowlist": {