fixing
This commit is contained in:
parent
c1aec7f316
commit
54633d8936
|
|
@ -2,7 +2,7 @@ import * as React from "react";
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn, getCookiesDecrypt } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -78,7 +78,7 @@ const columns: ColumnDef<any>[] = [
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
|
const levelNumber = getCookiesDecrypt("ulne");
|
||||||
async function doDelete(id: any) {
|
async function doDelete(id: any) {
|
||||||
// loading();
|
// loading();
|
||||||
const data = {
|
const data = {
|
||||||
|
|
@ -132,7 +132,7 @@ const columns: ColumnDef<any>[] = [
|
||||||
<MoreVertical className="h-4 w-4 text-default-800" />
|
<MoreVertical className="h-4 w-4 text-default-800" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent className="p-0" align="end">
|
{/* <DropdownMenuContent className="p-0" align="end">
|
||||||
<Link href={`/admin/settings/iklan/detail/${row.original.id}`}>
|
<Link href={`/admin/settings/iklan/detail/${row.original.id}`}>
|
||||||
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||||
<Eye className="w-4 h-4 me-1.5" />
|
<Eye className="w-4 h-4 me-1.5" />
|
||||||
|
|
@ -152,6 +152,33 @@ const columns: ColumnDef<any>[] = [
|
||||||
<Trash2 className="w-4 h-4 me-1.5" />
|
<Trash2 className="w-4 h-4 me-1.5" />
|
||||||
Delete
|
Delete
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent> */}
|
||||||
|
<DropdownMenuContent className="p-0" align="end">
|
||||||
|
<Link href={`/admin/settings/iklan/detail/${row.original.id}`}>
|
||||||
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||||
|
<Eye className="w-4 h-4 me-1.5" />
|
||||||
|
View
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
{levelNumber === "1" && (
|
||||||
|
<>
|
||||||
|
<Link href={`/admin/settings/iklan/update/${row.original.id}`}>
|
||||||
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||||
|
<SquarePen className="w-4 h-4 me-1.5" />
|
||||||
|
Edit
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => handleDeleteAdvertisements(row.original.id)}
|
||||||
|
className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none"
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4 me-1.5" />
|
||||||
|
Delete
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import {
|
||||||
UploadIcon,
|
UploadIcon,
|
||||||
UserIcon,
|
UserIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn, getCookiesDecrypt } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -94,6 +94,9 @@ const AdvertisementsList = () => {
|
||||||
const [statusFilter, setStatusFilter] = React.useState<number[]>([]);
|
const [statusFilter, setStatusFilter] = React.useState<number[]>([]);
|
||||||
const [page, setPage] = React.useState(1);
|
const [page, setPage] = React.useState(1);
|
||||||
const [totalPage, setTotalPage] = React.useState(1);
|
const [totalPage, setTotalPage] = React.useState(1);
|
||||||
|
const roleId = getCookiesDecrypt("urie");
|
||||||
|
const levelNumber = getCookiesDecrypt("ulne");
|
||||||
|
const userLevelId = getCookiesDecrypt("ulie");
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: dataTable,
|
data: dataTable,
|
||||||
columns,
|
columns,
|
||||||
|
|
@ -203,23 +206,27 @@ const AdvertisementsList = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<div className="flex-none">
|
{levelNumber === "1" && (
|
||||||
<Button
|
<div className="flex-none">
|
||||||
disabled={dataTable.length == 4}
|
<Link href={"/admin/settings/iklan/create"}>
|
||||||
onClick={() => router.push("/admin/settings/iklan/create")}
|
<Button
|
||||||
color="primary"
|
disabled={dataTable.length == 4}
|
||||||
className="text-white"
|
color="primary"
|
||||||
size="md"
|
className="text-white"
|
||||||
>
|
size="md"
|
||||||
<UploadIcon size={18} className="mr-2" />
|
>
|
||||||
Tambah Iklan
|
<UploadIcon size={18} className="mr-2" />
|
||||||
</Button>
|
Tambah Iklan
|
||||||
{dataTable.length == 4 && (
|
</Button>
|
||||||
<p className="text-sm text-red-400 pt-1">
|
</Link>
|
||||||
Jumlah Iklan Sudah Maksimal (4)
|
{dataTable.length == 4 && (
|
||||||
</p>
|
<p className="text-sm text-red-400 pt-1">
|
||||||
)}
|
Jumlah Iklan Sudah Maksimal (4)
|
||||||
</div>
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* <TambahIklanModal /> */}
|
{/* <TambahIklanModal /> */}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between ">
|
<div className="flex justify-between ">
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
Trash2,
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -20,6 +20,7 @@ import { Link } from "@/components/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import withReactContent from "sweetalert2-react-content";
|
import withReactContent from "sweetalert2-react-content";
|
||||||
import Swal from "sweetalert2";
|
import Swal from "sweetalert2";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
const useTableColumns = () => {
|
const useTableColumns = () => {
|
||||||
const t = useTranslations("Table");
|
const t = useTranslations("Table");
|
||||||
|
|
@ -37,7 +38,6 @@ const useTableColumns = () => {
|
||||||
onCheckedChange={(val) => table.toggleAllPageRowsSelected(!!val)}
|
onCheckedChange={(val) => table.toggleAllPageRowsSelected(!!val)}
|
||||||
aria-label="Pilih semua pada halaman ini"
|
aria-label="Pilih semua pada halaman ini"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
),
|
),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|
@ -140,15 +140,23 @@ const useTableColumns = () => {
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const isDisabled = row.original.isPublish;
|
const isDisabled = row.original.isPublish;
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const handleClick = (e: React.MouseEvent) => {
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
console.log("Ctrl + Click detected");
|
||||||
|
}
|
||||||
|
// Paksa buka menu meskipun ctrl ditekan
|
||||||
|
setOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu open={open} onOpenChange={setOpen}>
|
||||||
<DropdownMenuTrigger asChild disabled={isDisabled}>
|
<DropdownMenuTrigger asChild disabled={isDisabled}>
|
||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
className={`bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent ${
|
onClick={handleClick}
|
||||||
isDisabled ? "cursor-not-allowed opacity-50" : ""
|
className="bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent"
|
||||||
}`}
|
|
||||||
disabled={isDisabled}
|
|
||||||
>
|
>
|
||||||
<span className="sr-only">Open menu</span>
|
<span className="sr-only">Open menu</span>
|
||||||
<MoreVertical className="h-4 w-4 text-default-800" />
|
<MoreVertical className="h-4 w-4 text-default-800" />
|
||||||
|
|
@ -159,7 +167,7 @@ const useTableColumns = () => {
|
||||||
href={`/contributor/content/spit/convert/${row.original.contentId}`}
|
href={`/contributor/content/spit/convert/${row.original.contentId}`}
|
||||||
>
|
>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className={`p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none ${
|
className={`cursor-pointer p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none ${
|
||||||
isDisabled ? "cursor-not-allowed opacity-50" : ""
|
isDisabled ? "cursor-not-allowed opacity-50" : ""
|
||||||
}`}
|
}`}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import * as React from "react";
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn, getCookiesDecrypt } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -206,6 +206,15 @@ const useTableColumns = () => {
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
|
const roleId = getCookiesDecrypt("urie");
|
||||||
|
const levelNumber = getCookiesDecrypt("ulne");
|
||||||
|
const userLevelId = getCookiesDecrypt("ulie");
|
||||||
|
const contentLevelNumber =
|
||||||
|
row.original.createdBy?.userLevel?.levelNumber;
|
||||||
|
const isSameLevelOrLower =
|
||||||
|
levelNumber &&
|
||||||
|
contentLevelNumber &&
|
||||||
|
+levelNumber <= +contentLevelNumber;
|
||||||
|
|
||||||
async function deleteProcess(id: any) {
|
async function deleteProcess(id: any) {
|
||||||
loading();
|
loading();
|
||||||
|
|
@ -268,7 +277,24 @@ const useTableColumns = () => {
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{!isDone && (
|
{/* {!isDone && (
|
||||||
|
<>
|
||||||
|
<Link href={`/contributor/task/update/${row.original.id}`}>
|
||||||
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||||
|
<SquarePen className="w-4 h-4 me-1.5" />
|
||||||
|
Edit
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</Link>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => TaskDelete(row.original.id)}
|
||||||
|
className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none"
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4 me-1.5" />
|
||||||
|
Delete
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</>
|
||||||
|
)} */}
|
||||||
|
{!isDone && isSameLevelOrLower && (
|
||||||
<>
|
<>
|
||||||
<Link href={`/contributor/task/update/${row.original.id}`}>
|
<Link href={`/contributor/task/update/${row.original.id}`}>
|
||||||
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import FileUploader from "../shared/file-uploader";
|
||||||
import { Icon } from "@/components/ui/icon";
|
import { Icon } from "@/components/ui/icon";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "@/i18n/routing";
|
||||||
|
|
||||||
const calendarSchema = z.object({
|
const calendarSchema = z.object({
|
||||||
title: z.string().min(1, { message: "Judul diperlukan" }),
|
title: z.string().min(1, { message: "Judul diperlukan" }),
|
||||||
|
|
@ -64,6 +65,7 @@ interface Detail {
|
||||||
|
|
||||||
export function TambahIklanDetail() {
|
export function TambahIklanDetail() {
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const router = useRouter();
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
const t = useTranslations("Schedule");
|
const t = useTranslations("Schedule");
|
||||||
const { id } = useParams() as { id: string };
|
const { id } = useParams() as { id: string };
|
||||||
|
|
@ -376,6 +378,7 @@ export function TambahIklanDetail() {
|
||||||
].map(({ label, value }) => (
|
].map(({ label, value }) => (
|
||||||
<label key={value} className="flex items-center gap-2">
|
<label key={value} className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
disabled
|
||||||
id={value}
|
id={value}
|
||||||
checked={selectedPlacement === value}
|
checked={selectedPlacement === value}
|
||||||
onCheckedChange={() => handlePlacementSelect(value)}
|
onCheckedChange={() => handlePlacementSelect(value)}
|
||||||
|
|
@ -506,6 +509,7 @@ export function TambahIklanDetail() {
|
||||||
name="title"
|
name="title"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Input
|
<Input
|
||||||
|
readOnly
|
||||||
size={"md"}
|
size={"md"}
|
||||||
type="text"
|
type="text"
|
||||||
value={detail?.title}
|
value={detail?.title}
|
||||||
|
|
@ -540,6 +544,7 @@ export function TambahIklanDetail() {
|
||||||
name="description"
|
name="description"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Textarea
|
<Textarea
|
||||||
|
readOnly
|
||||||
rows={3}
|
rows={3}
|
||||||
value={detail?.description}
|
value={detail?.description}
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
|
|
@ -554,12 +559,22 @@ export function TambahIklanDetail() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="text-right">
|
{/* <div className="text-right">
|
||||||
<Link href={"admin/settings/iklan"}>
|
<Link href={"admin/settings/iklan"}>
|
||||||
<Button type="button" variant={"outline"} color="primary">
|
<Button type="button" variant={"outline"} color="primary">
|
||||||
Kembali
|
Kembali
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
</div> */}
|
||||||
|
<div className="text-right">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => router.back()}
|
||||||
|
>
|
||||||
|
Kembali
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import FileUploader from "../shared/file-uploader";
|
||||||
import { Icon } from "@/components/ui/icon";
|
import { Icon } from "@/components/ui/icon";
|
||||||
import { close } from "@/config/swal";
|
import { close } from "@/config/swal";
|
||||||
import { listDataAdvertisements } from "@/service/broadcast/broadcast";
|
import { listDataAdvertisements } from "@/service/broadcast/broadcast";
|
||||||
|
import { useRouter } from "@/i18n/routing";
|
||||||
|
|
||||||
const calendarSchema = z.object({
|
const calendarSchema = z.object({
|
||||||
title: z.string().min(1, { message: "Judul diperlukan" }),
|
title: z.string().min(1, { message: "Judul diperlukan" }),
|
||||||
|
|
@ -54,6 +55,7 @@ interface FileUploaded {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TambahIklanModal() {
|
export function TambahIklanModal() {
|
||||||
|
const router = useRouter();
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
const t = useTranslations("Schedule");
|
const t = useTranslations("Schedule");
|
||||||
|
|
@ -222,7 +224,7 @@ export function TambahIklanModal() {
|
||||||
text: "Iklan berhasil ditambahkan.",
|
text: "Iklan berhasil ditambahkan.",
|
||||||
confirmButtonText: "OK",
|
confirmButtonText: "OK",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
window.location.reload();
|
router.push("/admin/settings/iklan");
|
||||||
});
|
});
|
||||||
|
|
||||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ const Navbar = () => {
|
||||||
<ThemeSwitcher />
|
<ThemeSwitcher />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="hidden custom-lg-button:relative text-gray-600 dark:text-white ">
|
<div className=" custom-lg-button:relative text-gray-600 dark:text-white ">
|
||||||
{/* <input
|
{/* <input
|
||||||
value={onSearch}
|
value={onSearch}
|
||||||
onChange={(e) => setOnSearch(e.target.value)}
|
onChange={(e) => setOnSearch(e.target.value)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue