debug refactor table and passing parameters to dataTable_paper
This commit is contained in:
@@ -11,7 +11,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
() => [
|
||||
{
|
||||
accessorKey: "dabirkhaneh_number",
|
||||
header: "dabirkhaneh_number",
|
||||
header: "شماره دبیرخانه درخواست",
|
||||
id: "dabirkhaneh_number",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -20,7 +20,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "marjae_pasokh",
|
||||
header: "marjae_pasokh",
|
||||
header: "مرجع درخواست کننده پاسخ به استعلام",
|
||||
id: "marjae_pasokh",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -29,7 +29,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "motaghazi_is_legal",
|
||||
header: "motaghazi_is_legal",
|
||||
header: "متقاضی",
|
||||
id: "motaghazi_is_legal",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -38,7 +38,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "nameh_date",
|
||||
header: "nameh_date",
|
||||
header: "تاریخ نامه درخواست",
|
||||
id: "nameh_date",
|
||||
enableColumnFilter: false,
|
||||
datatype: "date",
|
||||
@@ -46,7 +46,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "motaghazi_type",
|
||||
header: "motaghazi_type",
|
||||
header: "نوع متقاضی",
|
||||
id: "motaghazi_type",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -55,7 +55,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "motaghazi_firstname",
|
||||
header: "motaghazi_firstname",
|
||||
header: "نام متقاضی",
|
||||
id: "motaghazi_firstname",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -64,7 +64,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "motaghazi_lastname",
|
||||
header: "motaghazi_lastname",
|
||||
header: "نام خانوادگی متقاضی",
|
||||
id: "motaghazi_lastname",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -73,25 +73,16 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "national_id",
|
||||
header: "national_id",
|
||||
header: "کد ملی/شناسه ملی",
|
||||
id: "national_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["equals", "notEquals", "contains"],
|
||||
},
|
||||
{
|
||||
accessorKey: "shenase_melli",
|
||||
header: "shenase_melli",
|
||||
id: "shenase_melli",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["equals", "notEquals", "contains"],
|
||||
},
|
||||
{
|
||||
accessorKey: "tel_number",
|
||||
header: "tel_number",
|
||||
header: "تلفن",
|
||||
id: "tel_number",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -100,7 +91,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "mobile_number",
|
||||
header: "mobile_number",
|
||||
header: "تلفن همراه",
|
||||
id: "mobile_number",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -109,7 +100,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "address",
|
||||
header: "address",
|
||||
header: "آدرس",
|
||||
id: "address",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -118,7 +109,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "edare_kol",
|
||||
header: "edare_kol",
|
||||
header: "اداره كل راهداری",
|
||||
id: "edare_kol",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -127,7 +118,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "edare_shahri",
|
||||
header: "edare_shahri",
|
||||
header: "اداره شهرستان",
|
||||
id: "edare_shahri",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -136,7 +127,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "rah_type",
|
||||
header: "rah_type",
|
||||
header: "نوع راه",
|
||||
id: "rah_type",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -145,7 +136,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "name_mehvar_fa",
|
||||
header: "name_mehvar_fa",
|
||||
header: "نام محور",
|
||||
id: "name_mehvar_fa",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -154,7 +145,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "mizan_harim",
|
||||
header: "mizan_harim",
|
||||
header: "میزان حریم",
|
||||
id: "mizan_harim",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -163,7 +154,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "arze_navar",
|
||||
header: "arze_navar",
|
||||
header: "عرض نوار تاسیساتی زیربنایی",
|
||||
id: "arze_navar",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -172,7 +163,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "samt",
|
||||
header: "samt",
|
||||
header: "سمت",
|
||||
id: "samt",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -181,7 +172,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "kilometr",
|
||||
header: "kilometr",
|
||||
header: "كيلومتر",
|
||||
id: "kilometr",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -199,7 +190,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "karbari_type",
|
||||
header: "karbari_type",
|
||||
header: "نوع کاربری",
|
||||
id: "karbari_type",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -208,7 +199,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "tarh_title",
|
||||
header: "tarh_title",
|
||||
header: "عنوان طرح",
|
||||
id: "tarh_title",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -217,7 +208,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "masahat_zirbana",
|
||||
header: "masahat_zirbana",
|
||||
header: "مساحت زیربنا",
|
||||
id: "masahat_zirbana",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -226,7 +217,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "ehdasat_type",
|
||||
header: "ehdasat_type",
|
||||
header: "نوع احداثات",
|
||||
id: "ehdasat_type",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -235,7 +226,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "divarkeshi_distance",
|
||||
header: "divarkeshi_distance",
|
||||
header: "فاصله دیوارکشی از آکس محور",
|
||||
id: "divarkeshi_distance",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -244,7 +235,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "mahale_ejra",
|
||||
header: "mahale_ejra",
|
||||
header: "محل اجرا",
|
||||
id: "mahale_ejra",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -253,7 +244,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "traffic",
|
||||
header: "traffic",
|
||||
header: "میزان ترافیک",
|
||||
id: "traffic",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -262,7 +253,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "vaziat_eghtesadi",
|
||||
header: "vaziat_eghtesadi",
|
||||
header: "وضعیت اقتصادی",
|
||||
id: "vaziat_eghtesadi",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -271,7 +262,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "has_access",
|
||||
header: "has_access",
|
||||
header: "آیا راه دسترسی از قبل وجود دارد؟",
|
||||
id: "has_access",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -280,7 +271,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "shomare_estelam_harim",
|
||||
header: "shomare_estelam_harim",
|
||||
header: "شماره استعلام دفتر ایمنی و حریم",
|
||||
id: "shomare_estelam_harim",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -289,7 +280,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "max_month",
|
||||
header: "max_month",
|
||||
header: "ماه",
|
||||
id: "max_month",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -298,7 +289,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "max_day",
|
||||
header: "max_day",
|
||||
header: "روز",
|
||||
id: "max_day",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -307,7 +298,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "shomare_tahaodname",
|
||||
header: "shomare_tahaodname",
|
||||
header: "شماره تعهدنامه",
|
||||
id: "shomare_tahaodname",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -316,7 +307,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "shomare_daftarkhaneh",
|
||||
header: "shomare_daftarkhaneh",
|
||||
header: "شماره دفترخانه",
|
||||
id: "shomare_daftarkhaneh",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -325,7 +316,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "description",
|
||||
header: "description",
|
||||
header: "توضیحات",
|
||||
id: "description",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -334,7 +325,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "ronevesht",
|
||||
header: "ronevesht",
|
||||
header: "رونوشت",
|
||||
id: "ronevesht",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
@@ -348,7 +339,7 @@ const InquiryPrivacyFencingPage = () => {
|
||||
return (
|
||||
<Box sx={{ mx: 2 }}>
|
||||
<DataTable
|
||||
need_filter={"false"}
|
||||
need_filter={false}
|
||||
columns={columns}
|
||||
table_url={GET_INQUIRY_PRIVACY_FENCING_ROUTE}
|
||||
user_id={0}
|
||||
|
||||
@@ -106,8 +106,10 @@ const DataTable_Main = (props) => {
|
||||
|
||||
return (
|
||||
<DataTable_Paper
|
||||
need_filter={need_filter}
|
||||
table={table}
|
||||
need_filter={need_filter}
|
||||
mutate={mutate}
|
||||
table_url={table_url}
|
||||
columns={flatColumns}
|
||||
user_id={user_id}
|
||||
page_name={page_name}
|
||||
|
||||
@@ -214,6 +214,7 @@ const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex,
|
||||
minWidth: `${Math.min(columnDef.header?.length ?? 0, 4)}ch`,
|
||||
overflow: columnDefType === "data" ? "hidden" : undefined,
|
||||
textOverflow: "ellipsis",
|
||||
textAlign: "start",
|
||||
color: "#fff",
|
||||
fontWeight: "400",
|
||||
whiteSpace: (columnDef.header?.length ?? 0) < 20 ? "nowrap" : "normal",
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
"use client";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import RestartAltIcon from "@mui/icons-material/RestartAlt";
|
||||
import useTableSetting from "@/lib/hooks/useTableSetting";
|
||||
import { useState } from "react";
|
||||
|
||||
function RefactorTable() {
|
||||
const { refactorAction } = useTableSetting();
|
||||
const [userId, setUserId] = useState(0);
|
||||
const [pageName, setPageName] = useState("testPage");
|
||||
const [tableName, setTableName] = useState("testTable");
|
||||
|
||||
function RefactorTable({ mutate }) {
|
||||
const refactor = () => {
|
||||
refactorAction(userId, pageName, tableName);
|
||||
mutate();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,7 +4,17 @@ import DataTable_BottomToolbar from "../toolbar/BottomToolbar";
|
||||
import DataTable_TopToolbar from "../toolbar/TopToolbar";
|
||||
import DataTable_TableContainer from "./TableContainer";
|
||||
|
||||
const DataTable_Paper = ({ table, ...rest }) => {
|
||||
const DataTable_Paper = ({
|
||||
table,
|
||||
table_name,
|
||||
columns,
|
||||
user_id,
|
||||
page_name,
|
||||
mutate,
|
||||
need_filter,
|
||||
table_url,
|
||||
...rest
|
||||
}) => {
|
||||
const {
|
||||
getState,
|
||||
options: {
|
||||
@@ -66,13 +76,14 @@ const DataTable_Paper = ({ table, ...rest }) => {
|
||||
{enableTopToolbar &&
|
||||
(parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (
|
||||
<DataTable_TopToolbar
|
||||
need_filter={paperProps.need_filter}
|
||||
need_filter={need_filter}
|
||||
table={table}
|
||||
columns={paperProps.columns}
|
||||
table_url={paperProps.table_url}
|
||||
user_id={paperProps.user_id}
|
||||
page_name={paperProps.page_name}
|
||||
table_name={paperProps.table_name}
|
||||
mutate={mutate}
|
||||
columns={columns}
|
||||
table_url={table_url}
|
||||
user_id={user_id}
|
||||
page_name={page_name}
|
||||
table_name={table_name}
|
||||
/>
|
||||
))}
|
||||
<DataTable_TableContainer table={table} />
|
||||
|
||||
@@ -6,7 +6,7 @@ import DataTable_ToolbarInternalButtons from "./ToolbarInternalButtons";
|
||||
import FilterColumn from "@/core/components/DataTable/filter";
|
||||
import RefactorTable from "@/core/components/DataTable/refactor/RefactorTable";
|
||||
|
||||
const DataTable_TopToolbar = ({ need_filter, table, columns, table_url, user_id, page_name, table_name }) => {
|
||||
const DataTable_TopToolbar = ({ mutate, need_filter, table, columns, table_url, user_id, page_name, table_name }) => {
|
||||
const {
|
||||
getState,
|
||||
options: {
|
||||
@@ -69,8 +69,8 @@ const DataTable_TopToolbar = ({ need_filter, table, columns, table_url, user_id,
|
||||
justifyContent: "flex-end",
|
||||
}}
|
||||
>
|
||||
<RefactorTable />
|
||||
{need_filter === "true" && (
|
||||
<RefactorTable mutate={mutate} />
|
||||
{need_filter && (
|
||||
<FilterColumn
|
||||
columns={columns}
|
||||
table_url={table_url}
|
||||
|
||||
@@ -55,23 +55,7 @@ export const TableSettingProvider = ({ children }) => {
|
||||
localStorage.setItem("_setting-app", JSON.stringify(updatedLocalStorage));
|
||||
setSettingStore(updatedLocalStorage);
|
||||
};
|
||||
const refactorAction = (user_id, page_name, table_name) => {
|
||||
const prevLocalStorage = JSON.parse(localStorage.getItem("_setting-app")) || {};
|
||||
const userSettings = prevLocalStorage[user_id] || {};
|
||||
const pageSettings = userSettings[page_name] || {};
|
||||
const refactorData = {
|
||||
...prevLocalStorage,
|
||||
[user_id]: {
|
||||
...userSettings,
|
||||
[page_name]: {
|
||||
...pageSettings,
|
||||
[table_name]: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
localStorage.setItem("_setting-app", JSON.stringify(refactorData));
|
||||
setSettingStore(refactorData);
|
||||
};
|
||||
|
||||
const SummaryTextMessage = (values, columns) => {
|
||||
let SummaryText = "";
|
||||
let HideText = "";
|
||||
@@ -133,7 +117,7 @@ export const TableSettingProvider = ({ children }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<TableSettingContext.Provider value={{ settingStore, hideAction, sortAction, filterAction, refactorAction }}>
|
||||
<TableSettingContext.Provider value={{ settingStore, hideAction, sortAction, filterAction }}>
|
||||
{children}
|
||||
</TableSettingContext.Provider>
|
||||
);
|
||||
|
||||
@@ -2,8 +2,8 @@ import { useContext } from "react";
|
||||
import { TableSettingContext } from "../contexts/tableSetting";
|
||||
|
||||
const useTableSetting = () => {
|
||||
const { settingStore, hideAction, sortAction, filterAction, refactorAction } = useContext(TableSettingContext);
|
||||
return { settingStore, hideAction, sortAction, filterAction, refactorAction };
|
||||
const { settingStore, hideAction, sortAction, filterAction } = useContext(TableSettingContext);
|
||||
return { settingStore, hideAction, sortAction, filterAction };
|
||||
};
|
||||
|
||||
export default useTableSetting;
|
||||
|
||||
Reference in New Issue
Block a user