feat:add table:schedule and fix bug table
This commit is contained in:
parent
4d3d934197
commit
b04ff4743a
|
|
@ -56,7 +56,6 @@ export type CompanyData = {
|
|||
import { data } from "./data";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { InputGroup, InputGroupText } from "@/components/ui/input-group";
|
||||
import { listTask } from "@/service/ppid-categories-services";
|
||||
import { paginationBlog } from "@/service/blog/blog";
|
||||
|
||||
export const columns: ColumnDef<CompanyData>[] = [
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import {
|
|||
export type CompanyData = {
|
||||
no: number;
|
||||
title: string;
|
||||
commentFromUserName: string;
|
||||
createdBy: string;
|
||||
commentToUserName: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
|
@ -86,21 +86,17 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "commentFromUserName",
|
||||
accessorKey: "createdBy",
|
||||
header: "Pengirim ",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">
|
||||
{row.getValue("commentFromUserName")}
|
||||
</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("createdBy")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "commentToUserName",
|
||||
accessorKey: "sendTo",
|
||||
header: "Penerima",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">
|
||||
{row.getValue("commentToUserName")}
|
||||
</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("sendTo")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
|
|
@ -158,7 +154,7 @@ const InternalTable = () => {
|
|||
const [rowSelection, setRowSelection] = React.useState({});
|
||||
const [pagination, setPagination] = React.useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 6,
|
||||
pageSize: 10,
|
||||
});
|
||||
const [page, setPage] = React.useState(1);
|
||||
const [totalPage, setTotalPage] = React.useState(1);
|
||||
|
|
@ -191,9 +187,8 @@ const InternalTable = () => {
|
|||
|
||||
async function initState() {
|
||||
try {
|
||||
const res = await listTicketingInternal(page);
|
||||
|
||||
const data = res.data.content.map((item: any, index: number) => ({
|
||||
const res = await listTicketingInternal(limit, page);
|
||||
const data = res.data.data.content.map((item: any, index: number) => ({
|
||||
no: (page - 1) * limit + index + 1,
|
||||
title: item.title,
|
||||
commentFromUserName: item.commentFromUserName,
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ const TableImage = () => {
|
|||
pageIndex: 0, // Halaman pertama
|
||||
pageSize: 10, // Jumlah baris per halaman
|
||||
});
|
||||
const [totalPage, setTotalPage] = React.useState<number>(1);
|
||||
const [totalPage, setTotalPage] = React.useState<number>(10);
|
||||
const [limit, setLimit] = React.useState<number>(10); // Jumlah baris per halaman
|
||||
const [search, setSearch] = React.useState<string>("");
|
||||
const userId = getCookiesDecrypt("uie");
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ export type CompanyData = {
|
|||
import { data } from "./data";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { InputGroup, InputGroupText } from "@/components/ui/input-group";
|
||||
import { listTask } from "@/service/ppid-categories-services";
|
||||
import page from "../page";
|
||||
import { getPlanningSentPagination } from "@/service/planning/planning";
|
||||
|
||||
export const columns: ColumnDef<CompanyData>[] = [
|
||||
|
|
|
|||
|
|
@ -46,11 +46,12 @@ import {
|
|||
} from "@/components/ui/dropdown-menu";
|
||||
|
||||
export type CompanyData = {
|
||||
no: number;
|
||||
title: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
time: string;
|
||||
loccation: string;
|
||||
startTime: string;
|
||||
address: string;
|
||||
speakerName: string;
|
||||
uploaderName: string;
|
||||
status: string;
|
||||
|
|
@ -58,8 +59,24 @@ export type CompanyData = {
|
|||
import { data } from "./data";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { InputGroup, InputGroupText } from "@/components/ui/input-group";
|
||||
import { paginationBlog } from "@/service/blog/blog";
|
||||
import { paginationSchedule } from "@/service/schedule/schedule";
|
||||
|
||||
export const columns: ColumnDef<CompanyData>[] = [
|
||||
{
|
||||
accessorKey: "no",
|
||||
header: "No",
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="flex-1 text-start">
|
||||
<h4 className="text-sm font-medium text-default-600 whitespace-nowrap mb-1">
|
||||
{row.getValue("no")}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: "Judul",
|
||||
|
|
@ -88,19 +105,30 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "time",
|
||||
accessorKey: "startTime",
|
||||
header: "Waktu",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">{row.getValue("time")}</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("startTime")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "loccation",
|
||||
accessorKey: "address",
|
||||
header: "Lokasi",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">{row.getValue("loccation")}</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("address")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<span className="whitespace-nowrap text-blue-600">
|
||||
{row.getValue("status")}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "speakerName",
|
||||
header: "Disampaikan oleh",
|
||||
|
|
@ -115,17 +143,7 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
<span className="whitespace-nowrap">{row.getValue("uploaderName")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<span className="whitespace-nowrap text-blue-600">
|
||||
{row.getValue("status")}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
id: "actions",
|
||||
accessorKey: "action",
|
||||
|
|
@ -164,6 +182,7 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
];
|
||||
|
||||
const EventTable = () => {
|
||||
const [eventTable, setEventTable] = React.useState<CompanyData[]>([]);
|
||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
||||
[]
|
||||
|
|
@ -173,11 +192,14 @@ const EventTable = () => {
|
|||
const [rowSelection, setRowSelection] = React.useState({});
|
||||
const [pagination, setPagination] = React.useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 6,
|
||||
pageSize: 10,
|
||||
});
|
||||
const [page, setPage] = React.useState(1);
|
||||
const [totalPage, setTotalPage] = React.useState(1);
|
||||
const [limit, setLimit] = React.useState(10);
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
data: eventTable,
|
||||
columns,
|
||||
onSortingChange: setSorting,
|
||||
onColumnFiltersChange: setColumnFilters,
|
||||
|
|
@ -197,6 +219,31 @@ const EventTable = () => {
|
|||
},
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
initState();
|
||||
}, [page, limit]);
|
||||
|
||||
async function initState() {
|
||||
try {
|
||||
const res = await paginationSchedule(limit, page, 2);
|
||||
const data = res.data.data.content.map((item: any, index: number) => ({
|
||||
no: (page - 1) * limit + index + 1,
|
||||
title: item.title,
|
||||
startDate: item.startDate,
|
||||
endDate: item.endDate,
|
||||
startTime: item.startTime,
|
||||
address: item.address,
|
||||
uploaderName: item.uploaderName,
|
||||
speakerName: item.speakerName,
|
||||
}));
|
||||
|
||||
setEventTable(data);
|
||||
setTotalPage(res.data.totalPages);
|
||||
} catch (error) {
|
||||
console.error("Error fetching tasks:", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<div className="flex justify-between items-center py-4 px-5">
|
||||
|
|
|
|||
|
|
@ -46,11 +46,12 @@ import {
|
|||
} from "@/components/ui/dropdown-menu";
|
||||
|
||||
export type CompanyData = {
|
||||
no: number;
|
||||
title: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
time: string;
|
||||
loccation: string;
|
||||
startTime: string;
|
||||
address: string;
|
||||
speakerName: string;
|
||||
uploaderName: string;
|
||||
status: string;
|
||||
|
|
@ -58,8 +59,24 @@ export type CompanyData = {
|
|||
import { data } from "./data";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { InputGroup, InputGroupText } from "@/components/ui/input-group";
|
||||
import { paginationBlog } from "@/service/blog/blog";
|
||||
import { paginationSchedule } from "@/service/schedule/schedule";
|
||||
|
||||
export const columns: ColumnDef<CompanyData>[] = [
|
||||
{
|
||||
accessorKey: "no",
|
||||
header: "No",
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="flex-1 text-start">
|
||||
<h4 className="text-sm font-medium text-default-600 whitespace-nowrap mb-1">
|
||||
{row.getValue("no")}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: "Judul",
|
||||
|
|
@ -88,19 +105,30 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "time",
|
||||
accessorKey: "startTime",
|
||||
header: "Waktu",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">{row.getValue("time")}</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("startTime")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "loccation",
|
||||
accessorKey: "address",
|
||||
header: "Lokasi",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">{row.getValue("loccation")}</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("address")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<span className="whitespace-nowrap text-blue-600">
|
||||
{row.getValue("status")}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "speakerName",
|
||||
header: "Disampaikan oleh",
|
||||
|
|
@ -115,17 +143,7 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
<span className="whitespace-nowrap">{row.getValue("uploaderName")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<span className="whitespace-nowrap text-blue-600">
|
||||
{row.getValue("status")}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
id: "actions",
|
||||
accessorKey: "action",
|
||||
|
|
@ -163,7 +181,8 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
},
|
||||
];
|
||||
|
||||
const PressReleaseTable = () => {
|
||||
const PressConTable = () => {
|
||||
const [pressconTable, setPressConTable] = React.useState<CompanyData[]>([]);
|
||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
||||
[]
|
||||
|
|
@ -173,11 +192,14 @@ const PressReleaseTable = () => {
|
|||
const [rowSelection, setRowSelection] = React.useState({});
|
||||
const [pagination, setPagination] = React.useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 6,
|
||||
pageSize: 10,
|
||||
});
|
||||
const [page, setPage] = React.useState(1);
|
||||
const [totalPage, setTotalPage] = React.useState(1);
|
||||
const [limit, setLimit] = React.useState(10);
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
data: pressconTable,
|
||||
columns,
|
||||
onSortingChange: setSorting,
|
||||
onColumnFiltersChange: setColumnFilters,
|
||||
|
|
@ -197,6 +219,31 @@ const PressReleaseTable = () => {
|
|||
},
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
initState();
|
||||
}, [page, limit]);
|
||||
|
||||
async function initState() {
|
||||
try {
|
||||
const res = await paginationSchedule(limit, page, 1);
|
||||
const data = res.data.data.content.map((item: any, index: number) => ({
|
||||
no: (page - 1) * limit + index + 1,
|
||||
title: item.title,
|
||||
startDate: item.startDate,
|
||||
endDate: item.endDate,
|
||||
startTime: item.startTime,
|
||||
address: item.address,
|
||||
uploaderName: item.uploaderName,
|
||||
speakerName: item.speakerName,
|
||||
}));
|
||||
|
||||
setPressConTable(data);
|
||||
setTotalPage(res.data.totalPages);
|
||||
} catch (error) {
|
||||
console.error("Error fetching tasks:", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<div className="flex justify-between items-center py-4 px-5">
|
||||
|
|
@ -305,4 +352,4 @@ const PressReleaseTable = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export default PressReleaseTable;
|
||||
export default PressConTable;
|
||||
|
|
|
|||
|
|
@ -46,11 +46,12 @@ import {
|
|||
} from "@/components/ui/dropdown-menu";
|
||||
|
||||
export type CompanyData = {
|
||||
no: number;
|
||||
title: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
time: string;
|
||||
loccation: string;
|
||||
startTime: string;
|
||||
address: string;
|
||||
speakerName: string;
|
||||
uploaderName: string;
|
||||
status: string;
|
||||
|
|
@ -58,8 +59,24 @@ export type CompanyData = {
|
|||
import { data } from "./data";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { InputGroup, InputGroupText } from "@/components/ui/input-group";
|
||||
import { paginationBlog } from "@/service/blog/blog";
|
||||
import { paginationSchedule } from "@/service/schedule/schedule";
|
||||
|
||||
export const columns: ColumnDef<CompanyData>[] = [
|
||||
{
|
||||
accessorKey: "no",
|
||||
header: "No",
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="flex-1 text-start">
|
||||
<h4 className="text-sm font-medium text-default-600 whitespace-nowrap mb-1">
|
||||
{row.getValue("no")}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: "Judul",
|
||||
|
|
@ -88,19 +105,30 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "time",
|
||||
accessorKey: "startTime",
|
||||
header: "Waktu",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">{row.getValue("time")}</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("startTime")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "loccation",
|
||||
accessorKey: "address",
|
||||
header: "Lokasi",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-nowrap">{row.getValue("loccation")}</span>
|
||||
<span className="whitespace-nowrap">{row.getValue("address")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<span className="whitespace-nowrap text-blue-600">
|
||||
{row.getValue("status")}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "speakerName",
|
||||
header: "Disampaikan oleh",
|
||||
|
|
@ -115,17 +143,7 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
<span className="whitespace-nowrap">{row.getValue("uploaderName")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<span className="whitespace-nowrap text-blue-600">
|
||||
{row.getValue("status")}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
id: "actions",
|
||||
accessorKey: "action",
|
||||
|
|
@ -163,7 +181,10 @@ export const columns: ColumnDef<CompanyData>[] = [
|
|||
},
|
||||
];
|
||||
|
||||
const PressConferenceTable = () => {
|
||||
const PressReleaseTable = () => {
|
||||
const [pressReleaseTable, setPressReleaseTable] = React.useState<
|
||||
CompanyData[]
|
||||
>([]);
|
||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
||||
[]
|
||||
|
|
@ -173,11 +194,14 @@ const PressConferenceTable = () => {
|
|||
const [rowSelection, setRowSelection] = React.useState({});
|
||||
const [pagination, setPagination] = React.useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 6,
|
||||
pageSize: 10,
|
||||
});
|
||||
const [page, setPage] = React.useState(1);
|
||||
const [totalPage, setTotalPage] = React.useState(1);
|
||||
const [limit, setLimit] = React.useState(10);
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
data: pressReleaseTable,
|
||||
columns,
|
||||
onSortingChange: setSorting,
|
||||
onColumnFiltersChange: setColumnFilters,
|
||||
|
|
@ -197,6 +221,31 @@ const PressConferenceTable = () => {
|
|||
},
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
initState();
|
||||
}, [page, limit]);
|
||||
|
||||
async function initState() {
|
||||
try {
|
||||
const res = await paginationSchedule(limit, page, 3);
|
||||
const data = res.data.data.content.map((item: any, index: number) => ({
|
||||
no: (page - 1) * limit + index + 1,
|
||||
title: item.title,
|
||||
startDate: item.startDate,
|
||||
endDate: item.endDate,
|
||||
startTime: item.startTime,
|
||||
address: item.address,
|
||||
uploaderName: item.uploaderName,
|
||||
speakerName: item.speakerName,
|
||||
}));
|
||||
|
||||
setPressReleaseTable(data);
|
||||
setTotalPage(res.data.totalPages);
|
||||
} catch (error) {
|
||||
console.error("Error fetching tasks:", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<div className="flex justify-between items-center py-4 px-5">
|
||||
|
|
@ -305,4 +354,4 @@ const PressConferenceTable = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export default PressConferenceTable;
|
||||
export default PressReleaseTable;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"use client";
|
||||
import React, { ChangeEvent, useRef, useState } from "react";
|
||||
import React, { ChangeEvent, useEffect, useRef, useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
|
@ -22,36 +22,49 @@ import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
|||
import JoditEditor from "jodit-react";
|
||||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import {
|
||||
getTagsBySubCategoryId,
|
||||
listEnableCategory,
|
||||
} from "@/service/content/content";
|
||||
import { data } from "jquery";
|
||||
|
||||
const taskSchema = z.object({
|
||||
title: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
naration: z.string().min(2, {
|
||||
description: z.string().min(2, {
|
||||
message: "Narasi Penugasan harus lebih dari 2 karakter.",
|
||||
}),
|
||||
categoryId: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
creator: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
tags: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
});
|
||||
|
||||
type Category = {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export default function FormImage() {
|
||||
const MySwal = withReactContent(Swal);
|
||||
const router = useRouter();
|
||||
const editor = useRef(null);
|
||||
type TaskSchema = z.infer<typeof taskSchema>;
|
||||
const [tags, setTags] = useState<string[]>([]);
|
||||
const [selectedFiles, setSelectedFiles] = useState<File[]>([]);
|
||||
|
||||
// State for various form fields
|
||||
const [output, setOutput] = useState({
|
||||
all: false,
|
||||
video: false,
|
||||
audio: false,
|
||||
image: false,
|
||||
text: false,
|
||||
});
|
||||
const [selectedFiles, setSelectedFiles] = useState<File[]>([]);
|
||||
const taskId = Cookies.get("taskId");
|
||||
|
||||
const [assignmentType, setAssignmentType] = useState("mediahub");
|
||||
const [assignmentCategory, setAssignmentCategory] = useState("publication");
|
||||
|
||||
const scheduleId = Cookies.get("scheduleId");
|
||||
const scheduleType = Cookies.get("scheduleType");
|
||||
|
||||
const [categories, setCategories] = useState<Category[]>([]);
|
||||
const [selectedCategory, setSelectedCategory] = useState<
|
||||
string | undefined
|
||||
>();
|
||||
const [tags, setTags] = useState<any[]>([]);
|
||||
|
||||
const [selectedTarget, setSelectedTarget] = useState("all");
|
||||
const [unitSelection, setUnitSelection] = useState({
|
||||
allUnit: false,
|
||||
|
|
@ -60,6 +73,8 @@ export default function FormImage() {
|
|||
polres: false,
|
||||
});
|
||||
|
||||
let fileTypeId = "";
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
|
|
@ -92,6 +107,45 @@ export default function FormImage() {
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
async function initState() {
|
||||
getCategories();
|
||||
// setVideoActive(fileTypeId == '2');
|
||||
// getRoles();
|
||||
}
|
||||
|
||||
initState();
|
||||
}, []);
|
||||
|
||||
const getCategories = async () => {
|
||||
try {
|
||||
const category = await listEnableCategory(fileTypeId);
|
||||
const resCategory: Category[] = category.data.data.content;
|
||||
|
||||
setCategories(resCategory);
|
||||
console.log("data category", resCategory);
|
||||
|
||||
if (scheduleId && scheduleType === "3") {
|
||||
const findCategory = resCategory.find((o) =>
|
||||
o.name.toLowerCase().includes("pers rilis")
|
||||
);
|
||||
|
||||
if (findCategory) {
|
||||
setValue("categoryId", findCategory.id);
|
||||
setSelectedCategory(findCategory.id); // Set the selected category
|
||||
const response = await getTagsBySubCategoryId(findCategory.id);
|
||||
setTags(response?.data.data);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch categories:", error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getCategories();
|
||||
}, []);
|
||||
|
||||
const handleRemoveImage = (index: number) => {
|
||||
setSelectedFiles((prevImages) => prevImages.filter((_, i) => i !== index));
|
||||
};
|
||||
|
|
@ -99,7 +153,6 @@ export default function FormImage() {
|
|||
const save = async (data: TaskSchema) => {
|
||||
const requestData = {
|
||||
...data,
|
||||
output,
|
||||
assignmentType,
|
||||
assignmentCategory,
|
||||
target: selectedTarget,
|
||||
|
|
@ -164,26 +217,46 @@ export default function FormImage() {
|
|||
</div>
|
||||
<div className="flex items-center">
|
||||
<div className="py-3 w-full">
|
||||
<Label>Kategory</Label>
|
||||
<Select onValueChange={setSelectedTarget}>
|
||||
<SelectTrigger size="md">
|
||||
<SelectValue placeholder="Pilih" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">Mediapool</SelectItem>
|
||||
<SelectItem value="contributor">
|
||||
Liputan Kegiatan
|
||||
</SelectItem>
|
||||
<SelectItem value="approver">Press Tour</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Label>Kategori</Label>
|
||||
<Controller
|
||||
name="categoryId"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
value={field.value} // Pastikan nilai berasal dari form state
|
||||
onValueChange={(value) => {
|
||||
setSelectedCategory(value); // Perbarui state lokal
|
||||
field.onChange(value); // Perbarui form state
|
||||
}}
|
||||
>
|
||||
<SelectTrigger size="md">
|
||||
<SelectValue>
|
||||
{categories.find((cat) => cat.id === field.value)
|
||||
?.name || "Pilih"}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{categories.map((category) => (
|
||||
<SelectItem key={category.id} value={category.id}>
|
||||
{category.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
{errors.categoryId?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.categoryId.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="py-3">
|
||||
<Label>Deskripsi</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="naration"
|
||||
name="description"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<JoditEditor
|
||||
ref={editor}
|
||||
|
|
@ -193,9 +266,9 @@ export default function FormImage() {
|
|||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.naration?.message && (
|
||||
{errors.description?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.naration.message}
|
||||
{errors.description.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import Cookies from "js-cookie";
|
||||
|
||||
import { getAPI, postAPI, postAPIWithJson } from "../config/api";
|
||||
import { getAPIDummy } from "./http-config/axiosCustom";
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
|||
|
||||
export async function paginationBlog(size: number, page: number) {
|
||||
return await httpGetInterceptor(
|
||||
`blog/pagination?enablePage=1&page=${page}&size=${size}`
|
||||
`blog/pagination?enablePage=0&page=${page}&size=${size}`
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import {
|
|||
httpPostInterceptor,
|
||||
} from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function listTicketingInternal(page: number) {
|
||||
export async function listTicketingInternal(page: number, size: any) {
|
||||
return await httpGetInterceptor(
|
||||
`ticketing/internal/pagination?enablePage=1&size=10&page=${page}`
|
||||
`ticketing/internal/pagination?enablePage=0&size=${size}&page=${page}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { getAPI, getAPIInterceptor, postAPI } from "@/config/api";
|
||||
import {
|
||||
httpGetInterceptor,
|
||||
httpGetInterceptorWithToken,
|
||||
} from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function listDataImage(
|
||||
page: any,
|
||||
|
|
@ -15,7 +18,7 @@ export async function listDataImage(
|
|||
endDate: any
|
||||
) {
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=1&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
`media/list?enablePage=0&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=1&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +36,7 @@ export async function listDataVideo(
|
|||
endDate: any
|
||||
) {
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=2&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
`media/list?enablePage=0&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=2&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +54,7 @@ export async function listDataTeks(
|
|||
endDate: any
|
||||
) {
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=3&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
`media/list?enablePage=0&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=3&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +72,7 @@ export async function listDataAudio(
|
|||
endDate: any
|
||||
) {
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=4&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
`media/list?enablePage=0&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=4&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -83,3 +86,14 @@ export async function listSPIT(
|
|||
`media/spit/pagination?enablePage=1&page=${page}&size=${limit}&sort=desc&sortBy=contentTitleId&title=${title}&isPublish=${isPublish}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function getTagsBySubCategoryId(subCategory: any) {
|
||||
return await httpGetInterceptor(
|
||||
`media/tags/list?subCategoryId=${subCategory}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function listEnableCategory(type: any) {
|
||||
const url = `media/categories/list/enable?enablePage=0&sort=desc&sortBy=id&type=${type}`;
|
||||
return getAPIInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ export async function getPlanningSentPagination(
|
|||
typeId: number
|
||||
) {
|
||||
return await httpGetInterceptor(
|
||||
`planning/pagination/sent?enablePage=1&size=${size}&page=${page}&typeId=${typeId}`
|
||||
`planning/pagination/sent?enablePage=0&size=${size}&page=${page}&typeId=${typeId}`
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import { title } from "process";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { type } from "os";
|
||||
|
||||
export async function paginationSchedule(
|
||||
size: number,
|
||||
page: number,
|
||||
type: any
|
||||
) {
|
||||
return await httpGetInterceptor(
|
||||
`schedule/pagination?enablePage=1&scheduleTypeId=${type}&page=${page}&size=${size}`
|
||||
);
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ import {
|
|||
// }
|
||||
|
||||
export async function listTask(page: any, limit: any) {
|
||||
const url = `assignment/list?size=${limit}&page=${page}`;
|
||||
const url = `assignment/list?enablePage=0&size=${limit}&page=${page}`;
|
||||
return getAPIInterceptor(url);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue