rez-table-listing-mui 1.0.46 → 1.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez-table-listing-mui",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
@@ -35,8 +35,14 @@ const QuickTab = ({
35
35
  tabsApiData,
36
36
  tabsApiDataLoading,
37
37
  }: SettingsQuickTabProps) => {
38
- const { quickTabStates, setQuickTabStates, settingsData, setColumnTabState } =
39
- filterSettingStates;
38
+ const {
39
+ quickTabStates,
40
+ setQuickTabStates,
41
+ settingsData,
42
+ setColumnTabState,
43
+ saveButtonError,
44
+ setSaveButtonError,
45
+ } = filterSettingStates;
40
46
 
41
47
  const [searchTerm, setSearchTerm] = useState<string>("");
42
48
 
@@ -101,6 +107,43 @@ const QuickTab = ({
101
107
  }));
102
108
  }
103
109
  }
110
+
111
+ // check for error
112
+ const hasInvalidValidShowList =
113
+ quickTabStates.show_list &&
114
+ (quickTabStates.show_list?.length === 0 ||
115
+ quickTabStates.show_list.length >= 5);
116
+
117
+ if (hasInvalidValidShowList) {
118
+ // Check if error is already in the state to avoid duplication
119
+ const errorMessage = {
120
+ type: "quick_tab_error",
121
+ message:
122
+ "Quick Tab : View as Tabs should have at least 1 and at most 5 tabs.",
123
+ };
124
+ const hasQuickTabError = saveButtonError?.messages?.some(
125
+ (message) => message.type === "quick_tab_error"
126
+ );
127
+
128
+ if (!hasQuickTabError) {
129
+ setSaveButtonError((prev) => ({
130
+ ...prev,
131
+ hasError: true,
132
+ messages: [...(prev?.messages || []), errorMessage], // Only add if it doesn't exist
133
+ }));
134
+ }
135
+ } else {
136
+ const otherMessages =
137
+ saveButtonError?.messages?.filter(
138
+ (message) => message.type !== "quick_tab_error"
139
+ ) || [];
140
+
141
+ setSaveButtonError((prev) => ({
142
+ ...prev,
143
+ hasError: otherMessages.length > 0,
144
+ messages: otherMessages,
145
+ }));
146
+ }
104
147
  }, [quickTabStates.show_list, quickTabStates.hide_list]);
105
148
 
106
149
  // useEffect(() => {
@@ -37,6 +37,7 @@ export function QuickFilterSettings({
37
37
  quickTabStates,
38
38
  columnTabState,
39
39
  sortingTabState,
40
+ saveButtonError,
40
41
  } = filterSettingStates;
41
42
 
42
43
  const hasAPIData = Boolean(Object.entries(columnsData).length);
@@ -148,7 +149,10 @@ export function QuickFilterSettings({
148
149
 
149
150
  {!columnsDataLoading && hasAPIData && (
150
151
  <DialogActions>
151
- <CustomButton onClick={handleSaveSetSettingsData}>
152
+ <CustomButton
153
+ disabled={saveButtonError?.hasError}
154
+ onClick={handleSaveSetSettingsData}
155
+ >
152
156
  Save Quick Filter
153
157
  </CustomButton>
154
158
  </DialogActions>