-
-
-
-
-
-
- {(column) => (
- {column.name}
- )}
-
-
- {(item) => (
-
- {(columnKey) => (
- {renderCell(item, columnKey)}
- )}
-
- )}
-
-
-
+ case "status":
+ return (
+
+
+ {cellValue}
+
+ );
- >
- );
+ case "actions":
+ return (
+
+
+
+
+
+
+
+
+
+ Detail
+
+
+
+
+
+ Edit
+
+
+
+
+
+ Delete
+
+
+
+
+
+ );
+
+ default:
+ return cellValue;
+ }
+ }, []);
+
+ return (
+ <>
+
+
+
+
+
+
+
+ {(column) => (
+ {column.name}
+ )}
+
+
+ {(item) => (
+
+ {(columnKey) => (
+ {renderCell(item, columnKey)}
+ )}
+
+ )}
+
+
+
+
+ >
+ );
}
diff --git a/components/table/master/master-module/master-module-table.tsx b/components/table/master/master-module/master-module-table.tsx
index 3bad23b..80257ad 100644
--- a/components/table/master/master-module/master-module-table.tsx
+++ b/components/table/master/master-module/master-module-table.tsx
@@ -1,224 +1,214 @@
"use client";
import {
- TableCell,
- TableRow,
- Table,
- TableHeader,
- TableColumn,
- TableBody,
- Pagination,
- Dropdown,
- DropdownTrigger,
- DropdownMenu,
- DropdownItem,
- Input,
- User,
- Card,
- Divider,
- Chip,
- ChipProps,
+ TableCell,
+ TableRow,
+ Table,
+ TableHeader,
+ TableColumn,
+ TableBody,
+ Pagination,
+ Dropdown,
+ DropdownTrigger,
+ DropdownMenu,
+ DropdownItem,
+ Input,
+ User,
+ Card,
+ Divider,
+ Chip,
+ ChipProps,
} from "@nextui-org/react";
import { Button } from "@nextui-org/button";
import React, { Key, useCallback, useMemo, useState } from "react";
import {
- AddIcon,
- CreateIconIon,
- DeleteIcon,
- DotsYIcon,
- EyeFilledIcon,
- EyeIconMdi,
+ AddIcon,
+ CreateIconIon,
+ DeleteIcon,
+ DotsYIcon,
+ EyeFilledIcon,
+ EyeIconMdi,
} from "@/components/icons";
import Link from "next/link";
type UserObject = {
- id: number;
- name: string;
- status: string;
- description: string;
- pathUrl: string;
+ id: number;
+ name: string;
+ status: string;
+ description: string;
+ pathUrl: string;
};
const statusColorMap = {
- active: "success",
- paused: "danger",
- vacation: "warning",
+ active: "success",
+ paused: "danger",
+ vacation: "warning",
};
-
export default function MasterModuleTable() {
- type TableRow = (typeof masterModuleTable)[0];
+ type TableRow = (typeof masterModuleTable)[0];
- const columns = [
- { name: "No", uid: "no" },
- { name: "Name", uid: "name" },
- { name: "Description", uid: "description" },
- { name: "Path URL", uid: "pathUrl" },
- { name: "Status", uid: "status" },
- { name: "Action", uid: "actions" },
- ];
+ const columns = [
+ { name: "No", uid: "no" },
+ { name: "Name", uid: "name" },
+ { name: "Description", uid: "description" },
+ { name: "Path URL", uid: "pathUrl" },
+ { name: "Status", uid: "status" },
+ { name: "Action", uid: "actions" },
+ ];
- const masterModuleTable = [
- {
- id: 1,
- name: "AI Journalist ",
- status: "active",
- description: "AI Journalist",
- pathUrl: "/admin/acts",
- },
- {
- id: 2,
- name: "AI Journalist ",
- status: "active",
- description: "AI Journalist",
- pathUrl: "/admin/acts",
- },
- {
- id: 3,
- name: "AI Journalist ",
- status: "active",
- description: "AI Journalist",
- pathUrl: "/admin/acts",
- },
- {
- id: 4,
- name: "AI Journalist ",
- status: "active",
- description: "AI Journalist",
- pathUrl: "/admin/acts",
- },
- {
- id: 5,
- name: "AI Journalist ",
- status: "active",
- description: "AI Journalist",
- pathUrl: "/admin/acts",
- },
- ];
+ const masterModuleTable = [
+ {
+ id: 1,
+ name: "AI Journalist ",
+ status: "active",
+ description: "AI Journalist",
+ pathUrl: "/admin/acts",
+ },
+ {
+ id: 2,
+ name: "AI Journalist ",
+ status: "active",
+ description: "AI Journalist",
+ pathUrl: "/admin/acts",
+ },
+ {
+ id: 3,
+ name: "AI Journalist ",
+ status: "active",
+ description: "AI Journalist",
+ pathUrl: "/admin/acts",
+ },
+ {
+ id: 4,
+ name: "AI Journalist ",
+ status: "active",
+ description: "AI Journalist",
+ pathUrl: "/admin/acts",
+ },
+ {
+ id: 5,
+ name: "AI Journalist ",
+ status: "active",
+ description: "AI Journalist",
+ pathUrl: "/admin/acts",
+ },
+ ];
- const renderCell = useCallback((masterModule: TableRow, columnKey: Key) => {
- const cellValue = masterModule[columnKey as keyof UserObject];
- const statusColorMap: Record
= {
- active: "success",
- cancel: "danger",
- pending: "warning",
- };
+ const renderCell = useCallback((masterModule: TableRow, columnKey: Key) => {
+ const cellValue = masterModule[columnKey as keyof UserObject];
+ const statusColorMap: Record = {
+ active: "success",
+ cancel: "danger",
+ pending: "warning",
+ };
- switch (columnKey) {
- case "no":
- return (
- {masterModule.id}
- )
+ switch (columnKey) {
+ case "no":
+ return {masterModule.id}
;
- case "name":
- return (
- {masterModule.name}
- )
+ case "name":
+ return {masterModule.name}
;
- case "description":
- return (
- {masterModule.description}
- )
+ case "description":
+ return {masterModule.description}
;
- case "status":
- return (
-
-
- {cellValue}
-
-
- );
-
- case "actions":
- return (
-
-
-
-
-
-
-
-
-
- Detail
-
-
-
-
-
- Edit
-
-
-
-
-
- Delete
-
-
-
-
-
- );
-
- default:
- return cellValue;
- }
- }, []);
-
- return (
- <>
-
-
-
-
-
-
-
- {(column) => (
- {column.name}
- )}
-
-
- {(item) => (
-
- {(columnKey) => (
- {renderCell(item, columnKey)}
- )}
-
- )}
-
-
-
+ case "status":
+ return (
+
+
+ {cellValue}
+
+ );
- >
- );
+ case "actions":
+ return (
+
+
+
+
+
+
+
+
+
+ Detail
+
+
+
+
+
+ Edit
+
+
+
+
+
+ Delete
+
+
+
+
+
+ );
+
+ default:
+ return cellValue;
+ }
+ }, []);
+
+ return (
+ <>
+
+
+
+
+
+
+
+ {(column) => (
+ {column.name}
+ )}
+
+
+ {(item) => (
+
+ {(columnKey) => (
+ {renderCell(item, columnKey)}
+ )}
+
+ )}
+
+
+
+
+ >
+ );
}
diff --git a/components/table/master/master-user-level/master-user-level-table.tsx b/components/table/master/master-user-level/master-user-level-table.tsx
index fa5b6f1..944d56c 100644
--- a/components/table/master/master-user-level/master-user-level-table.tsx
+++ b/components/table/master/master-user-level/master-user-level-table.tsx
@@ -1,241 +1,233 @@
"use client";
import {
- TableCell,
- TableRow,
- Table,
- TableHeader,
- TableColumn,
- TableBody,
- Pagination,
- Dropdown,
- DropdownTrigger,
- DropdownMenu,
- DropdownItem,
- Input,
- User,
- Card,
- Divider,
- Chip,
- ChipProps,
+ TableCell,
+ TableRow,
+ Table,
+ TableHeader,
+ TableColumn,
+ TableBody,
+ Pagination,
+ Dropdown,
+ DropdownTrigger,
+ DropdownMenu,
+ DropdownItem,
+ Input,
+ User,
+ Card,
+ Divider,
+ Chip,
+ ChipProps,
} from "@nextui-org/react";
import { Button } from "@nextui-org/button";
import React, { Key, useCallback, useEffect, useMemo, useState } from "react";
import {
- AddIcon,
- CreateIconIon,
- DeleteIcon,
- DotsYIcon,
- EyeFilledIcon,
- EyeIconMdi,
+ AddIcon,
+ CreateIconIon,
+ DeleteIcon,
+ DotsYIcon,
+ EyeFilledIcon,
+ EyeIconMdi,
} from "@/components/icons";
import Link from "next/link";
import { getAllUserLevels } from "@/services/user-levels/user-levels-service";
type UserObject = {
- id: number;
- name: string;
- levelNumber: string;
- aliasName: string;
- parentLevelId: string;
- provinceId: string;
- status: string;
+ id: number;
+ name: string;
+ levelNumber: string;
+ aliasName: string;
+ parentLevelId: string;
+ provinceId: string;
+ status: string;
};
const statusColorMap = {
- active: "success",
- paused: "danger",
- vacation: "warning",
+ active: "success",
+ paused: "danger",
+ vacation: "warning",
};
-
export default function MasterUserLevelTable() {
- const [totalPage, setTotalPage] = useState(1);
- const [masterUserLevelTable, setmasterUserLevel] = useState
([]);
+ const [totalPage, setTotalPage] = useState(1);
+ const [masterUserLevelTable, setmasterUserLevel] = useState([]);
- type TableRow = (typeof masterUserLevelTable)[0];
+ type TableRow = (typeof masterUserLevelTable)[0];
- const columns = [
- { name: "No", uid: "no" },
- { name: "Name", uid: "name" },
- { name: "User Name", uid: "alias_name" },
- { name: "Level Number", uid: "level_number" },
- { name: "Parent Level", uid: "parent_level_id" },
- { name: "Province", uid: "province_id" },
- { name: "Status", uid: "is_active" },
- { name: "Action", uid: "actions" },
- ];
+ const columns = [
+ { name: "No", uid: "no" },
+ { name: "Name", uid: "name" },
+ { name: "User Name", uid: "alias_name" },
+ { name: "Level Number", uid: "level_number" },
+ { name: "Parent Level", uid: "parent_level_id" },
+ { name: "Province", uid: "province_id" },
+ { name: "Status", uid: "is_active" },
+ { name: "Action", uid: "actions" },
+ ];
- const [page, setPage] = useState(1);
+ const [page, setPage] = useState(1);
- useEffect(() => {
- fetchData();
- }, []);
+ useEffect(() => {
+ fetchData();
+ }, []);
- async function fetchData() {
- const request = {
- page: page,
- limit: 10,
+ async function fetchData() {
+ const request = {
+ page: page,
+ limit: 10,
+ };
+ const res = await getAllUserLevels(request);
+ const data = res?.data?.data;
+ setTotalPage(Math.ceil(res?.data?.total / 10));
+ initUserData(10, data);
+ }
- };
- const res = await getAllUserLevels(request);
- const data = res?.data?.data;
- setTotalPage(Math.ceil(res?.data?.total / 10));
- initUserData(10, data);
+ function initUserData(limit: number, data?: any) {
+ if (data) {
+ console.log(data);
+ const startIndex = limit * (page - 1);
+ let iterate = 0;
+ const newData = data.map((value: any) => {
+ iterate++;
+ value.no = startIndex + iterate;
+ return value;
+ });
+ console.log("Data ::", newData);
+ setmasterUserLevel(newData);
}
+ }
- function initUserData(limit: number, data?: any) {
- if (data) {
- console.log(data);
- const startIndex = limit * (page - 1);
- let iterate = 0;
- const newData = data.map((value: any) => {
- iterate++;
- value.no = startIndex + iterate;
- return value;
- });
- console.log("Data ::", newData);
- setmasterUserLevel(newData);
- }
- }
+ const renderCell = useCallback(
+ (masterUserLevel: TableRow, columnKey: Key) => {
+ const cellValue = masterUserLevel[columnKey as keyof UserObject];
+ const statusColorMap: Record = {
+ active: "success",
+ cancel: "danger",
+ pending: "warning",
+ };
- const renderCell = useCallback((masterUserLevel: TableRow, columnKey: Key) => {
- const cellValue = masterUserLevel[columnKey as keyof UserObject];
- const statusColorMap: Record = {
- active: "success",
- cancel: "danger",
- pending: "warning",
- };
+ switch (columnKey) {
+ case "no":
+ return {masterUserLevel.id}
;
- switch (columnKey) {
- case "no":
- return (
- {masterUserLevel.id}
- )
+ case "name":
+ return {masterUserLevel.name}
;
- case "name":
- return (
- {masterUserLevel.name}
- )
+ case "alias_Name":
+ return {masterUserLevel.aliasName}
;
+ case "is_active":
+ return (
+
+
+ {cellValue}
+
+
+ );
- case "alias_Name":
- return (
- {masterUserLevel.aliasName}
- )
- case "is_active":
- return (
-
-
- {cellValue}
-
-
- );
-
- case "actions":
- return (
-
-
-
-
-
-
-
-
-
- Detail
-
-
-
-
-
- Edit
-
-
-
-
-
- Delete
-
-
-
-
-
- );
-
- default:
- return cellValue;
- }
- }, []);
-
- return (
- <>
-
-
-
-
-
-
-
- {(column) => (
- {column.name}
- )}
-
-
- {(item) => (
-
- {(columnKey) => (
- {renderCell(item, columnKey)}
- )}
-
- )}
-
-
-
-
+ case "actions":
+ return (
+
+
+
+
+
+
+
+
+
+ Detail
+
+
+
+
+
+ Edit
+
+
+
+
+
+ Delete
+
+
+
+
+ );
- >
- );
+ default:
+ return cellValue;
+ }
+ },
+ []
+ );
+
+ return (
+ <>
+
+
+
+
+
+
+
+ {(column) => (
+ {column.name}
+ )}
+
+
+ {(item) => (
+
+ {(columnKey) => (
+ {renderCell(item, columnKey)}
+ )}
+
+ )}
+
+
+
+
+
+ >
+ );
}
diff --git a/components/table/static-page-table.tsx b/components/table/static-page-table.tsx
index a9b301a..39d8901 100644
--- a/components/table/static-page-table.tsx
+++ b/components/table/static-page-table.tsx
@@ -157,13 +157,16 @@ export default function StaticPageTable() {
Detail
*/}
-
+
Edit
- handleDelete(article.id)}>
+ handleDelete(article.id)}
+ >