Skip to content

Commit 6c235f1

Browse files
committed
Clear columns on changing resource along with form validation in y axis column form
1 parent 5d88f69 commit 6c235f1

File tree

1 file changed

+65
-62
lines changed

1 file changed

+65
-62
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/charts/[chartID]/components/ChartGenVizPreview.tsx

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as echarts from 'echarts/core';
99
import {
1010
Button,
1111
Dialog,
12+
Form,
1213
Label,
1314
Popover,
1415
Select,
@@ -445,7 +446,11 @@ const ChartGenVizPreview = ({ params }: { params: any }) => {
445446
chartId: params.chartID,
446447
resource: value,
447448
name: chartData.name,
448-
options: chartData.options,
449+
options: {
450+
...chartData.options,
451+
xAxisColumn: '',
452+
yAxisColumn: [],
453+
},
449454
type: chartData.type,
450455
filters: chartData.filters,
451456
},
@@ -689,7 +694,7 @@ const ChartGenVizPreview = ({ params }: { params: any }) => {
689694
</div>
690695
) : (
691696
<div className="sticky top-36 flex w-full items-center justify-center">
692-
<Text variant="bodyLg">No Chart Data</Text>
697+
<Text variant="bodyLg">No Valid Chart Data</Text>
693698
</div>
694699
)}
695700
</div>
@@ -903,11 +908,6 @@ const ChartGenVizPreview = ({ params }: { params: any }) => {
903908
columnLabel={''}
904909
columnColor={''}
905910
onSubmit={(e) => {
906-
console.log(
907-
'addYAxisColumn :::::::::',
908-
e,
909-
chartData.options.yAxisColumn
910-
);
911911
if (
912912
chartData.options.yAxisColumn === undefined ||
913913
chartData.options.yAxisColumn?.findIndex(
@@ -1054,62 +1054,65 @@ const YaxisColumnForm = ({
10541054

10551055
return (
10561056
<div className="flex w-full min-w-full flex-col gap-1 p-8">
1057-
{/* Y axis Column */}
1058-
<Select
1059-
name="selectYAxisColumn"
1060-
label="Column"
1061-
options={yAxisOptions}
1062-
value={yAxisColumn}
1063-
onChange={(e) => {
1064-
setYAxisColumn(e);
1065-
}}
1066-
/>
1067-
1068-
{/* Label for specific element */}
1069-
<TextField
1070-
name="selectYAxisColumnLabel"
1071-
label="Label"
1072-
value={yAxisColumnLabel}
1073-
onChange={(e) => {
1074-
setYAxisColumnLabel(e);
1075-
}}
1076-
/>
1077-
1078-
{/* Color for specific element */}
1079-
<TextField
1080-
name="selectYAxisColumnColor"
1081-
label="Color"
1082-
value={yAxisColumnColor}
1083-
onChange={(e) => {
1084-
setYAxisColumnColor(e);
1085-
}}
1086-
/>
1087-
1088-
<div className="mt-1 flex flex-row justify-between gap-8">
1089-
<Button
1090-
kind="secondary"
1091-
size="slim"
1092-
className="rounded-2 border-1 border-solid border-greyExtralight"
1093-
onClick={onCancel}
1094-
>
1095-
Cancel
1096-
</Button>
1097-
1098-
<Button
1099-
kind="primary"
1100-
size="slim"
1101-
className="rounded-2 border-1 border-solid border-greyExtralight"
1102-
onClick={() => {
1103-
onSubmit({
1104-
fieldName: yAxisColumn,
1105-
label: yAxisColumnLabel,
1106-
color: yAxisColumnColor,
1107-
});
1057+
<Form>
1058+
{/* Y axis Column */}
1059+
<Select
1060+
name="selectYAxisColumn"
1061+
label="Column"
1062+
options={yAxisOptions}
1063+
value={yAxisColumn}
1064+
onChange={(e) => {
1065+
setYAxisColumn(e);
11081066
}}
1109-
>
1110-
Save
1111-
</Button>
1112-
</div>
1067+
required
1068+
/>
1069+
1070+
{/* Label for specific element */}
1071+
<TextField
1072+
name="selectYAxisColumnLabel"
1073+
label="Label"
1074+
value={yAxisColumnLabel}
1075+
onChange={(e) => {
1076+
setYAxisColumnLabel(e);
1077+
}}
1078+
/>
1079+
1080+
{/* Color for specific element */}
1081+
<TextField
1082+
name="selectYAxisColumnColor"
1083+
label="Color"
1084+
value={yAxisColumnColor}
1085+
onChange={(e) => {
1086+
setYAxisColumnColor(e);
1087+
}}
1088+
/>
1089+
1090+
<div className="mt-1 flex flex-row justify-between gap-8">
1091+
<Button
1092+
kind="secondary"
1093+
size="slim"
1094+
className="rounded-2 border-1 border-solid border-greyExtralight"
1095+
onClick={onCancel}
1096+
>
1097+
Cancel
1098+
</Button>
1099+
1100+
<Button
1101+
kind="primary"
1102+
size="slim"
1103+
className="rounded-2 border-1 border-solid border-greyExtralight"
1104+
onClick={() => {
1105+
onSubmit({
1106+
fieldName: yAxisColumn,
1107+
label: yAxisColumnLabel,
1108+
color: yAxisColumnColor,
1109+
});
1110+
}}
1111+
>
1112+
Save
1113+
</Button>
1114+
</div>
1115+
</Form>
11131116
</div>
11141117
);
11151118
};

0 commit comments

Comments
 (0)