fix:menu satker, create category

This commit is contained in:
Rama Priyanto 2025-01-13 11:50:39 +07:00
parent 332b589866
commit b02622ff50
4 changed files with 227 additions and 137 deletions

View File

@ -37,6 +37,8 @@ import { useDropzone } from "react-dropzone";
import { CloudUpload } from "lucide-react";
import Image from "next/image";
import { Upload } from "tus-js-client";
import { getCookiesDecrypt } from "@/lib/utils";
import Cookies from "js-cookie";
const FormSchema = z.object({
title: z.string({
@ -103,6 +105,10 @@ const publishToList = [
export default function CreateCategoryModal() {
const router = useRouter();
const { toast } = useToast();
const roleId = getCookiesDecrypt("urie");
const levelNumber = getCookiesDecrypt("ulne");
const userLevelId = getCookiesDecrypt("ulie");
const poldaState = Cookies.get("state");
const [files, setFiles] = useState<File[]>([]);
const [isOpen, setIsOpen] = useState(false);
@ -139,6 +145,14 @@ export default function CreateCategoryModal() {
useEffect(() => {
getRoles();
if (Number(levelNumber) === 2) {
form.setValue("publishTo", ["polda"]);
setUnitData([String(userLevelId)]);
}
if (Number(levelNumber) === 3) {
form.setValue("publishTo", ["satker"]);
setSatkerData([String(userLevelId)]);
}
}, []);
async function getRoles() {
@ -176,7 +190,7 @@ export default function CreateCategoryModal() {
const save = async (data: z.infer<typeof FormSchema>) => {
const formMedia = new FormData();
loading();
// loading();
const unit = unitData?.join(",");
const satker = satkerData?.join(",");
@ -196,6 +210,10 @@ export default function CreateCategoryModal() {
formMedia.append("file", files[0]);
formMedia.append("publishedLocation", data.publishTo.sort().join(","));
formMedia.append("publishedLocationLevel", join);
formMedia.append(
"isInt",
data.publishTo.includes("internasional") ? "true" : "false"
);
const response = await postCategory(formMedia);
close();
@ -374,6 +392,7 @@ export default function CreateCategoryModal() {
</FormItem>
)}
/>
{Number(levelNumber) === 1 ? (
<FormField
control={form.control}
name="publishTo"
@ -462,6 +481,28 @@ export default function CreateCategoryModal() {
</FormItem>
)}
/>
) : (
<FormField
control={form.control}
name="publishTo"
render={() => (
<FormItem>
<FormLabel>Wilayah Publish</FormLabel>
<div className="flex flex-row items-center gap-2">
<div className="flex gap-3 items-center">
<Checkbox disabled checked />
<label htmlFor="all" className="text-sm">
{poldaState}
</label>
</div>
</div>
<FormMessage />
</FormItem>
)}
/>
)}
<FormField
control={form.control}
name="title"

View File

@ -2712,7 +2712,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
],
},
];
} else {
} else if (Number(levelNumber) == 2) {
menusSelected = [
{
groupLabel: t("apps"),
@ -2724,53 +2724,11 @@ export function getMenuList(pathname: string, t: any): Group[] {
label: t("dashboard"),
active: pathname.includes("/dashboard"),
icon: "material-symbols:dashboard",
submenus: [
{
href: "/dashboard",
label: "Breakdown",
active: pathname === "/dashboard",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/dashboard/executive",
label: "Executive",
active: pathname === "/dashboard/executive",
icon: "heroicons:arrow-trending-up",
children: [],
},
],
},
],
},
{
groupLabel: "",
id: "agenda-setting",
menus: [
{
id: "agenda-setting",
href: "/contributor/agenda-setting",
label: t("agenda-setting"),
active: pathname.includes("/agenda-setting"),
icon: "iconoir:journal-page",
submenus: [],
},
],
},
{
groupLabel: "",
id: "management-user",
menus: [
{
id: "management-user-menu",
href: "/admin/management-user",
label: "Management User",
active: pathname.includes("/management-user"),
icon: "clarity:users-solid",
submenus: [],
},
],
},
{
groupLabel: "",
id: "content-production",
@ -2801,13 +2759,13 @@ export function getMenuList(pathname: string, t: any): Group[] {
},
{
groupLabel: "",
id: "performance-polda",
id: "performance-polres",
menus: [
{
id: "performance-polda",
href: "/admin/performance-polda",
label: t("performance-polda"),
active: pathname.includes("/admin/performance-polda"),
id: "performance-polres",
href: "/admin/performance-polres",
label: t("performance-polres"),
active: pathname.includes("/admin/performance-polres"),
icon: "ant-design:signal-filled",
submenus: [],
},
@ -2851,7 +2809,96 @@ export function getMenuList(pathname: string, t: any): Group[] {
active: pathname === "/admin/settings/tag",
icon: "heroicons:arrow-trending-up",
children: [],
}
},
],
},
],
},
];
} else {
menusSelected = [
{
groupLabel: t("apps"),
id: "dashboard",
menus: [
{
id: "dashboard",
href: "/dashboard",
label: t("dashboard"),
active: pathname.includes("/dashboard"),
icon: "material-symbols:dashboard",
submenus: [],
},
],
},
{
groupLabel: "",
id: "content-production",
menus: [
{
id: "content-production",
href: "/curator/content-production",
label: t("content-production"),
active: pathname.includes("/content-production"),
icon: "fluent:content-view-gallery-16-regular",
submenus: [],
},
],
},
{
groupLabel: "",
id: "pattern-relation",
menus: [
{
id: "pattern-relation",
href: "/curator/pattern-relation",
label: t("pattern-relation"),
active: pathname.includes("/pattern-relation"),
icon: "oui:app-index-pattern",
submenus: [],
},
],
},
{
groupLabel: "",
id: "communication",
menus: [
{
id: "communication",
href: "/shared/communication",
label: t("communication"),
active: pathname.includes("/communication"),
icon: "token:chat",
submenus: [],
},
],
},
{
groupLabel: "",
id: "settings",
menus: [
{
id: "settings",
href: "/admin/settings",
label: t("settings"),
active: pathname.includes("/settinng"),
icon: "material-symbols:settings",
submenus: [
{
href: "/admin/settings/category",
label: t("category"),
active: pathname === "/admin/settings/category",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/tag",
label: "Tag",
active: pathname === "/admin/settings/tag",
icon: "heroicons:arrow-trending-up",
children: [],
},
],
},
],

View File

@ -296,6 +296,7 @@
"typography": "Typography",
"colors": "Colors",
"performance-polda": "Performance Polda",
"performance-polres": "Performance Polres",
"analysis": "Analysis",
"management-content": "Content Management ",
"add-experts": "Add Experts",

View File

@ -296,6 +296,7 @@
"typography": "Typography",
"colors": "Colors",
"performance-polda": "Performa Polda",
"performance-polres": "Performa Polres",
"analysis": "Analisa",
"management-content": "Manajemen Konten",
"add-experts": "Tambah Tenaga Ahli",