fix:avertise form
This commit is contained in:
parent
0cf395cf59
commit
d428928150
|
|
@ -12,6 +12,8 @@ import {
|
||||||
ModalContent,
|
ModalContent,
|
||||||
ModalFooter,
|
ModalFooter,
|
||||||
ModalHeader,
|
ModalHeader,
|
||||||
|
Radio,
|
||||||
|
RadioGroup,
|
||||||
Switch,
|
Switch,
|
||||||
Textarea,
|
Textarea,
|
||||||
useDisclosure,
|
useDisclosure,
|
||||||
|
|
@ -46,7 +48,7 @@ export default function AdvertisePage() {
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
|
|
||||||
const [refresh, setRefresh] = useState(false);
|
const [refresh, setRefresh] = useState(false);
|
||||||
const [isHeader, setIsHeader] = useState(false);
|
const [placement, setPlacement] = useState("banner");
|
||||||
|
|
||||||
const [files, setFiles] = useState<File[]>([]);
|
const [files, setFiles] = useState<File[]>([]);
|
||||||
|
|
||||||
|
|
@ -76,7 +78,7 @@ export default function AdvertisePage() {
|
||||||
const formData = {
|
const formData = {
|
||||||
title: values.title,
|
title: values.title,
|
||||||
description: values.description,
|
description: values.description,
|
||||||
isHeader: isHeader,
|
placement: placement,
|
||||||
url: values.url,
|
url: values.url,
|
||||||
};
|
};
|
||||||
close();
|
close();
|
||||||
|
|
@ -219,14 +221,17 @@ export default function AdvertisePage() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-sm mt-3">Header</p>
|
<p className="text-sm mt-3">Penempatan</p>
|
||||||
<Switch
|
<RadioGroup
|
||||||
|
label=""
|
||||||
|
orientation="horizontal"
|
||||||
size="sm"
|
size="sm"
|
||||||
isSelected={isHeader}
|
value={placement}
|
||||||
onValueChange={setIsHeader}
|
onValueChange={setPlacement}
|
||||||
>
|
>
|
||||||
<p className="text-sm"> {isHeader ? "Ya" : "Tidak"}</p>
|
<Radio value="banner">Banner</Radio>
|
||||||
</Switch>
|
<Radio value="jumbotron">Jumbotron</Radio>
|
||||||
|
</RadioGroup>
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<p className="text-sm mt-3">Thumbnail</p>
|
<p className="text-sm mt-3">Thumbnail</p>
|
||||||
{files.length < 1 && (
|
{files.length < 1 && (
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import Login from "@/components/form/login";
|
import Login from "@/components/form/login";
|
||||||
import QudoLogin from "@/components/form/qudo-login";
|
|
||||||
import Cookies from "js-cookie";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
export default function AuthPage() {
|
export default function AuthPage() {
|
||||||
// const isAuthenticated = Cookies.get("is_authenticated") || "false";
|
// const isAuthenticated = Cookies.get("is_authenticated") || "false";
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ import {
|
||||||
} from "@/service/generate-article";
|
} from "@/service/generate-article";
|
||||||
import GenerateContentRewriteForm from "./generate-ai-content-rewrite-form";
|
import GenerateContentRewriteForm from "./generate-ai-content-rewrite-form";
|
||||||
import Datepicker from "react-tailwindcss-datepicker";
|
import Datepicker from "react-tailwindcss-datepicker";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
import { getUserLevels } from "@/services/user-levels/user-levels-service";
|
||||||
|
|
||||||
const CustomEditor = dynamic(
|
const CustomEditor = dynamic(
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -112,7 +114,7 @@ const createArticleSchema = z.object({
|
||||||
|
|
||||||
export default function CreateArticleForm() {
|
export default function CreateArticleForm() {
|
||||||
const { isOpen, onOpen, onOpenChange } = useDisclosure();
|
const { isOpen, onOpen, onOpenChange } = useDisclosure();
|
||||||
|
const userLevel = Cookies.get("ulne");
|
||||||
const animatedComponents = makeAnimated();
|
const animatedComponents = makeAnimated();
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -285,8 +287,16 @@ export default function CreateArticleForm() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getUserLevelApprovalStatus = async () => {
|
||||||
|
const res = await getUserLevels(String(userLevel));
|
||||||
|
console.log("res", res?.data?.data?.isApprovalActive);
|
||||||
|
return res?.data?.data?.isApprovalActive;
|
||||||
|
};
|
||||||
|
|
||||||
const save = async (values: z.infer<typeof createArticleSchema>) => {
|
const save = async (values: z.infer<typeof createArticleSchema>) => {
|
||||||
loading();
|
loading();
|
||||||
|
|
||||||
|
const userLevelStatus = await getUserLevelApprovalStatus();
|
||||||
const formData = {
|
const formData = {
|
||||||
title: values.title,
|
title: values.title,
|
||||||
typeId: 1,
|
typeId: 1,
|
||||||
|
|
@ -296,14 +306,12 @@ export default function CreateArticleForm() {
|
||||||
description: htmlToString(removeImgTags(values.description)),
|
description: htmlToString(removeImgTags(values.description)),
|
||||||
htmlDescription: removeImgTags(values.description),
|
htmlDescription: removeImgTags(values.description),
|
||||||
aiArticleId: await saveArticleToDise(values),
|
aiArticleId: await saveArticleToDise(values),
|
||||||
|
// isDraft: userLevelStatus ? true : status === "draft",
|
||||||
|
// isPublish: userLevelStatus ? false : status === "publish",
|
||||||
isDraft: status === "draft",
|
isDraft: status === "draft",
|
||||||
isPublish: status === "publish",
|
isPublish: status === "publish",
|
||||||
};
|
};
|
||||||
console.log(
|
|
||||||
"ssada",
|
|
||||||
formData,
|
|
||||||
`${startDateValue.year}-${startDateValue.month}-${startDateValue.day}`
|
|
||||||
);
|
|
||||||
const response = await createArticle(formData);
|
const response = await createArticle(formData);
|
||||||
|
|
||||||
if (response?.error) {
|
if (response?.error) {
|
||||||
|
|
@ -340,7 +348,7 @@ export default function CreateArticleForm() {
|
||||||
if (status === "scheduled") {
|
if (status === "scheduled") {
|
||||||
const request = {
|
const request = {
|
||||||
id: articleId,
|
id: articleId,
|
||||||
date: `${startDateValue.year}-${startDateValue.month}-${startDateValue.day}`,
|
date: `${startDateValue?.year}-${startDateValue?.month}-${startDateValue?.day}`,
|
||||||
};
|
};
|
||||||
const res = await createArticleSchedule(request);
|
const res = await createArticleSchedule(request);
|
||||||
}
|
}
|
||||||
|
|
@ -659,7 +667,7 @@ export default function CreateArticleForm() {
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
size="sm"
|
size="sm"
|
||||||
color="danger"
|
color="danger"
|
||||||
onClick={() => setThumbnailImg([])}
|
onPress={() => setThumbnailImg([])}
|
||||||
>
|
>
|
||||||
<TimesIcon />
|
<TimesIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -789,15 +797,6 @@ export default function CreateArticleForm() {
|
||||||
<div className="flex flex-col lg:flex-row gap-3">
|
<div className="flex flex-col lg:flex-row gap-3">
|
||||||
<div className="w-full lg:w-[140px] flex flex-col gal-2 ">
|
<div className="w-full lg:w-[140px] flex flex-col gal-2 ">
|
||||||
<p className="text-sm">Tanggal</p>
|
<p className="text-sm">Tanggal</p>
|
||||||
{/* <Datepicker
|
|
||||||
value={startDateValue}
|
|
||||||
displayFormat="DD/MM/YYYY"
|
|
||||||
popoverDirection="down"
|
|
||||||
asSingle={true}
|
|
||||||
useRange={false}
|
|
||||||
onChange={(e: any) => setStartDateValue(e)}
|
|
||||||
inputClassName="z-50 w-full text-xs lg:text-sm bg-white dark bg-black border-1 border-gray-200 px-2 py-[6px] rounded-sm lg:rounded-lg h-[30px] lg:h-[40px] text-gray-600 dark:text-gray-300"
|
|
||||||
/> */}
|
|
||||||
<Popover
|
<Popover
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
classNames={{ content: ["!bg-transparent", "p-0"] }}
|
classNames={{ content: ["!bg-transparent", "p-0"] }}
|
||||||
|
|
@ -820,25 +819,6 @@ export default function CreateArticleForm() {
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
{/* <div className="w-[140px] flex flex-col gal-2 ">
|
|
||||||
<p className="text-sm">Waktu</p>
|
|
||||||
<Input
|
|
||||||
type="time"
|
|
||||||
value={timeValue}
|
|
||||||
onValueChange={setTimeValue}
|
|
||||||
variant="bordered"
|
|
||||||
className="w-full"
|
|
||||||
classNames={{
|
|
||||||
input: "h-[30px]",
|
|
||||||
mainWrapper: ["bg-white !h-[30px] lg:h-[40px]"],
|
|
||||||
innerWrapper: "!h-[30px] lg:h-[40px]",
|
|
||||||
inputWrapper: [
|
|
||||||
"border-1 rounded-lg !h-[30px] lg:h-[40px]",
|
|
||||||
"dark:group-data-[focused=false]:bg-transparent !border-1 dark:!border-gray-400",
|
|
||||||
],
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div> */}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -875,6 +875,7 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
||||||
|
|
||||||
<div className="flex flex-row justify-end gap-3">
|
<div className="flex flex-row justify-end gap-3">
|
||||||
{isDetail &&
|
{isDetail &&
|
||||||
|
username === "admin-mabes" &&
|
||||||
(detailData?.statusId === 1 || detailData?.statusId === null) && (
|
(detailData?.statusId === 1 || detailData?.statusId === null) && (
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ export default function Login() {
|
||||||
Cookies.set("masterPoldaId", profile?.data?.data?.masterPoldaId, {
|
Cookies.set("masterPoldaId", profile?.data?.data?.masterPoldaId, {
|
||||||
expires: 1,
|
expires: 1,
|
||||||
});
|
});
|
||||||
Cookies.set("ulne", profile?.data?.data?.roleLevelNumber, {
|
Cookies.set("ulne", profile?.data?.data?.userLevelId, {
|
||||||
expires: 1,
|
expires: 1,
|
||||||
});
|
});
|
||||||
Cookies.set("urce", profile?.data?.data?.roleCode, {
|
Cookies.set("urce", profile?.data?.data?.roleCode, {
|
||||||
|
|
@ -151,15 +151,20 @@ export default function Login() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row h-full">
|
<div className="flex flex-row h-full">
|
||||||
<div
|
<div
|
||||||
style={{
|
// style={{
|
||||||
backgroundImage: "url(headerbanner1.png)",
|
// backgroundImage: "url(headerbanner1.png)",
|
||||||
backgroundRepeat: "no-repeat",
|
// backgroundRepeat: "no-repeat",
|
||||||
backgroundSize: "cover",
|
// backgroundSize: "cover",
|
||||||
backgroundPosition: "left center",
|
// backgroundPosition: "left center",
|
||||||
}}
|
// }}
|
||||||
className="h-screen hidden md:block md:w-3/5"
|
className="h-screen hidden md:block md:w-3/5"
|
||||||
>
|
>
|
||||||
<Link href="/">
|
<Image
|
||||||
|
src="/headerbanner1.png"
|
||||||
|
alt="login-image"
|
||||||
|
className="w-full h-screen rounded-none object-cover"
|
||||||
|
/>
|
||||||
|
<Link href="/" className="absolute left-5 top-5">
|
||||||
<Image
|
<Image
|
||||||
width={480}
|
width={480}
|
||||||
height={480}
|
height={480}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,10 @@ export default function ArticleTable() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleBanner = async (id: number, status: boolean) => {
|
||||||
|
console.log("vbanner", id, status);
|
||||||
|
};
|
||||||
|
|
||||||
const renderCell = useCallback(
|
const renderCell = useCallback(
|
||||||
(article: any, columnKey: Key) => {
|
(article: any, columnKey: Key) => {
|
||||||
const cellValue = article[columnKey as keyof any];
|
const cellValue = article[columnKey as keyof any];
|
||||||
|
|
@ -209,7 +213,9 @@ export default function ArticleTable() {
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="setBanner"
|
key="setBanner"
|
||||||
// onPress={() => handleDelete(article.id)}
|
onPress={() =>
|
||||||
|
handleBanner(article?.id, !article?.isBanner || true)
|
||||||
|
}
|
||||||
className={username === "admin-mabes" ? "" : "hidden"}
|
className={username === "admin-mabes" ? "" : "hidden"}
|
||||||
>
|
>
|
||||||
{username === "admin-mabes" && (
|
{username === "admin-mabes" && (
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,13 @@ export default function MasterUserLevelTable() {
|
||||||
const res = await getAllUserLevels(request);
|
const res = await getAllUserLevels(request);
|
||||||
const data = res?.data?.data;
|
const data = res?.data?.data;
|
||||||
setUserLevelAll(data);
|
setUserLevelAll(data);
|
||||||
|
const temp = [];
|
||||||
|
for (const element of data) {
|
||||||
|
if (element.isApprovalActive) {
|
||||||
|
temp.push(String(element.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSelectedLevel(temp);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,8 +255,8 @@ export default function MasterUserLevelTable() {
|
||||||
<>
|
<>
|
||||||
<div className="mx-3 my-5">
|
<div className="mx-3 my-5">
|
||||||
<div className="flex flex-col items-start rounded-2xl">
|
<div className="flex flex-col items-start rounded-2xl">
|
||||||
<div className="flex flex-row items-end gap-3 mb-3">
|
<div className="flex flex-row gap-3 mb-3 w-full justify-start items-end">
|
||||||
<div className="flex flex-col gap-1 w-full justify-start">
|
<div className="flex flex-col gap-1 w-auto justify-start">
|
||||||
<p className="font-semibold text-sm">Pencarian</p>
|
<p className="font-semibold text-sm">Pencarian</p>
|
||||||
<Input
|
<Input
|
||||||
aria-label="Search"
|
aria-label="Search"
|
||||||
|
|
@ -257,7 +264,7 @@ export default function MasterUserLevelTable() {
|
||||||
inputWrapper: "bg-default-100",
|
inputWrapper: "bg-default-100",
|
||||||
input: "text-sm",
|
input: "text-sm",
|
||||||
}}
|
}}
|
||||||
className="max-w-md"
|
className="w-[300px]"
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
startContent={
|
startContent={
|
||||||
<SearchIcon className="text-base text-default-400 pointer-events-none flex-shrink-0" />
|
<SearchIcon className="text-base text-default-400 pointer-events-none flex-shrink-0" />
|
||||||
|
|
@ -268,12 +275,16 @@ export default function MasterUserLevelTable() {
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button color="primary" onPress={() => setDoSetup(!doSetup)}>
|
<Button
|
||||||
Settings
|
color="primary"
|
||||||
|
onPress={() => setDoSetup(!doSetup)}
|
||||||
|
className="px-2"
|
||||||
|
>
|
||||||
|
Settings Approval
|
||||||
</Button>
|
</Button>
|
||||||
{doSetup && (
|
{doSetup && (
|
||||||
<Button color="success" className="text-white">
|
<Button color="success" className="text-white">
|
||||||
Save ({selectedLevel.length})
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue