From b91f715e464f7fa2796ed0cb23f6119a494eb0cb Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Sat, 4 Jan 2025 04:18:22 +0700 Subject: [PATCH] feat:admin page-> broadcast, tenaga ahli, kategori --- .../admin/add-experts/component/column.tsx | 91 ++++ .../admin/add-experts/component/table.tsx | 276 +++++++++++ .../admin/add-experts/create/page.tsx | 258 ++++++++++ .../(protected)/admin/add-experts/page.tsx | 11 + .../account-list/component/column.tsx | 60 ++- .../account-list/component/table.tsx | 165 +++++-- .../account-list/create/page.tsx | 306 ++++++++++++ .../account-list/edit/[id]/page.tsx | 325 +++++++++++++ .../campaign-list/component/column.tsx | 4 +- .../campaign-list/component/table.tsx | 30 +- .../broadcast/campaign-list/create/page.tsx | 198 ++++++++ .../campaign-list/edit/[id]/page.tsx | 227 +++++++++ .../admin/broadcast/component/column.tsx | 2 +- .../admin/broadcast/component/table.tsx | 254 +++++----- .../admin/broadcast/email/[id]/page.tsx | 11 + .../admin/broadcast/whatsapp/[id]/page.tsx | 11 + .../settings/category/component/column.tsx | 157 +++++++ .../settings/category/component/create.tsx | 430 +++++++++++++++++ .../settings/category/component/edit.tsx | 443 ++++++++++++++++++ .../settings/category/component/status.tsx | 29 ++ .../settings/category/component/table.tsx | 184 ++++++++ .../admin/settings/category/page.tsx | 2 + .../form/broadcast/content-blast-form.tsx | 293 ++++++++++++ components/icon.tsx | 34 ++ messages/in.json | 2 +- .../assets/img/illust-for-broadcast-sent.png | Bin 0 -> 11149 bytes .../illust-for-scheduled-broadcast-sent.png | Bin 0 -> 16747 bytes service/broadcast/broadcast.ts | 58 ++- .../http-config/http-interceptor-service.ts | 2 +- service/settings/settings.ts | 30 ++ utils/globals.tsx | 25 +- 31 files changed, 3719 insertions(+), 199 deletions(-) create mode 100644 app/[locale]/(protected)/admin/add-experts/component/column.tsx create mode 100644 app/[locale]/(protected)/admin/add-experts/component/table.tsx create mode 100644 app/[locale]/(protected)/admin/add-experts/create/page.tsx create mode 100644 app/[locale]/(protected)/admin/add-experts/page.tsx create mode 100644 app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/create/page.tsx create mode 100644 app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx create mode 100644 app/[locale]/(protected)/admin/broadcast/campaign-list/create/page.tsx create mode 100644 app/[locale]/(protected)/admin/broadcast/campaign-list/edit/[id]/page.tsx create mode 100644 app/[locale]/(protected)/admin/broadcast/email/[id]/page.tsx create mode 100644 app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx create mode 100644 app/[locale]/(protected)/admin/settings/category/component/column.tsx create mode 100644 app/[locale]/(protected)/admin/settings/category/component/create.tsx create mode 100644 app/[locale]/(protected)/admin/settings/category/component/edit.tsx create mode 100644 app/[locale]/(protected)/admin/settings/category/component/status.tsx create mode 100644 app/[locale]/(protected)/admin/settings/category/component/table.tsx create mode 100644 components/form/broadcast/content-blast-form.tsx create mode 100644 public/assets/img/illust-for-broadcast-sent.png create mode 100644 public/assets/img/illust-for-scheduled-broadcast-sent.png create mode 100644 service/settings/settings.ts diff --git a/app/[locale]/(protected)/admin/add-experts/component/column.tsx b/app/[locale]/(protected)/admin/add-experts/component/column.tsx new file mode 100644 index 00000000..528d9436 --- /dev/null +++ b/app/[locale]/(protected)/admin/add-experts/component/column.tsx @@ -0,0 +1,91 @@ +import * as React from "react"; +import { ColumnDef } from "@tanstack/react-table"; + +import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react"; +import { cn } from "@/lib/utils"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuTrigger, + DropdownMenuItem, +} from "@/components/ui/dropdown-menu"; +import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; +import { + formatDateToIndonesian, + getOnlyDate, + htmlToString, +} from "@/utils/globals"; +import { Link, useRouter } from "@/i18n/routing"; +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from "@/components/ui/accordion"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + + { + accessorKey: "name", + header: "Nama", + cell: ({ row }) => {row.getValue("name")}, + }, + { + accessorKey: "region", + header: "Wilayah", + cell: ({ row }) => {row.getValue("region")}, + }, + { + accessorKey: "skills", + header: "Bidang Keahlian", + cell: ({ row }) => {row.getValue("skills")}, + }, + + { + accessorKey: "experience", + header: "Pengalaman", + cell: ({ row }) => {row.getValue("experience")}, + }, + + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + Detail + + + + ); + }, + }, +]; + +export default columns; diff --git a/app/[locale]/(protected)/admin/add-experts/component/table.tsx b/app/[locale]/(protected)/admin/add-experts/component/table.tsx new file mode 100644 index 00000000..e1cee274 --- /dev/null +++ b/app/[locale]/(protected)/admin/add-experts/component/table.tsx @@ -0,0 +1,276 @@ +"use client"; + +import * as React from "react"; +import { + ColumnDef, + ColumnFiltersState, + PaginationState, + SortingState, + VisibilityState, + flexRender, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable, +} from "@tanstack/react-table"; +import { Button } from "@/components/ui/button"; + +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { UserIcon } from "lucide-react"; +import { cn } from "@/lib/utils"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Input } from "@/components/ui/input"; +import { InputGroup, InputGroupText } from "@/components/ui/input-group"; +import { paginationBlog } from "@/service/blog/blog"; +import { ticketingPagination } from "@/service/ticketing/ticketing"; +import { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import columns from "./column"; +import { getPlanningPagination } from "@/service/agenda-setting/agenda-setting"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { listDataMedia } from "@/service/broadcast/broadcast"; +import { listEnableCategory } from "@/service/content/content"; +import { Checkbox } from "@/components/ui/checkbox"; +import { close, loading } from "@/config/swal"; +import { Link } from "@/i18n/routing"; + +const dummyData = [ + { + id: 1, + name: "Prof. Dr. Ravi", + region: "Nasional", + skills: "Komunikasi", + experience: "Akademisi", + }, + { + id: 2, + name: "Prof. Dr. Novan", + region: "DKI Jakarta", + skills: "Hukum", + experience: "Akademisi + Praktisi", + }, +]; + +const AddExpertTable = () => { + const router = useRouter(); + const searchParams = useSearchParams(); + const [showData, setShowData] = React.useState("10"); + const [categories, setCategories] = React.useState(); + const [dataTable, setDataTable] = React.useState([]); + const [totalData, setTotalData] = React.useState(1); + const [sorting, setSorting] = React.useState([]); + const [columnFilters, setColumnFilters] = React.useState( + [] + ); + const [columnVisibility, setColumnVisibility] = + React.useState({}); + const [rowSelection, setRowSelection] = React.useState({}); + const [pagination, setPagination] = React.useState({ + pageIndex: 0, + pageSize: Number(showData), + }); + const [categoryFilter, setCategoryFilter] = React.useState([]); + const [statusFilter, setStatusFilter] = React.useState([]); + const [page, setPage] = React.useState(1); + const [totalPage, setTotalPage] = React.useState(1); + const table = useReactTable({ + data: dataTable, + columns, + onSortingChange: setSorting, + onColumnFiltersChange: setColumnFilters, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getSortedRowModel: getSortedRowModel(), + getFilteredRowModel: getFilteredRowModel(), + onColumnVisibilityChange: setColumnVisibility, + onRowSelectionChange: setRowSelection, + onPaginationChange: setPagination, + state: { + sorting, + columnFilters, + columnVisibility, + rowSelection, + pagination, + }, + }); + + let typingTimer: any; + const doneTypingInterval = 1500; + + const handleKeyUp = () => { + clearTimeout(typingTimer); + typingTimer = setTimeout(doneTyping, doneTypingInterval); + }; + + const handleKeyDown = () => { + clearTimeout(typingTimer); + typingTimer = setTimeout(doneTyping, doneTypingInterval); + }; + + async function doneTyping() { + fetchData(); + } + + React.useEffect(() => { + const pageFromUrl = searchParams?.get("page"); + if (pageFromUrl) { + setPage(Number(pageFromUrl)); + } + }, [searchParams]); + + React.useEffect(() => { + fetchData(); + setPagination({ + pageIndex: 0, + pageSize: Number(showData), + }); + }, [page, showData]); + + async function fetchData() { + try { + loading(); + + const contentData = dummyData; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * Number(showData) + index + 1; + }); + + setDataTable(contentData); + setTotalData(contentData?.length); + setTotalPage(1); + close(); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + React.useEffect(() => { + getCategories(); + }, []); + + async function getCategories() { + const category = await listEnableCategory(""); + const resCategory = category.data.data.content; + setCategories(resCategory); + } + + return ( +
+
+

