rez-table-listing-mui 1.0.40 → 1.0.41

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.40",
3
+ "version": "1.0.41",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
package/src/App.tsx CHANGED
@@ -9,9 +9,10 @@ import {
9
9
  useDeleteFilterAPI,
10
10
  useEntityTableAPI,
11
11
  useSavedFilterAPI,
12
- useSaveSettingsDataAPI,
12
+ useGetSettingsDataAPI,
13
13
  useSettingsDropDownAPI,
14
14
  useUpdateFilterAPI,
15
+ useSaveSettingsDataAPI,
15
16
  } from "./libs/hooks/useEntityTableAPI";
16
17
  import {
17
18
  useDetailsQueryAPI,
@@ -20,7 +21,8 @@ import {
20
21
  import LoginButton from "./components/login";
21
22
  import { CraftTableFilter } from ".";
22
23
  import { useCraftTableFilterSettings } from "./libs/hooks/useCraftTableFilterSettings";
23
- import QuickFilterSettings from "./components/table-settings";
24
+ import { QuickFilterSettings } from "./components/table-settings";
25
+ import { SettingsDataProps } from "./types/filter-settings";
24
26
  // import { ENTITY_TYPE } from "./libs/utils/common";
25
27
 
26
28
  function App() {
@@ -38,12 +40,8 @@ function App() {
38
40
 
39
41
  const { filters, setFilters, filterMaster, filterToDelete } = tableStates;
40
42
 
41
- const {
42
- showListViewSettings,
43
- setShowListViewSettings,
44
- settingsData,
45
- setSettingsData,
46
- } = filterSettingStates;
43
+ const { showListViewSettings, setShowListViewSettings, setSettingsData } =
44
+ filterSettingStates;
47
45
 
48
46
  const { defaultColumns } = useDefaultColumns();
49
47
 
@@ -57,7 +55,7 @@ function App() {
57
55
  const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
58
56
  const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
59
57
  const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
60
-
58
+ const { saveSettingsDataMutation } = useSaveSettingsDataAPI("AYR");
61
59
  const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
62
60
  const { settingsTabDropdownData, settingsTabDropdownPending } =
63
61
  useSettingsDropDownAPI({
@@ -66,9 +64,7 @@ function App() {
66
64
  sort_by: filterSettingStates?.quickTabStates?.sorting,
67
65
  });
68
66
 
69
- const { saveSettingsAPIData } = useSaveSettingsDataAPI({
70
- payload: filterSettingStates?.settingsData,
71
- });
67
+ const { getSettingsAPIData } = useGetSettingsDataAPI("AYR");
72
68
 
73
69
  useEffect(() => {
74
70
  // setTimeout(() => {
@@ -92,9 +88,8 @@ function App() {
92
88
  }, [detailsQuery.data]);
93
89
 
94
90
  useEffect(() => {
95
- setSettingsData(saveSettingsAPIData?.layout_json);
96
- console.log("settingsData", settingsData);
97
- }, [saveSettingsAPIData]);
91
+ setSettingsData(getSettingsAPIData?.layout_json);
92
+ }, [getSettingsAPIData]);
98
93
 
99
94
  //For server side sorting
100
95
  const enableServerSideSorting = true;
@@ -234,6 +229,16 @@ function App() {
234
229
  updateMutation.mutate({ entity_type, payload });
235
230
  };
236
231
 
232
+ const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
233
+ const payload = {
234
+ entity_type: "LAP",
235
+ mapped_entity_type: "AYR",
236
+ layout_json: settingsData,
237
+ };
238
+
239
+ saveSettingsDataMutation.mutate({ payload });
240
+ };
241
+
237
242
  return (
238
243
  <div className="app_wrapper">
239
244
  <LoginButton />
@@ -302,8 +307,10 @@ function App() {
302
307
  filterSettingStates={filterSettingStates}
303
308
  onClose={() => setShowListViewSettings(false)}
304
309
  columnsData={metaQuery.data || {}}
310
+ columnsDataLoading={metaQuery.isPending}
305
311
  tabsApiData={settingsTabDropdownData || []}
306
312
  tabsApiDataLoading={settingsTabDropdownPending}
313
+ onSaveSettingsData={handleSaveSettingsData}
307
314
  />
308
315
  </>
309
316
  ),
@@ -838,7 +838,7 @@ export const AddIcon = ({ ...props }) => {
838
838
  >
839
839
  <path
840
840
  d="M4.50002 5.50002H1.16669C1.02502 5.50002 0.906298 5.45208 0.81052 5.35619C0.714632 5.2603 0.666687 5.14152 0.666687 4.99985C0.666687 4.85808 0.714632 4.73935 0.81052 4.64369C0.906298 4.54791 1.02502 4.50002 1.16669 4.50002H4.50002V1.16669C4.50002 1.02502 4.54797 0.906298 4.64385 0.81052C4.73974 0.714632 4.85852 0.666687 5.00019 0.666687C5.14197 0.666687 5.26069 0.714632 5.35635 0.81052C5.45213 0.906298 5.50002 1.02502 5.50002 1.16669V4.50002H8.83335C8.97502 4.50002 9.09374 4.54797 9.18952 4.64385C9.28541 4.73974 9.33335 4.85852 9.33335 5.00019C9.33335 5.14197 9.28541 5.26069 9.18952 5.35635C9.09374 5.45213 8.97502 5.50002 8.83335 5.50002H5.50002V8.83335C5.50002 8.97502 5.45208 9.09374 5.35619 9.18952C5.2603 9.28541 5.14152 9.33335 4.99985 9.33335C4.85808 9.33335 4.73935 9.28541 4.64369 9.18952C4.54791 9.09374 4.50002 8.97502 4.50002 8.83335V5.50002Z"
841
- fill="#888888"
841
+ fill="currentColor"
842
842
  />
843
843
  </svg>
844
844
  );
@@ -894,3 +894,63 @@ export const CrossBox = () => {
894
894
  </svg>
895
895
  );
896
896
  };
897
+
898
+ export const EyeIcon = () => {
899
+ return (
900
+ <svg
901
+ width="24"
902
+ height="24"
903
+ viewBox="0 0 16 16"
904
+ fill="none"
905
+ xmlns="http://www.w3.org/2000/svg"
906
+ >
907
+ <mask
908
+ id="mask0_6673_82208"
909
+ style={{ maskType: "alpha" }}
910
+ maskUnits="userSpaceOnUse"
911
+ x="0"
912
+ y="0"
913
+ width="16"
914
+ height="16"
915
+ >
916
+ <rect width="16" height="16" fill="#D9D9D9" />
917
+ </mask>
918
+ <g mask="url(#mask0_6673_82208)">
919
+ <path
920
+ d="M8.00147 10.3847C8.75692 10.3847 9.39853 10.1203 9.92631 9.5915C10.4541 9.06272 10.718 8.42061 10.718 7.66517C10.718 6.90972 10.4536 6.26811 9.9248 5.74033C9.39603 5.21256 8.75392 4.94867 7.99847 4.94867C7.24303 4.94867 6.60142 5.21306 6.07364 5.74183C5.54586 6.27061 5.28197 6.91272 5.28197 7.66817C5.28197 8.42361 5.54636 9.06522 6.07514 9.593C6.60392 10.1208 7.24603 10.3847 8.00147 10.3847ZM7.99997 9.46667C7.49997 9.46667 7.07497 9.29167 6.72497 8.94167C6.37497 8.59167 6.19997 8.16667 6.19997 7.66667C6.19997 7.16667 6.37497 6.74167 6.72497 6.39167C7.07497 6.04167 7.49997 5.86667 7.99997 5.86667C8.49997 5.86667 8.92497 6.04167 9.27497 6.39167C9.62497 6.74167 9.79997 7.16667 9.79997 7.66667C9.79997 8.16667 9.62497 8.59167 9.27497 8.94167C8.92497 9.29167 8.49997 9.46667 7.99997 9.46667ZM7.99997 12.3333C6.59653 12.3333 5.31297 11.9589 4.1493 11.2102C2.98564 10.4615 2.0568 9.4765 1.3628 8.25517C1.30725 8.15939 1.26664 8.06289 1.24097 7.96567C1.21541 7.86844 1.20264 7.76867 1.20264 7.66633C1.20264 7.564 1.21541 7.46433 1.24097 7.36733C1.26664 7.27033 1.30725 7.17394 1.3628 7.07817C2.0568 5.85683 2.98564 4.87183 4.1493 4.12317C5.31297 3.37439 6.59653 3 7.99997 3C9.40342 3 10.687 3.37439 11.8506 4.12317C13.0143 4.87183 13.9431 5.85683 14.6371 7.07817C14.6927 7.17394 14.7333 7.27044 14.759 7.36767C14.7845 7.46489 14.7973 7.56467 14.7973 7.667C14.7973 7.76933 14.7845 7.869 14.759 7.966C14.7333 8.063 14.6927 8.15939 14.6371 8.25517C13.9431 9.4765 13.0143 10.4615 11.8506 11.2102C10.687 11.9589 9.40342 12.3333 7.99997 12.3333ZM7.99997 11.3333C9.25553 11.3333 10.4083 11.0028 11.4583 10.3417C12.5083 9.68055 13.3111 8.78889 13.8666 7.66667C13.3111 6.54444 12.5083 5.65278 11.4583 4.99167C10.4083 4.33056 9.25553 4 7.99997 4C6.74442 4 5.59164 4.33056 4.54164 4.99167C3.49164 5.65278 2.68886 6.54444 2.1333 7.66667C2.68886 8.78889 3.49164 9.68055 4.54164 10.3417C5.59164 11.0028 6.74442 11.3333 7.99997 11.3333Z"
921
+ fill="#505050"
922
+ />
923
+ </g>
924
+ </svg>
925
+ );
926
+ };
927
+
928
+ export const ClosedEyeIcon = () => {
929
+ return (
930
+ <svg
931
+ width="24"
932
+ height="24"
933
+ viewBox="0 0 16 16"
934
+ fill="none"
935
+ xmlns="http://www.w3.org/2000/svg"
936
+ >
937
+ <mask
938
+ id="mask0_6673_82183"
939
+ style={{ maskType: "alpha" }}
940
+ maskUnits="userSpaceOnUse"
941
+ x="0"
942
+ y="0"
943
+ width="16"
944
+ height="16"
945
+ >
946
+ <rect width="16" height="16" fill="#D9D9D9" />
947
+ </mask>
948
+ <g mask="url(#mask0_6673_82183)">
949
+ <path
950
+ d="M9.91793 5.74876C10.1888 6.01976 10.3982 6.34903 10.5461 6.73659C10.694 7.12426 10.7499 7.51337 10.7139 7.90392C10.7139 8.03215 10.6678 8.1407 10.5756 8.22959C10.4833 8.31848 10.373 8.36292 10.2448 8.36292C10.1165 8.36292 10.008 8.31848 9.9191 8.22959C9.83021 8.1407 9.78576 8.03215 9.78576 7.90392C9.82854 7.61081 9.80443 7.33303 9.71343 7.07059C9.62243 6.80826 9.48248 6.58264 9.29359 6.39376C9.1047 6.20487 8.87693 6.06148 8.61026 5.96359C8.34359 5.8657 8.06237 5.84026 7.76659 5.88726C7.63837 5.89159 7.52771 5.84864 7.43459 5.75842C7.34137 5.66831 7.29265 5.55914 7.28843 5.43092C7.28409 5.3027 7.32532 5.19198 7.41209 5.09876C7.49887 5.00564 7.60637 4.95698 7.73459 4.95276C8.12259 4.90831 8.51254 4.95892 8.90443 5.10459C9.29632 5.25037 9.63415 5.46509 9.91793 5.74876ZM7.99993 4.00009C7.76315 4.00009 7.53087 4.01165 7.30309 4.03476C7.07532 4.05776 6.84859 4.09576 6.62293 4.14876C6.48104 4.17787 6.35326 4.15759 6.23959 4.08792C6.12593 4.01826 6.04776 3.91803 6.00509 3.78726C5.96232 3.65226 5.97643 3.52387 6.04743 3.40209C6.11832 3.28031 6.22126 3.20487 6.35626 3.17576C6.62471 3.11164 6.89587 3.06637 7.16976 3.03992C7.44376 3.01337 7.72048 3.00009 7.99993 3.00009C9.43237 3.00009 10.7482 3.37231 11.9474 4.11676C13.1465 4.8612 14.0687 5.86848 14.7139 7.13859C14.7584 7.22315 14.7907 7.30837 14.8108 7.39426C14.8309 7.48014 14.8409 7.57098 14.8409 7.66676C14.8409 7.76253 14.8326 7.85337 14.8159 7.93926C14.7993 8.02515 14.7687 8.11037 14.7243 8.19492C14.52 8.62226 14.2718 9.02076 13.9794 9.39042C13.6871 9.76009 13.3653 10.0996 13.0139 10.4091C12.9106 10.5014 12.7925 10.5396 12.6596 10.5238C12.5266 10.508 12.4174 10.4415 12.3319 10.3244C12.2465 10.2073 12.211 10.0817 12.2256 9.94759C12.2402 9.81337 12.2991 9.70009 12.4024 9.60776C12.7033 9.33509 12.9777 9.03703 13.2256 8.71359C13.4735 8.39003 13.6872 8.04109 13.8666 7.66676C13.311 6.54453 12.5083 5.65287 11.4583 4.99176C10.4083 4.33065 9.25548 4.00009 7.99993 4.00009ZM7.99993 12.3334C6.59648 12.3334 5.31015 11.9584 4.14093 11.2084C2.97171 10.4584 2.04226 9.47059 1.35259 8.24492C1.29704 8.16037 1.25643 8.06848 1.23076 7.96926C1.20509 7.87014 1.19226 7.76931 1.19226 7.66676C1.19226 7.5642 1.20337 7.46503 1.22559 7.36926C1.24782 7.27359 1.28671 7.18003 1.34226 7.08859C1.59015 6.63559 1.87093 6.20415 2.18459 5.79426C2.49826 5.38448 2.85893 5.0172 3.26659 4.69242L1.76143 3.17692C1.66921 3.07781 1.62371 2.96009 1.62493 2.82376C1.62626 2.68742 1.67521 2.57098 1.77176 2.47442C1.86832 2.37787 1.98543 2.32959 2.12309 2.32959C2.26065 2.32959 2.37771 2.37787 2.47426 2.47442L13.5256 13.5258C13.6179 13.6181 13.6669 13.7324 13.6724 13.8686C13.678 14.0049 13.629 14.1248 13.5256 14.2283C13.429 14.3248 13.3119 14.3731 13.1743 14.3731C13.0367 14.3731 12.9197 14.3248 12.8231 14.2283L10.4769 11.9026C10.0837 12.0547 9.67959 12.1645 9.2646 12.2321C8.84971 12.2996 8.42815 12.3334 7.99993 12.3334ZM3.96926 5.39492C3.57859 5.6967 3.22748 6.03792 2.91593 6.41859C2.60437 6.79937 2.34348 7.21542 2.13326 7.66676C2.68882 8.78898 3.49159 9.68064 4.54159 10.3418C5.59159 11.0029 6.74437 11.3334 7.99993 11.3334C8.28626 11.3334 8.56809 11.3142 8.84543 11.2758C9.12276 11.2373 9.3982 11.1779 9.67176 11.0976L8.82809 10.2334C8.69309 10.2924 8.55826 10.3324 8.42359 10.3533C8.28904 10.3743 8.14782 10.3848 7.99993 10.3848C7.24348 10.3848 6.60137 10.1209 6.07359 9.59309C5.54582 9.06531 5.28193 8.4232 5.28193 7.66676C5.28193 7.51887 5.29348 7.37765 5.31659 7.24309C5.33971 7.10842 5.37859 6.97359 5.43326 6.83859L3.96926 5.39492Z"
951
+ fill="#C5C5C5"
952
+ />
953
+ </g>
954
+ </svg>
955
+ );
956
+ };
@@ -0,0 +1,20 @@
1
+ import { Box, CircularProgress, Typography } from "@mui/material";
2
+
3
+ const Loader = ({ loaderText }: { loaderText?: string }) => {
4
+ return (
5
+ <Box
6
+ display={"flex"}
7
+ justifyContent="center"
8
+ alignItems={"center"}
9
+ flexDirection={"column"}
10
+ gap={2}
11
+ height={"100%"}
12
+ width={"100%"}
13
+ >
14
+ <CircularProgress />
15
+ {loaderText && <Typography variant="h6">{loaderText}</Typography>}
16
+ </Box>
17
+ );
18
+ };
19
+
20
+ export default Loader;
@@ -42,22 +42,23 @@ const DraggableListItem = ({
42
42
  ref={setNodeRef}
43
43
  style={style}
44
44
  {...attributes}
45
- {...listeners}
46
45
  sx={{
47
46
  display: "flex",
48
47
  alignItems: "center",
49
48
  justifyContent: "space-between",
50
- py: 1,
51
- px: 1,
52
49
  "&:hover": { bgcolor: "#f5f5f5" },
53
50
  borderRadius: 1,
54
51
  marginBottom: 1,
55
- backgroundColor: "white",
56
- cursor: isDragging ? "grabbing" : "grab",
52
+ cursor: isDragging ? "grabbing" : "default",
57
53
  boxShadow: isDragging ? "0 2px 8px rgba(0,0,0,0.1)" : "none",
58
54
  }}
59
55
  >
60
- <DragIndicator sx={{ mr: 1, color: "#ccc" }} />
56
+ <Box
57
+ {...listeners}
58
+ sx={{ cursor: "grab", display: "flex", alignItems: "center" }}
59
+ >
60
+ <DragIndicator sx={{ mr: 1, color: "#ccc" }} />
61
+ </Box>
61
62
  {children}
62
63
  </Box>
63
64
  );
@@ -1,12 +1,4 @@
1
- import { Visibility, VisibilityOff } from "@mui/icons-material";
2
- import {
3
- Box,
4
- Button,
5
- CircularProgress,
6
- Grid,
7
- IconButton,
8
- Typography,
9
- } from "@mui/material";
1
+ import { Box, Button, Grid, IconButton, Typography } from "@mui/material";
10
2
  import CustomSearch from "../../filter/components/search/index.tsx";
11
3
  import {
12
4
  SortableContext,
@@ -15,6 +7,9 @@ import {
15
7
  import { useDroppable } from "@dnd-kit/core";
16
8
  import DraggableListItem from "./draggable-listitem.tsx";
17
9
  import { listingValuesStyles } from "../style.ts";
10
+ import Loader from "../../common/loader/loader.tsx";
11
+ import { ClosedEyeIcon, EyeIcon } from "../../../assets/svg.tsx";
12
+ ``;
18
13
 
19
14
  interface FilterValue {
20
15
  id: string;
@@ -30,6 +25,7 @@ interface ListingValuesProps {
30
25
  setSearchTerm?: React.Dispatch<React.SetStateAction<string>>;
31
26
  containerId: string;
32
27
  tabsApiDataLoading?: boolean;
28
+ onItemToggle: (itemId: string, fromContainerId: string) => void;
33
29
  }
34
30
 
35
31
  const ListingValues = ({
@@ -41,6 +37,7 @@ const ListingValues = ({
41
37
  setSearchTerm,
42
38
  containerId,
43
39
  tabsApiDataLoading,
40
+ onItemToggle,
44
41
  }: ListingValuesProps) => {
45
42
  const { setNodeRef } = useDroppable({
46
43
  id: containerId,
@@ -53,14 +50,7 @@ const ListingValues = ({
53
50
  return (
54
51
  <Grid size={6} sx={listingValuesStyles.wrapper}>
55
52
  {tabsApiDataLoading ? (
56
- <Box
57
- display={"flex"}
58
- justifyContent="center"
59
- alignItems={"center"}
60
- height={"100%"}
61
- >
62
- <CircularProgress />
63
- </Box>
53
+ <Loader />
64
54
  ) : (
65
55
  <Box sx={{ p: 2 }}>
66
56
  <Box sx={listingValuesStyles.headerContainer}>
@@ -72,6 +62,7 @@ const ListingValues = ({
72
62
  variant="text"
73
63
  size="small"
74
64
  sx={listingValuesStyles.button}
65
+ disabled={filteredValues.length === 0}
75
66
  >
76
67
  {buttonText}
77
68
  </Button>
@@ -93,15 +84,23 @@ const ListingValues = ({
93
84
  id={item.id}
94
85
  containerId={containerId}
95
86
  >
96
- <Box sx={listingValuesStyles.itemLabel}>
87
+ <Box
88
+ sx={{
89
+ display: "flex",
90
+ alignItems: "center",
91
+ flex: 1,
92
+ color: containerId === "tabs" ? "black" : "#9e9d9b",
93
+ }}
94
+ >
97
95
  <Typography>{item.label}</Typography>
98
96
  </Box>
99
- <IconButton size="small">
100
- {containerId === "tabs" ? (
101
- <Visibility />
102
- ) : (
103
- <VisibilityOff />
104
- )}
97
+
98
+ {/* on click i want to append this item in the show list and remove it from the hide list */}
99
+ <IconButton
100
+ size="small"
101
+ onClick={() => onItemToggle(item.id, containerId)}
102
+ >
103
+ {containerId === "tabs" ? <EyeIcon /> : <ClosedEyeIcon />}
105
104
  </IconButton>
106
105
  </DraggableListItem>
107
106
  ))}
@@ -39,16 +39,25 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
39
39
  const [searchTerm, setSearchTerm] = useState<string>("");
40
40
  const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
41
41
 
42
- const { quickTabStates, columnTabState, setColumnTabState } =
42
+ const { quickTabStates, columnTabState, setColumnTabState, settingsData } =
43
43
  filterSettingStates;
44
44
 
45
45
  useEffect(() => {
46
+ const mappedColumns: ColumnItem[] =
47
+ columnsData?.column_list?.map((column) => ({
48
+ label: column?.name,
49
+ value: column?.attribute_key,
50
+ })) || [];
51
+ //Later changed TabData to interface from filter settings types file
52
+ const mappedTabs: TabData[] =
53
+ quickTabStates?.show_list?.map((tab) => ({
54
+ tab_name: tab,
55
+ show_list: mappedColumns,
56
+ hide_list: [],
57
+ })) || [];
58
+
46
59
  if (!Object.entries(columnTabState)?.length) {
47
- const mappedColumns: ColumnItem[] =
48
- columnsData?.column_list?.map((column) => ({
49
- label: column?.name,
50
- value: column?.attribute_key,
51
- })) || [];
60
+ console.log("hello:", Object.entries(columnTabState)?.length);
52
61
 
53
62
  console.log("mappedColumnsssss", mappedColumns);
54
63
 
@@ -56,16 +65,41 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
56
65
  isDefault: true,
57
66
  show_list: mappedColumns,
58
67
  hide_list: [],
59
- tabs: quickTabStates?.show_list?.map((tab) => ({
60
- tab_name: tab,
61
- show_list: mappedColumns,
62
- hide_list: [],
63
- })),
68
+ tabs: mappedTabs,
64
69
  };
65
70
 
66
71
  setColumnTabState(newColumnState);
67
72
  }
68
- }, []);
73
+
74
+ // console.log(
75
+ // "+++++++++",
76
+ // columnTabState?.tabs,
77
+ // !settingsData?.column?.tabs?.length
78
+ // );
79
+
80
+ /**
81
+ * * If isDefault is true and tabs is undefined
82
+ * * - we need to set tabs
83
+ *
84
+ * * If isDefault is false and show_list and hide_list are undefined
85
+ * * - we need to set show_list and hide_list
86
+ */
87
+ if (
88
+ columnTabState?.tabs?.length === undefined &&
89
+ !settingsData?.column?.tabs?.length
90
+ ) {
91
+ setColumnTabState((prev) => ({
92
+ ...prev,
93
+ tabs: mappedTabs,
94
+ }));
95
+ } else if (!columnTabState?.show_list && !columnTabState?.hide_list) {
96
+ setColumnTabState((prev) => ({
97
+ ...prev,
98
+ show_list: mappedColumns,
99
+ hide_list: [],
100
+ }));
101
+ }
102
+ }, []); // might need settingsData dependancy if logic is working inconsistently
69
103
 
70
104
  // useEffect(() => {
71
105
  // if (settingsData?.column) {
@@ -154,6 +188,29 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
154
188
  value.label.toLowerCase().includes(searchTerm.toLowerCase())
155
189
  );
156
190
 
191
+ const handleItemToggle = (itemId: string, fromContainerId: string) => {
192
+ let newShowList = [...showList];
193
+ let newHideList = [...hideList];
194
+
195
+ if (fromContainerId === "tabs") {
196
+ // Move from show to hide
197
+ const itemIndex = newShowList.findIndex((item) => item.value === itemId);
198
+ if (itemIndex > -1) {
199
+ const [itemToMove] = newShowList.splice(itemIndex, 1);
200
+ newHideList.push(itemToMove);
201
+ }
202
+ } else if (fromContainerId === "list") {
203
+ // Move from hide to show
204
+ const itemIndex = newHideList.findIndex((item) => item.value === itemId);
205
+ if (itemIndex > -1) {
206
+ const [itemToMove] = newHideList.splice(itemIndex, 1);
207
+ newShowList.push(itemToMove);
208
+ }
209
+ }
210
+
211
+ updateLists(newShowList, newHideList);
212
+ };
213
+
157
214
  // Update lists based on current mode
158
215
  const updateLists = (
159
216
  newShowList: ColumnItem[],
@@ -267,38 +324,39 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
267
324
  setSelectedTabIndex(newValue);
268
325
  };
269
326
 
327
+ const hasShowListQuickTabs =
328
+ quickTabStates?.show_list?.length !== 0 || isColumnDefault ? true : false;
329
+
270
330
  return (
271
- <Box sx={{ maxHeight: "600px" }}>
272
- <Box sx={{ maxHeight: "500px", borderRadius: 1, bgcolor: "white" }}>
273
- <Grid container spacing={2}>
274
- <Grid size={12}>
275
- <Box sx={{ mb: 2 }}>
276
- <Typography
277
- variant="subtitle2"
278
- sx={{ mb: 1, fontWeight: 500, color: "#0E0C0BE5" }}
279
- >
280
- Customize column by
281
- </Typography>
282
- <CustomToggleSwitchButton
283
- buttons={TOGGLE_BUTTON_TABS}
284
- value={isColumnDefault}
285
- onChange={handleToggleChange}
286
- />
287
- </Box>
288
- </Grid>
289
-
290
- {!isColumnDefault && (
291
- <Grid size={12}>
292
- <Box sx={{ borderBottom: 1, borderColor: "divider", mb: 2 }}>
293
- <CustomTabs value={selectedTabIndex} onChange={handleTabChange}>
294
- {quickTabStates?.show_list?.map((tab) => (
295
- <Tab key={tab} label={tab} />
296
- ))}
297
- </CustomTabs>
298
- </Box>
299
- </Grid>
300
- )}
331
+ <Box
332
+ sx={{
333
+ display: "flex",
334
+ flexDirection: "column",
335
+ gap: "0.75rem",
336
+ height: "100%",
337
+ }}
338
+ >
339
+ <Box>
340
+ <Typography variant="subtitle2" sx={{ mb: 1 }}>
341
+ Customize column by
342
+ </Typography>
343
+ <CustomToggleSwitchButton
344
+ buttons={TOGGLE_BUTTON_TABS}
345
+ value={isColumnDefault}
346
+ onChange={handleToggleChange}
347
+ />
348
+ </Box>
301
349
 
350
+ <Box sx={{ flex: 1 }}>
351
+ {!isColumnDefault && hasShowListQuickTabs && (
352
+ <CustomTabs value={selectedTabIndex} onChange={handleTabChange}>
353
+ {quickTabStates?.show_list?.map((tab) => (
354
+ <Tab key={tab} label={tab} />
355
+ ))}
356
+ </CustomTabs>
357
+ )}
358
+
359
+ {hasShowListQuickTabs ? (
302
360
  <DndContext
303
361
  sensors={sensors}
304
362
  collisionDetection={closestCenter}
@@ -306,24 +364,28 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
306
364
  >
307
365
  <Grid container spacing={2} size={12}>
308
366
  <ListingValues
367
+ containerId="list"
368
+ headerText="Hidden In List"
369
+ filteredValues={filteredListValues}
309
370
  buttonText="Show All"
310
371
  onClick={handleShowAll}
311
- headerText="Hidden in List"
312
- filteredValues={filteredListValues}
313
372
  searchTerm={searchTerm}
314
373
  setSearchTerm={setSearchTerm}
315
- containerId="list"
374
+ onItemToggle={handleItemToggle}
316
375
  />
317
376
  <ListingValues
377
+ containerId="tabs"
378
+ headerText="Show In List"
379
+ filteredValues={showListValues}
318
380
  buttonText="Hide All"
319
381
  onClick={handleHideAll}
320
- headerText="Shown in List"
321
- filteredValues={showListValues}
322
- containerId="tabs"
382
+ onItemToggle={handleItemToggle}
323
383
  />
324
384
  </Grid>
325
385
  </DndContext>
326
- </Grid>
386
+ ) : (
387
+ <Typography>View as Tabs empty in Quick Tab</Typography>
388
+ )}
327
389
  </Box>
328
390
  </Box>
329
391
  );