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