Tenaga Ahli

+ + + +
+ +
+ +
+ + + + + + + + 1 - 10 Data + + + 1 - 20 Data + + + 1 - 25 Data + + + 1 - 50 Data + + + + +
+
+ + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => ( + + {header.isPlaceholder + ? null + : flexRender( + header.column.columnDef.header, + header.getContext() + )} + + ))} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + )) + ) : ( + + + No results. + + + )} + +
+ +
+ ); +}; + +export default AddExpertTable; diff --git a/app/[locale]/(protected)/admin/add-experts/create/page.tsx b/app/[locale]/(protected)/admin/add-experts/create/page.tsx new file mode 100644 index 00000000..abc66bc2 --- /dev/null +++ b/app/[locale]/(protected)/admin/add-experts/create/page.tsx @@ -0,0 +1,258 @@ +"use client"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import { Button } from "@/components/ui/button"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { z } from "zod"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import withReactContent from "sweetalert2-react-content"; +import Swal from "sweetalert2"; +import { useRouter } from "@/i18n/routing"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; + +const FormSchema = z.object({ + name: z.string({ + required_error: "Required", + }), + phoneNumber: z.string({ + required_error: "Required", + }), + email: z.string({ + required_error: "Required", + }), + region: z.string({ + required_error: "Required", + }), + skills: z.string({ + required_error: "Required", + }), + experience: z.string({ + required_error: "Required", + }), + company: z.string({ + required_error: "Required", + }), +}); + +export default function AddExpertForm() { + const MySwal = withReactContent(Swal); + const router = useRouter(); + const form = useForm>({ + resolver: zodResolver(FormSchema), + }); + + const onSubmit = async (data: z.infer) => { + MySwal.fire({ + title: "Simpan Data", + text: "Apakah Anda yakin ingin menyimpan data ini?", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Simpan", + }).then((result) => { + if (result.isConfirmed) { + save(data); + } + }); + }; + + const save = async (data: z.infer) => { + console.log("data", data); + + // successSubmit(); + }; + + function successSubmit() { + MySwal.fire({ + title: "Sukses", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then((result) => { + if (result.isConfirmed) { + router.push("/admin/add-experts"); + } + }); + } + return ( +
+ + +
+ +

Campaign

+ ( + + Nama Lengkap + + + + + )} + /> + ( + + No. HP + + + + )} + /> + ( + + Email + + + + )} + /> + + ( + + Wilayah + + + + + )} + /> + ( + + Bidang Keahlian + + + + + )} + /> + ( + + Pengalaman + + + + + )} + /> + + ( + + Nama Institusi/Perusahaan + + + + )} + /> + +
+ + +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/add-experts/page.tsx b/app/[locale]/(protected)/admin/add-experts/page.tsx new file mode 100644 index 00000000..437a0a26 --- /dev/null +++ b/app/[locale]/(protected)/admin/add-experts/page.tsx @@ -0,0 +1,11 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import AddExpertTable from "./component/table"; + +export default function AddExpert() { + return ( +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx index 53fdc8d8..e21af944 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx @@ -11,8 +11,13 @@ import { } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; +import Swal from "sweetalert2"; import { Link, useRouter } from "@/i18n/routing"; +import withReactContent from "sweetalert2-react-content"; +import { close, error, loading } from "@/config/swal"; +import { deleteMediaBlastAccount } from "@/service/broadcast/broadcast"; +import { useToast } from "@/components/ui/use-toast"; const columns: ColumnDef[] = [ { @@ -24,22 +29,30 @@ const columns: ColumnDef[] = [ { accessorKey: "accountName", header: "Nama", - cell: ({ row }) => {row.getValue("accountName")}, + cell: ({ row }) => ( + {row.getValue("accountName")} + ), }, { accessorKey: "accountType", header: "Tipe Akun", - cell: ({ row }) => {row.getValue("accountType")}, + cell: ({ row }) => ( + {row.getValue("accountType")} + ), }, { accessorKey: "accountCategory", header: "Kategory", - cell: ({ row }) => {row.getValue("accountCategory")}, + cell: ({ row }) => ( + {row.getValue("accountCategory")} + ), }, { accessorKey: "emailAddress", header: "Email", - cell: ({ row }) => {row.getValue("emailAddress")}, + cell: ({ row }) => ( + {row.getValue("emailAddress")} + ), }, { accessorKey: "whatsappNumber", @@ -52,6 +65,41 @@ const columns: ColumnDef[] = [ header: "Actions", enableHiding: false, cell: ({ row }) => { + const MySwal = withReactContent(Swal); + const { toast } = useToast(); + const router = useRouter(); + const handleDelete = (id: string) => { + MySwal.fire({ + title: "Apakah anda ingin menghapus data?", + showCancelButton: true, + confirmButtonColor: "#dc3545", + confirmButtonText: "Iya", + cancelButtonText: "Tidak", + }).then((result) => { + if (result.isConfirmed) { + doDeleteAccount(id); + } + }); + }; + + async function succes() { + toast({ + title: "Sukses", + description: "Berhasil Delete", + }); + window.location.reload(); + } + + async function doDeleteAccount(id: string) { + loading(); + const response = await deleteMediaBlastAccount(id); + close(); + if (response?.error) { + error(response.message); + return false; + } + succes(); + } return ( @@ -65,13 +113,13 @@ const columns: ColumnDef[] = [ Edit - Delete + handleDelete(row.original.id)}>Delete diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/table.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/table.tsx index a60ae9ce..eb8b3e22 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/table.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/table.tsx @@ -24,51 +24,21 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - SquarePen, - Trash2, - TrendingDown, - TrendingUp, - UserIcon, -} from "lucide-react"; -import { cn } from "@/lib/utils"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuRadioGroup, - DropdownMenuRadioItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; -import { ticketingPagination } from "@/service/ticketing/ticketing"; -import { Badge } from "@/components/ui/badge"; +import { UserIcon } from "lucide-react"; + import { useRouter, useSearchParams } from "next/navigation"; import TablePagination from "@/components/table/table-pagination"; import columns from "./column"; -import { getPlanningPagination } from "@/service/agenda-setting/agenda-setting"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; -import { - getMediaBlastAccountPage, - getMediaBlastCampaignPage, - listDataMedia, -} from "@/service/broadcast/broadcast"; -import { listEnableCategory } from "@/service/content/content"; +import { getMediaBlastAccountPage } from "@/service/broadcast/broadcast"; import { Checkbox } from "@/components/ui/checkbox"; import { close, loading } from "@/config/swal"; import { Link } from "@/i18n/routing"; +import { Icon } from "@iconify/react/dist/iconify.js"; const AccountListTable = () => { const router = useRouter(); @@ -89,6 +59,7 @@ const AccountListTable = () => { const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); + const [filtered, setFiltered] = React.useState([]); const table = useReactTable({ data: dataTable, columns, @@ -124,15 +95,16 @@ const AccountListTable = () => { async function fetchData() { try { loading(); - const res = await getMediaBlastAccountPage(page - 1, ""); + const res = await getMediaBlastAccountPage( + page - 1, + filtered ? filtered.join(",") : "" + ); const data = res.data?.data; const contentData = data?.content; contentData.forEach((item: any, index: number) => { item.no = (page - 1) * 10 + index + 1; }); - console.log("contentData : ", data); - setDataTable(contentData); setTotalData(data?.totalElements); setTotalPage(data?.totalPages); @@ -142,23 +114,114 @@ const AccountListTable = () => { } } + const handleFilter = (id: string, checked: boolean) => { + let temp = [...filtered]; + if (checked) { + temp = [...temp, id]; + } else { + temp = temp.filter((a) => a !== id); + } + setFiltered(temp); + console.log("sss", temp); + }; + return (
-
- - - - - - +
+

Daftar Akun

+
+ + + + + + +
+
+
+ + + + + +
+ +
+
+ handleFilter("polri", Boolean(e))} + /> + +
+
+ + handleFilter("jurnalis", Boolean(e)) + } + /> + +
+
+ handleFilter("umum", Boolean(e))} + /> + +
+
+ handleFilter("ksp", Boolean(e))} + /> + +
+
+
+
+
- {table.getHeaderGroups().map((headerGroup) => ( diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/create/page.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/create/page.tsx new file mode 100644 index 00000000..02c28100 --- /dev/null +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/create/page.tsx @@ -0,0 +1,306 @@ +"use client"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import { z } from "zod"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import withReactContent from "sweetalert2-react-content"; +import Swal from "sweetalert2"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; +import { format } from "date-fns"; +import { CalendarIcon } from "lucide-react"; +import { Calendar } from "@/components/ui/calendar"; +import { getOnlyDate } from "@/utils/globals"; +import { + saveMediaBlastAccount, + saveMediaBlastCampaign, +} from "@/service/broadcast/broadcast"; +import { error } from "@/config/swal"; +import { useRouter } from "@/i18n/routing"; +import { Checkbox } from "@/components/ui/checkbox"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; + +const FormSchema = z.object({ + name: z.string({ + required_error: "Required", + }), + accountType: z + .array(z.string()) + .refine((value) => value.some((item) => item), { + message: "Required", + }), + accountCategory: z.enum(["polri", "jurnalis", "umumu", "ksp"], { + required_error: "Required", + }), + email: z.string({ + required_error: "Required", + }), + whatsapp: z.string({ + required_error: "Required", + }), +}); + +export default function CreateAccountForBroadcast() { + const MySwal = withReactContent(Swal); + const router = useRouter(); + const form = useForm>({ + resolver: zodResolver(FormSchema), + defaultValues: { accountType: [] }, + }); + + const onSubmit = async (data: z.infer) => { + MySwal.fire({ + title: "Simpan Data", + text: "Apakah Anda yakin ingin menyimpan data ini?", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Simpan", + }).then((result) => { + if (result.isConfirmed) { + save(data); + } + }); + }; + + function successSubmit() { + MySwal.fire({ + title: "Sukses", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then((result) => { + if (result.isConfirmed) { + router.push("/admin/broadcast/campaign-list/account-list"); + } + }); + } + + const save = async (data: z.infer) => { + const reqData = { + accountName: data.name, + accountType: data.accountType.join(","), + accountCategory: data.accountCategory, + emailAddress: data.email, + whatsappNumber: data.whatsapp, + }; + console.log("data", data); + + const response = await saveMediaBlastAccount(reqData); + if (response?.error) { + error(response.message); + return false; + } + + successSubmit(); + }; + return ( +
+ +
+ +

Account

+ ( + + Nama + + + + + )} + /> + ( + + Tipe Akun +
+ {" "} + { + return ( + + + { + return checked + ? field.onChange([...field.value, "wa"]) + : field.onChange( + field.value?.filter( + (value) => value !== "wa" + ) + ); + }} + /> + + + Whatsapp + + + ); + }} + /> + { + return ( + + + { + return checked + ? field.onChange([...field.value, "email"]) + : field.onChange( + field.value?.filter( + (value) => value !== "email" + ) + ); + }} + /> + + Email + + ); + }} + /> +
+ + +
+ )} + /> + ( + + Kategori + + + + + + + POLRI + + + + + + JURNALIS + + + + + + UMUM + + + + + + KSP + + + + + + )} + /> + ( + + Nama + + + + + )} + /> + ( + + Nama + + + + + )} + /> +
+ + +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx new file mode 100644 index 00000000..1ce469af --- /dev/null +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx @@ -0,0 +1,325 @@ +"use client"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import { z } from "zod"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import withReactContent from "sweetalert2-react-content"; +import Swal from "sweetalert2"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; +import { format } from "date-fns"; +import { CalendarIcon } from "lucide-react"; +import { Calendar } from "@/components/ui/calendar"; +import { getOnlyDate } from "@/utils/globals"; +import { + getMediaBlastAccount, + saveMediaBlastAccount, + saveMediaBlastCampaign, +} from "@/service/broadcast/broadcast"; +import { error } from "@/config/swal"; +import { useRouter } from "@/i18n/routing"; +import { Checkbox } from "@/components/ui/checkbox"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; +import { useParams } from "next/navigation"; +import { useEffect } from "react"; + +const FormSchema = z.object({ + name: z.string({ + required_error: "Required", + }), + accountType: z + .array(z.string()) + .refine((value) => value.some((item) => item), { + message: "Required", + }), + accountCategory: z.enum(["polri", "jurnalis", "umumu", "ksp"], { + required_error: "Required", + }), + email: z.string({ + required_error: "Required", + }), + whatsapp: z.string({ + required_error: "Required", + }), +}); + +export default function EditAccountForBroadcast() { + const id = useParams()?.id; + const MySwal = withReactContent(Swal); + const router = useRouter(); + const form = useForm>({ + resolver: zodResolver(FormSchema), + defaultValues: { accountType: [] }, + }); + + useEffect(() => { + async function getDetailData() { + const response = await getMediaBlastAccount(String(id)); + const details = response.data?.data; + console.log("new", details); + form.setValue("name", details.accountName); + form.setValue("email", details?.emailAddress); + form.setValue("whatsapp", details?.whatsappNumber); + form.setValue("accountCategory", details?.accountCategory); + form.setValue("accountType", details?.accountType.split(",")); + } + + getDetailData(); + }, [id]); + + const onSubmit = async (data: z.infer) => { + MySwal.fire({ + title: "Simpan Data", + text: "Apakah Anda yakin ingin menyimpan data ini?", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Simpan", + }).then((result) => { + if (result.isConfirmed) { + save(data); + } + }); + }; + + function successSubmit() { + MySwal.fire({ + title: "Sukses", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then((result) => { + if (result.isConfirmed) { + router.push("/admin/broadcast/campaign-list/account-list"); + } + }); + } + + const save = async (data: z.infer) => { + const reqData = { + id: String(id), + accountName: data.name, + accountType: data.accountType.join(","), + accountCategory: data.accountCategory, + emailAddress: data.email, + whatsappNumber: data.whatsapp, + }; + console.log("data", data); + + const response = await saveMediaBlastAccount(reqData); + if (response?.error) { + error(response.message); + return false; + } + + successSubmit(); + }; + return ( +
+ +
+ +

Account

+ ( + + Nama + + + + + )} + /> + ( + + Tipe Akun +
+ { + return ( + + + { + return checked + ? field.onChange([...field.value, "wa"]) + : field.onChange( + field.value?.filter( + (value) => value !== "wa" + ) + ); + }} + /> + + + Whatsapp + + + ); + }} + /> + { + return ( + + + { + return checked + ? field.onChange([...field.value, "email"]) + : field.onChange( + field.value?.filter( + (value) => value !== "email" + ) + ); + }} + /> + + Email + + ); + }} + /> +
+ + +
+ )} + /> + ( + + Kategori + + + + + + + POLRI + + + + + + JURNALIS + + + + + + UMUM + + + + + + KSP + + + + + + )} + /> + ( + + Nama + + + + + )} + /> + ( + + Nama + + + + + )} + /> +
+ + +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx index 8c269959..139090ad 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx @@ -24,7 +24,9 @@ const columns: ColumnDef[] = [ { accessorKey: "title", header: "Judul", - cell: ({ row }) => {row.getValue("title")}, + cell: ({ row }) => ( + {row.getValue("title")} + ), }, { accessorKey: "sendTime", diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx index 96d00a4e..f56cf0ab 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx @@ -68,6 +68,7 @@ import { listEnableCategory } from "@/service/content/content"; import { Checkbox } from "@/components/ui/checkbox"; import { close, loading } from "@/config/swal"; import { Link } from "@/i18n/routing"; +import { NewCampaignIcon } from "@/components/icon"; const CampaignListTable = () => { const router = useRouter(); @@ -143,19 +144,22 @@ const CampaignListTable = () => { return (
-
- - - - - - +
+

Daftar Campaign

+
+ + + + + + +
diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/create/page.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/create/page.tsx new file mode 100644 index 00000000..210c8241 --- /dev/null +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/create/page.tsx @@ -0,0 +1,198 @@ +"use client"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import { z } from "zod"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import withReactContent from "sweetalert2-react-content"; +import Swal from "sweetalert2"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; +import { format } from "date-fns"; +import { CalendarIcon } from "lucide-react"; +import { Calendar } from "@/components/ui/calendar"; +import { getOnlyDate } from "@/utils/globals"; +import { saveMediaBlastCampaign } from "@/service/broadcast/broadcast"; +import { error } from "@/config/swal"; +import { useRouter } from "@/i18n/routing"; + +const FormSchema = z.object({ + date: z.date({ + required_error: "Required", + }), + title: z.string({ + required_error: "Required", + }), + time: z.string({ + required_error: "Required", + }), +}); + +export default function CreateCampaign() { + const MySwal = withReactContent(Swal); + const router = useRouter(); + const form = useForm>({ + resolver: zodResolver(FormSchema), + }); + + const onSubmit = async (data: z.infer) => { + MySwal.fire({ + title: "Simpan Data", + text: "Apakah Anda yakin ingin menyimpan data ini?", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Simpan", + }).then((result) => { + if (result.isConfirmed) { + save(data); + } + }); + }; + + function successSubmit() { + MySwal.fire({ + title: "Sukses", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then((result) => { + if (result.isConfirmed) { + router.push("/admin/broadcast/campaign-list"); + } + }); + } + + const save = async (data: z.infer) => { + const newDate = getOnlyDate(data.date).split("-"); + const dates = `${newDate[2]}-${newDate[1]}-${newDate[0]}`; + const reqData = { + title: data.title, + sendTime: `${dates} ${data.time}:00`, + status: "waiting", + }; + + const response = await saveMediaBlastCampaign(reqData); + if (response?.error) { + error(response.message); + return false; + } + + successSubmit(); + }; + return ( +
+ +
+ +

Campaign

+ ( + + Judul + + + + + )} + /> +

Jadwal Kirim

+
+ ( + + + + + + + + + + + + )} + /> + ( + + + + + + )} + /> +
+ +
+ + +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/edit/[id]/page.tsx new file mode 100644 index 00000000..01064f1f --- /dev/null +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/edit/[id]/page.tsx @@ -0,0 +1,227 @@ +"use client"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import { z } from "zod"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import withReactContent from "sweetalert2-react-content"; +import Swal from "sweetalert2"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; +import { format } from "date-fns"; +import { CalendarIcon } from "lucide-react"; +import { Calendar } from "@/components/ui/calendar"; +import { getOnlyDate } from "@/utils/globals"; +import { + getMediaBlastCampaignById, + saveMediaBlastCampaign, +} from "@/service/broadcast/broadcast"; +import { error } from "@/config/swal"; +import { useRouter } from "@/i18n/routing"; +import { useParams } from "next/navigation"; +import { useEffect } from "react"; + +const FormSchema = z.object({ + date: z.date({ + required_error: "Required", + }), + title: z.string({ + required_error: "Required", + }), + time: z.string({ + required_error: "Required", + }), + status: z.string({ + required_error: "Required", + }), +}); + +export default function EditCampaign() { + const id = useParams()?.id; + const MySwal = withReactContent(Swal); + const router = useRouter(); + const form = useForm>({ + resolver: zodResolver(FormSchema), + }); + + useEffect(() => { + async function getInitData() { + const response = await getMediaBlastCampaignById(String(id)); + const date = response?.data?.data?.sendTime.split(" "); + const dateInput: Date = new Date(date[0]); + + const time = date[1].split(":"); + + form.setValue("title", response?.data?.data?.title); + form.setValue("status", response?.data?.data?.status); + form.setValue("date", new Date(format(dateInput, "dd-MM-yyyy"))); + form.setValue("time", `${time[0]}:${time[1]}`); + } + + if (id != undefined) { + getInitData(); + } + }, [id]); + + const onSubmit = async (data: z.infer) => { + MySwal.fire({ + title: "Simpan Data", + text: "Apakah Anda yakin ingin menyimpan data ini?", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Simpan", + }).then((result) => { + if (result.isConfirmed) { + save(data); + } + }); + }; + + function successSubmit() { + MySwal.fire({ + title: "Sukses", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then((result) => { + if (result.isConfirmed) { + router.push("/admin/broadcast/campaign-list"); + } + }); + } + + const save = async (data: z.infer) => { + const newDate = getOnlyDate(data.date).split("-"); + const dates = `${newDate[2]}-${newDate[1]}-${newDate[0]}`; + const reqData = { + id: String(id), + title: data.title, + sendTime: `${dates} ${data.time}:00`, + status: data.status, + }; + + const response = await saveMediaBlastCampaign(reqData); + if (response?.error) { + error(response.message); + return false; + } + + successSubmit(); + }; + return ( +
+ +
+ +

Campaign

+ ( + + Judul + + + + + )} + /> +

Jadwal Kirim

+
+ ( + + + + + + + + + + + + )} + /> + ( + + + + + + )} + /> +
+ +
+ + +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/broadcast/component/column.tsx b/app/[locale]/(protected)/admin/broadcast/component/column.tsx index 476b628e..a9a32f16 100644 --- a/app/[locale]/(protected)/admin/broadcast/component/column.tsx +++ b/app/[locale]/(protected)/admin/broadcast/component/column.tsx @@ -93,7 +93,7 @@ const columns: ColumnDef[] = [ - + Whatsapp Blast diff --git a/app/[locale]/(protected)/admin/broadcast/component/table.tsx b/app/[locale]/(protected)/admin/broadcast/component/table.tsx index d2cb4a48..338cd31d 100644 --- a/app/[locale]/(protected)/admin/broadcast/component/table.tsx +++ b/app/[locale]/(protected)/admin/broadcast/component/table.tsx @@ -135,6 +135,10 @@ const BroadcastTable = () => { React.useEffect(() => { fetchData(); + setPagination({ + pageIndex: 0, + pageSize: Number(showData), + }); }, [page, showData]); async function fetchData() { @@ -198,147 +202,153 @@ const BroadcastTable = () => { return (
- - - +
+

Brodcast

+ + + +
-
+
- - - - - - - - 1 - 10 Data - - - 1 - 20 Data - - - 1 - 25 Data - - - 1 - 50 Data - - - - - - - - - -
- -
-

Kategory

- {categories?.map((category: any) => ( +
+ + + + + + + + 1 - 10 Data + + + 1 - 20 Data + + + 1 - 25 Data + + + 1 - 50 Data + + + + + + + + + +
+ +
+

Kategory

+ {categories?.map((category: any) => ( +
+ + handleChange("category", category.id, Boolean(e)) + } + /> + +
+ ))} +

Status

- handleChange("category", category.id, Boolean(e)) + handleChange("status", 1, Boolean(e)) } /> +
+
+ + handleChange("status", 2, Boolean(e)) + } + /> + +
+
+ + handleChange("status", 3, Boolean(e)) + } + /> + +
+
+ + handleChange("status", 4, Boolean(e)) + } + /> +
- ))} -

Status

-
- - handleChange("status", 1, Boolean(e)) - } - /> - -
-
- - handleChange("status", 2, Boolean(e)) - } - /> - -
-
- - handleChange("status", 3, Boolean(e)) - } - /> - -
-
- - handleChange("status", 4, Boolean(e)) - } - /> -
-
-
-
+ + +
diff --git a/app/[locale]/(protected)/admin/broadcast/email/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/email/[id]/page.tsx new file mode 100644 index 00000000..73256382 --- /dev/null +++ b/app/[locale]/(protected)/admin/broadcast/email/[id]/page.tsx @@ -0,0 +1,11 @@ +import ContentBlast from "@/components/form/broadcast/content-blast-form"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; + +export default function CreateEmailBlast() { + return ( +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx new file mode 100644 index 00000000..d1ddaa08 --- /dev/null +++ b/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx @@ -0,0 +1,11 @@ +import ContentBlast from "@/components/form/broadcast/content-blast-form"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; + +export default function CreateWABlast() { + return ( +
+ + +
+ ); +} diff --git a/app/[locale]/(protected)/admin/settings/category/component/column.tsx b/app/[locale]/(protected)/admin/settings/category/component/column.tsx new file mode 100644 index 00000000..02fe1320 --- /dev/null +++ b/app/[locale]/(protected)/admin/settings/category/component/column.tsx @@ -0,0 +1,157 @@ +import * as React from "react"; +import { ColumnDef } from "@tanstack/react-table"; + +import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react"; +import { cn } from "@/lib/utils"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuTrigger, + DropdownMenuItem, +} from "@/components/ui/dropdown-menu"; +import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; + +import { Link, useRouter } from "@/i18n/routing"; +import StatusToogle from "./status"; +import { error } from "@/config/swal"; +import { deleteCategory } from "@/service/settings/settings"; +import { useToast } from "@/components/ui/use-toast"; +import EditCategoryModal from "./edit"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { + Menubar, + MenubarContent, + MenubarMenu, + MenubarTrigger, +} from "@/components/ui/menubar"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + + { + accessorKey: "name", + header: "Nama Kategori", + cell: ({ row }) => ( + {row.getValue("name")} + ), + }, + { + accessorKey: "contentType", + header: "Tipe Konten", + cell: ({ row }) => ( + {row.getValue("contentType")} + ), + }, + { + accessorKey: "isInternational", + header: "Wilayah", + cell: ({ row }) => ( + + {row.getValue("isInternational") ? "INT" : "ID"} + + ), + }, + { + accessorKey: "status", + header: "Status", + cell: ({ row }) => ( + + + + ), + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + const router = useRouter(); + const { toast } = useToast(); + + const categoryDelete = async (id: number) => { + const response = await deleteCategory(id); + console.log(response); + if (response?.error) { + error(response.message); + return false; + } + toast({ + title: "Sukses", + description: "Berhasil Delete", + }); + router.push("/admin/settings/category?dataChange=true"); + }; + return ( + // + // + // + // + // + // + // + // + + // + // + // + // + // + // + // + // + // + // categoryDelete(row.original.id)}>Delete + // + // + // + + + + + + + + + categoryDelete(row.original.id)} + className="hover:underline cursor-pointer hover:text-destructive" + > + Delete + + + + + ); + }, + }, +]; + +export default columns; diff --git a/app/[locale]/(protected)/admin/settings/category/component/create.tsx b/app/[locale]/(protected)/admin/settings/category/component/create.tsx new file mode 100644 index 00000000..cc3f6563 --- /dev/null +++ b/app/[locale]/(protected)/admin/settings/category/component/create.tsx @@ -0,0 +1,430 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { z } from "zod"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { useRouter } from "@/i18n/routing"; +import { Input } from "@/components/ui/input"; +import { Checkbox } from "@/components/ui/checkbox"; +import { getUserRoles, postCategory } from "@/service/settings/settings"; +import { useEffect, useState } from "react"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { Textarea } from "@/components/ui/textarea"; +import { close, error, loading } from "@/config/swal"; + +const FormSchema = z.object({ + title: z.string({ + required_error: "Required", + }), + description: z.string({ + required_error: "Required", + }), + contentType: z + .array(z.string()) + .refine((value) => value.some((item) => item), { + message: "Required", + }), + selectedUser: z + .array(z.string()) + .refine((value) => value.some((item) => item), { + message: "Required", + }), + publishTo: z.string({ + required_error: "Required", + }), + file: z + .instanceof(File, { + message: "Invalid file format", + }) + .optional() + .refine((file) => file && file.size > 0, { + message: "File is required", + }), +}); + +const listContent = [ + { + id: "1", + name: "Foto", + }, + { + id: "2", + name: "Audio Visual", + }, + { + id: "3", + name: "Teks", + }, + { + id: "4", + name: "Audio", + }, +]; + +export default function CreateCategoryModal() { + const router = useRouter(); + const [userList, setUserList] = useState< + { id: string; name: string; isInternal: boolean }[] + >([]); + const form = useForm>({ + resolver: zodResolver(FormSchema), + defaultValues: { contentType: [], selectedUser: [], publishTo: "national" }, + }); + + const contentType = form.watch("contentType"); + + const isAllContentChecked = listContent.every((item) => + contentType?.includes(item.id) + ); + + const users = form.watch("selectedUser"); + + const isAllUserChecked = userList.every((item) => users?.includes(item.id)); + + useEffect(() => { + getRoles(); + }, []); + + async function getRoles() { + const response = await getUserRoles(); + let dataRoles = response.data.data; + for (let i = 0; i < dataRoles.length; i++) { + dataRoles[i].id = String(dataRoles[i].id); + } + setUserList(dataRoles); + console.log("dasda", dataRoles); + } + + const onSubmit = async (data: z.infer) => { + if (data.file instanceof Blob) { + const formMedia = new FormData(); + + loading(); + + formMedia.append("name", data.title); + formMedia.append("description", data.description); + formMedia.append("mediaTypes", data.contentType.join(",")); + formMedia.append("file", data.file); + formMedia.append("publishedFor", data.selectedUser.sort().join(",")); + formMedia.append( + "isInt", + data.publishTo === "national" ? "false" : "true" + ); + console.log(formMedia); + const response = await postCategory(formMedia); + close(); + if (response?.error == true) { + error(response.message); + return false; + } + router.push("/admin/settings/category?dataChange=true"); + } + }; + return ( + + + + + + + Tambah Kategori + +
+ + ( + + Tipe Konten + +
+
+ { + if (checked) { + form.setValue( + "contentType", + listContent.map((item) => item.id) + ); + } else { + form.setValue("contentType", []); + } + }} + /> + +
+ {listContent.map((item) => ( + { + return ( + +
+ + { + return checked + ? field.onChange([ + ...field.value, + item.id, + ]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ); + }} + /> + + + {item.name} + +
+
+ ); + }} + /> + ))} +
+ +
+ )} + /> + + ( + + Target Publish + +
+
+ { + if (checked) { + form.setValue( + "selectedUser", + userList.map((item) => item.id) + ); + } else { + form.setValue("selectedUser", []); + } + }} + /> + +
+ {userList.map((item) => ( + { + return ( + +
+ + { + return checked + ? field.onChange([ + ...field.value, + item.id, + ]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ); + }} + /> + + + {item.name} + +
+
+ ); + }} + /> + ))} +
+ +
+ )} + /> + ( + + Wilayah Publish + + + + + + + Nasional + + + + + + + Internasional + + + + + + + )} + /> + ( + + Nama Kategori + + + + + )} + /> + + ( + + Nama Kategori + {!field.value && ( +
+ +
+ )} + + {field.value && ( + + )} + + +
+ )} + /> + ( + + Deskripsi + +