fix:menu satker, create category
This commit is contained in:
parent
332b589866
commit
b02622ff50
|
|
@ -37,6 +37,8 @@ import { useDropzone } from "react-dropzone";
|
||||||
import { CloudUpload } from "lucide-react";
|
import { CloudUpload } from "lucide-react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { Upload } from "tus-js-client";
|
import { Upload } from "tus-js-client";
|
||||||
|
import { getCookiesDecrypt } from "@/lib/utils";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
title: z.string({
|
title: z.string({
|
||||||
|
|
@ -103,6 +105,10 @@ const publishToList = [
|
||||||
export default function CreateCategoryModal() {
|
export default function CreateCategoryModal() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { toast } = useToast();
|
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 [files, setFiles] = useState<File[]>([]);
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
@ -139,6 +145,14 @@ export default function CreateCategoryModal() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getRoles();
|
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() {
|
async function getRoles() {
|
||||||
|
|
@ -176,7 +190,7 @@ export default function CreateCategoryModal() {
|
||||||
const save = async (data: z.infer<typeof FormSchema>) => {
|
const save = async (data: z.infer<typeof FormSchema>) => {
|
||||||
const formMedia = new FormData();
|
const formMedia = new FormData();
|
||||||
|
|
||||||
loading();
|
// loading();
|
||||||
|
|
||||||
const unit = unitData?.join(",");
|
const unit = unitData?.join(",");
|
||||||
const satker = satkerData?.join(",");
|
const satker = satkerData?.join(",");
|
||||||
|
|
@ -196,6 +210,10 @@ export default function CreateCategoryModal() {
|
||||||
formMedia.append("file", files[0]);
|
formMedia.append("file", files[0]);
|
||||||
formMedia.append("publishedLocation", data.publishTo.sort().join(","));
|
formMedia.append("publishedLocation", data.publishTo.sort().join(","));
|
||||||
formMedia.append("publishedLocationLevel", join);
|
formMedia.append("publishedLocationLevel", join);
|
||||||
|
formMedia.append(
|
||||||
|
"isInt",
|
||||||
|
data.publishTo.includes("internasional") ? "true" : "false"
|
||||||
|
);
|
||||||
|
|
||||||
const response = await postCategory(formMedia);
|
const response = await postCategory(formMedia);
|
||||||
close();
|
close();
|
||||||
|
|
@ -374,94 +392,117 @@ export default function CreateCategoryModal() {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
{Number(levelNumber) === 1 ? (
|
||||||
control={form.control}
|
<FormField
|
||||||
name="publishTo"
|
control={form.control}
|
||||||
render={() => (
|
name="publishTo"
|
||||||
<FormItem>
|
render={() => (
|
||||||
<FormLabel>Wilayah Publish</FormLabel>
|
<FormItem>
|
||||||
|
<FormLabel>Wilayah Publish</FormLabel>
|
||||||
|
|
||||||
<div className="flex flex-row items-center gap-2">
|
<div className="flex flex-row items-center gap-2">
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="all"
|
id="all"
|
||||||
checked={isAllTargetChecked}
|
checked={isAllTargetChecked}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"publishTo",
|
"publishTo",
|
||||||
publishToList.map((item) => item.id)
|
publishToList.map((item) => item.id)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
form.setValue("publishTo", []);
|
form.setValue("publishTo", []);
|
||||||
}
|
}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<label htmlFor="all" className="text-sm">
|
|
||||||
Semua
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{publishToList.map((item) => (
|
|
||||||
<>
|
|
||||||
<FormField
|
|
||||||
key={item.id}
|
|
||||||
control={form.control}
|
|
||||||
name="publishTo"
|
|
||||||
render={({ field }) => {
|
|
||||||
return (
|
|
||||||
<FormItem
|
|
||||||
key={item.id}
|
|
||||||
className="flex flex-row items-start "
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<FormControl>
|
|
||||||
<Checkbox
|
|
||||||
checked={field.value?.includes(item.id)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
return checked
|
|
||||||
? field.onChange([
|
|
||||||
...field.value,
|
|
||||||
item.id,
|
|
||||||
])
|
|
||||||
: field.onChange(
|
|
||||||
field.value?.filter(
|
|
||||||
(value) => value !== item.id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormLabel className="font-normal">
|
|
||||||
{item.name}{" "}
|
|
||||||
</FormLabel>
|
|
||||||
</div>
|
|
||||||
</FormItem>
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{item.id === "polda" &&
|
<label htmlFor="all" className="text-sm">
|
||||||
form.getValues("publishTo")?.includes(item.id) && (
|
Semua
|
||||||
<UnitMapping
|
</label>
|
||||||
unit="Polda"
|
</div>
|
||||||
isDetail={false}
|
{publishToList.map((item) => (
|
||||||
sendDataToParent={(data) => setUnitData(data)}
|
<>
|
||||||
/>
|
<FormField
|
||||||
)}
|
key={item.id}
|
||||||
{item.id === "satker" &&
|
control={form.control}
|
||||||
form.getValues("publishTo")?.includes(item.id) && (
|
name="publishTo"
|
||||||
<UnitMapping
|
render={({ field }) => {
|
||||||
isDetail={false}
|
return (
|
||||||
unit="Satker"
|
<FormItem
|
||||||
sendDataToParent={(data) => setSatkerData(data)}
|
key={item.id}
|
||||||
/>
|
className="flex flex-row items-start "
|
||||||
)}
|
>
|
||||||
</>
|
<div className="flex items-center gap-3">
|
||||||
))}
|
<FormControl>
|
||||||
</div>
|
<Checkbox
|
||||||
<FormMessage />
|
checked={field.value?.includes(item.id)}
|
||||||
</FormItem>
|
onCheckedChange={(checked) => {
|
||||||
)}
|
return checked
|
||||||
/>
|
? field.onChange([
|
||||||
|
...field.value,
|
||||||
|
item.id,
|
||||||
|
])
|
||||||
|
: field.onChange(
|
||||||
|
field.value?.filter(
|
||||||
|
(value) => value !== item.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormLabel className="font-normal">
|
||||||
|
{item.name}{" "}
|
||||||
|
</FormLabel>
|
||||||
|
</div>
|
||||||
|
</FormItem>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{item.id === "polda" &&
|
||||||
|
form.getValues("publishTo")?.includes(item.id) && (
|
||||||
|
<UnitMapping
|
||||||
|
unit="Polda"
|
||||||
|
isDetail={false}
|
||||||
|
sendDataToParent={(data) => setUnitData(data)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{item.id === "satker" &&
|
||||||
|
form.getValues("publishTo")?.includes(item.id) && (
|
||||||
|
<UnitMapping
|
||||||
|
isDetail={false}
|
||||||
|
unit="Satker"
|
||||||
|
sendDataToParent={(data) => setSatkerData(data)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<FormMessage />
|
||||||
|
</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
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="title"
|
name="title"
|
||||||
|
|
|
||||||
147
lib/menus.ts
147
lib/menus.ts
|
|
@ -2712,7 +2712,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
} else {
|
} else if (Number(levelNumber) == 2) {
|
||||||
menusSelected = [
|
menusSelected = [
|
||||||
{
|
{
|
||||||
groupLabel: t("apps"),
|
groupLabel: t("apps"),
|
||||||
|
|
@ -2724,53 +2724,11 @@ export function getMenuList(pathname: string, t: any): Group[] {
|
||||||
label: t("dashboard"),
|
label: t("dashboard"),
|
||||||
active: pathname.includes("/dashboard"),
|
active: pathname.includes("/dashboard"),
|
||||||
icon: "material-symbols: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: [],
|
submenus: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
groupLabel: "",
|
groupLabel: "",
|
||||||
id: "content-production",
|
id: "content-production",
|
||||||
|
|
@ -2801,13 +2759,13 @@ export function getMenuList(pathname: string, t: any): Group[] {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
groupLabel: "",
|
groupLabel: "",
|
||||||
id: "performance-polda",
|
id: "performance-polres",
|
||||||
menus: [
|
menus: [
|
||||||
{
|
{
|
||||||
id: "performance-polda",
|
id: "performance-polres",
|
||||||
href: "/admin/performance-polda",
|
href: "/admin/performance-polres",
|
||||||
label: t("performance-polda"),
|
label: t("performance-polres"),
|
||||||
active: pathname.includes("/admin/performance-polda"),
|
active: pathname.includes("/admin/performance-polres"),
|
||||||
icon: "ant-design:signal-filled",
|
icon: "ant-design:signal-filled",
|
||||||
submenus: [],
|
submenus: [],
|
||||||
},
|
},
|
||||||
|
|
@ -2851,7 +2809,96 @@ export function getMenuList(pathname: string, t: any): Group[] {
|
||||||
active: pathname === "/admin/settings/tag",
|
active: pathname === "/admin/settings/tag",
|
||||||
icon: "heroicons:arrow-trending-up",
|
icon: "heroicons:arrow-trending-up",
|
||||||
children: [],
|
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: [],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,7 @@
|
||||||
"typography": "Typography",
|
"typography": "Typography",
|
||||||
"colors": "Colors",
|
"colors": "Colors",
|
||||||
"performance-polda": "Performance Polda",
|
"performance-polda": "Performance Polda",
|
||||||
|
"performance-polres": "Performance Polres",
|
||||||
"analysis": "Analysis",
|
"analysis": "Analysis",
|
||||||
"management-content": "Content Management ",
|
"management-content": "Content Management ",
|
||||||
"add-experts": "Add Experts",
|
"add-experts": "Add Experts",
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,7 @@
|
||||||
"typography": "Typography",
|
"typography": "Typography",
|
||||||
"colors": "Colors",
|
"colors": "Colors",
|
||||||
"performance-polda": "Performa Polda",
|
"performance-polda": "Performa Polda",
|
||||||
|
"performance-polres": "Performa Polres",
|
||||||
"analysis": "Analisa",
|
"analysis": "Analisa",
|
||||||
"management-content": "Manajemen Konten",
|
"management-content": "Manajemen Konten",
|
||||||
"add-experts": "Tambah Tenaga Ahli",
|
"add-experts": "Tambah Tenaga Ahli",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue