From 192d0baf3344276c4308d0912030646bbfcc1517 Mon Sep 17 00:00:00 2001 From: yusualhashash Date: Fri, 9 Aug 2024 15:49:44 +0300 Subject: [PATCH 1/4] feat: send the fileds of table from template page to table page --- .../app/[type]/template/rebate/page.tsx | 169 ++++++++++++------ 1 file changed, 116 insertions(+), 53 deletions(-) diff --git a/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx b/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx index a7df3f6b6..951c21bac 100644 --- a/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx +++ b/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx @@ -74,9 +74,52 @@ function AmountCell({ getValue, row: { index }, column: { id }, table }: any) { ); } +const feescolumns: ColumnDef>[] = [ + { + id: "select", + header: ({ table }) => ( + { + table.toggleAllPageRowsSelected(Boolean(value)); + }} + /> + ), + cell: ({ row }) => ( + { + row.toggleSelected(); + }} + /> + ), + }, + { + accessorKey: "name", + header: () =>
Name
, + cell: (props) => , + }, + { + accessorKey: "amount", + header: () =>
Amount
, + cell: (props) => , + }, + { + accessorKey: "actions", + enableHiding: false, + cell: () => ( + + ), + }, +]; + function SetupCell({ getValue, row: { index }, column: { id }, table }: any) { - const initialValue = getValue() as string | undefined; - const [value, setValue] = useState(initialValue); + const setupValue = getValue() as string | undefined; + const [value, setValue] = useState(setupValue); const onChange = (newValue: string): void => { setValue(newValue); @@ -84,8 +127,8 @@ function SetupCell({ getValue, row: { index }, column: { id }, table }: any) { }; useEffect(() => { - setValue(initialValue); - }, [initialValue]); + setValue(setupValue); + }, [setupValue]); return ( >[] = [ - { - id: "select", - header: ({ table }) => ( - { - table.toggleAllPageRowsSelected(Boolean(value)); - }} - /> - ), - cell: ({ row }) => ( - { - row.toggleSelected(); - }} - /> - ), - }, - { - accessorKey: "name", - header: () =>
Name
, - cell: (props) => , - }, - { - accessorKey: "amount", - header: () =>
Amount
, - cell: (props) => , - }, - { - accessorKey: "actions", - enableHiding: false, - cell: () => ( - - ), - }, -]; +function Variablefee({ getValue, row: { index }, column: { id }, table }: any) { + const variableFeeValue = getValue() as string | undefined; + const [value, setValue] = useState(variableFeeValue); + + const onChange = (newValue: string): void => { + setValue(newValue); + table.options.meta?.updateData(index, id, newValue); + }; + + useEffect(() => { + setValue(variableFeeValue); + }, [variableFeeValue]); + + return ( + + ); +} + +function PercentCell({ getValue, row: { index }, column: { id }, table }: any) { + const percentValue = getValue(); + const [value, setValue] = useState(percentValue); + + const onBlur = (): void => { + table.options.meta?.updateData(index, id, value); + }; + + useEffect(() => { + setValue(percentValue); + }, [percentValue]); + + return ( + { + setValue(e.target.value); + }} + type="number" + value={value as string} + /> + ); +} const setupcolumns: ColumnDef>[] = [ { @@ -202,12 +254,12 @@ const setupcolumns: ColumnDef>[] = [ { accessorKey: "fixedfee", header: () =>
Fixed fee
, - cell: (props) => , + cell: (props) => , }, { accessorKey: "variablefee", header: () =>
Variable fee
, - cell: (props) => , + cell: (props) => , }, { accessorKey: "percent", @@ -255,6 +307,15 @@ function Rebate() { return Object.values(row).every((value) => value === "" || value === null); }; + const feesHeaders = { name: "", amount: "" }; + + const setupHeaders = { + refundmethod: "", + fixedfee: "", + variablefee: "", + percent: "", + }; + return (
@@ -282,6 +343,7 @@ function Rebate() {
Date: Mon, 12 Aug 2024 14:56:17 +0300 Subject: [PATCH 2/4] chore: edit the position of calculate button --- .../web/src/app/[lang]/app/[type]/template/preview/page.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/[lang]/app/[type]/template/preview/page.tsx b/apps/web/src/app/[lang]/app/[type]/template/preview/page.tsx index 3ad8cd3da..7e0ad84f4 100644 --- a/apps/web/src/app/[lang]/app/[type]/template/preview/page.tsx +++ b/apps/web/src/app/[lang]/app/[type]/template/preview/page.tsx @@ -310,9 +310,9 @@ const data = [ function MyDataTable() { return (
-
- - +
+ +
Date: Mon, 12 Aug 2024 15:31:16 +0300 Subject: [PATCH 3/4] feat: make handlesubmit function enable to send the data from autofrma nd table --- .../app/[type]/template/rebate/page.tsx | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx b/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx index 951c21bac..bac277b6a 100644 --- a/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx +++ b/apps/web/src/app/[lang]/app/[type]/template/rebate/page.tsx @@ -109,8 +109,13 @@ const feescolumns: ColumnDef>[] = [ { accessorKey: "actions", enableHiding: false, - cell: () => ( - ), @@ -193,10 +198,10 @@ function Variablefee({ getValue, row: { index }, column: { id }, table }: any) { - % of GC - % of GC without VAT - % of VAT - % of SIS + % of GC + % of GC without VAT + % of VAT + % of SIS ); @@ -269,8 +274,13 @@ const setupcolumns: ColumnDef>[] = [ { accessorKey: "actions", enableHiding: false, - cell: () => ( - ), @@ -279,28 +289,23 @@ const setupcolumns: ColumnDef>[] = [ function Rebate() { const [autoFormData, setAutoFormData] = useState>({}); - const [feesData] = useState(initialFeesData); - const [setupData] = useState(initialSetupData); + const [feesData, setFeesData] = useState(initialFeesData); + const [setupData, setSetupData] = useState(initialSetupData); const handleFormChange = (newFormData: any): void => { setAutoFormData(newFormData); }; - const handleSubmit = (): void => { + const handleSubmit = () => { const filteredFeesData = feesData.filter((row) => !isRowEmpty(row)); const filteredSetupData = setupData.filter((row) => !isRowEmpty(row)); const payload: any = { autoFormData, + feesData: filteredFeesData, + setupData: filteredSetupData, }; - - if (filteredFeesData.length > 0) { - payload.feesData = filteredFeesData; - } - - if (filteredSetupData.length > 0) { - payload.setupData = filteredSetupData; - } + return payload; }; const isRowEmpty = (row: any): boolean => { @@ -320,7 +325,8 @@ function Rebate() {
- Edit Template Information + + Edit Template Information
@@ -350,6 +356,7 @@ function Rebate() { }} data={feesData} editable + onDataUpdate={() => { setFeesData(initialFeesData); }} showView={false} />
@@ -369,6 +376,7 @@ function Rebate() { }} data={setupData} editable + onDataUpdate={() => { setSetupData(initialSetupData); }} showView={false} />
From 3dab0a437a075920755410eac78464af86991a68 Mon Sep 17 00:00:00 2001 From: yusualhashash Date: Mon, 12 Aug 2024 15:33:48 +0300 Subject: [PATCH 4/4] chore: update ui --- packages/ayasofyazilim-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ayasofyazilim-ui b/packages/ayasofyazilim-ui index 0573d4cd4..d6018e98e 160000 --- a/packages/ayasofyazilim-ui +++ b/packages/ayasofyazilim-ui @@ -1 +1 @@ -Subproject commit 0573d4cd4fada3a89990b766714d1a89f412dc4f +Subproject commit d6018e98e047ad335309d705f481c1e819913cf8