feat:upload contest

This commit is contained in:
Anang Yusman 2025-02-12 21:00:06 +08:00
parent 3f89d63d20
commit 212a544765
19 changed files with 673 additions and 113 deletions

View File

@ -15,7 +15,7 @@ const BlogPage = async () => {
<CardTitle> <CardTitle>
<div className="flex items-center"> <div className="flex items-center">
<div className="flex-1 text-xl font-medium text-default-900"> <div className="flex-1 text-xl font-medium text-default-900">
Table Indeks Tabel Indeks
</div> </div>
<div className="flex-none"> <div className="flex-none">
<Link href={"/contributor/blog/create"}> <Link href={"/contributor/blog/create"}>

View File

@ -0,0 +1,15 @@
import FormAudio from "@/components/form/content/audio-form";
import SiteBreadcrumb from "@/components/site-breadcrumb";
const AudioScheduleCreatePage = async () => {
return (
<div>
<SiteBreadcrumb />
<div className="space-y-4">
<FormAudio />
</div>
</div>
);
};
export default AudioScheduleCreatePage;

View File

@ -0,0 +1,17 @@
import { Card, CardContent } from "@/components/ui/card";
import SiteBreadcrumb from "@/components/site-breadcrumb";
import FormTask from "@/components/form/task/task-form";
import FormImage from "@/components/form/content/image-form";
const ImageScheduleCreatePage = async () => {
return (
<div>
<SiteBreadcrumb />
<div className="space-y-4">
<FormImage />
</div>
</div>
);
};
export default ImageScheduleCreatePage;

View File

@ -0,0 +1,16 @@
import FormAudio from "@/components/form/content/audio-form";
import FormTeks from "@/components/form/content/teks-form";
import SiteBreadcrumb from "@/components/site-breadcrumb";
const TeksScheduleCreatePage = async () => {
return (
<div>
<SiteBreadcrumb />
<div className="space-y-4">
<FormTeks />
</div>
</div>
);
};
export default TeksScheduleCreatePage;

View File

@ -0,0 +1,15 @@
import FormVideo from "@/components/form/content/video-form";
import SiteBreadcrumb from "@/components/site-breadcrumb";
const VideoScheduleCreatePage = async () => {
return (
<div>
<SiteBreadcrumb />
<div className="space-y-4">
<FormVideo />
</div>
</div>
);
};
export default VideoScheduleCreatePage;

View File

@ -27,7 +27,7 @@ const TaskPage = () => {
<CardTitle> <CardTitle>
<div className="flex flex-col sm:flex-row lg:flex-row lg:items-center"> <div className="flex flex-col sm:flex-row lg:flex-row lg:items-center">
<div className="flex-1 text-xl font-medium text-default-900"> <div className="flex-1 text-xl font-medium text-default-900">
Table Penugasan Tabel Penugasan
</div> </div>
<div className="flex-none"> <div className="flex-none">
<Link href={"/contributor/task/create"}> <Link href={"/contributor/task/create"}>

View File

@ -15,7 +15,7 @@ const ContestPage = () => {
<CardTitle> <CardTitle>
<div className="flex items-center"> <div className="flex items-center">
<div className="flex-1 text-xl font-medium text-default-900"> <div className="flex-1 text-xl font-medium text-default-900">
Table Lomba Tabel Lomba
</div> </div>
<div className="flex-none"> <div className="flex-none">
<Link href={"/shared/contest/create"}> <Link href={"/shared/contest/create"}>

View File

@ -51,9 +51,14 @@ import { AudioRecorder } from "react-audio-voice-recorder";
import { error, loading } from "@/lib/swal"; import { error, loading } from "@/lib/swal";
import { Upload } from "tus-js-client"; import { Upload } from "tus-js-client";
import { getCsrfToken } from "@/service/auth"; import { getCsrfToken } from "@/service/auth";
import { getOnlyDate } from "@/utils/globals";
import { duration } from "moment";
const contestSchema = z.object({ const contestSchema = z.object({
theme: z.string().min(1, { message: "Judul diperlukan" }), theme: z.string().min(1, { message: "Judul diperlukan" }),
duration: z
.array(z.string().min(1)) // Gunakan array string untuk menyimpan range tanggal
.min(1, { message: "Tanggal diperlukan" }),
hastagCode: z.string().min(1, { message: "Judul diperlukan" }), hastagCode: z.string().min(1, { message: "Judul diperlukan" }),
description: z.string().min(2, { description: z.string().min(2, {
message: "Narasi Penugasan harus lebih dari 2 karakter.", message: "Narasi Penugasan harus lebih dari 2 karakter.",
@ -76,7 +81,7 @@ export type contestDetail = {
id: number; id: number;
name: string; name: string;
}; };
createdAt: string; duration: string;
platformType: string | null; platformType: string | null;
assignmentTypeId: string; assignmentTypeId: string;
targetOutput: string; targetOutput: string;
@ -190,9 +195,12 @@ export default function FormContestDetail() {
const details = response?.data?.data; const details = response?.data?.data;
setDetail(details); setDetail(details);
if (details?.createdAt) { if (details?.duration) {
const parsedDate = parseISO(details.createdAt); const [start, end] = details.duration.split(" - "); // Pisahkan tanggal
setDate({ from: parsedDate, to: parsedDate }); setDate({
from: parseISO(start),
to: end ? parseISO(end) : undefined, // Pastikan `to` bisa undefined jika hanya satu tanggal
});
} }
} }
} }
@ -212,19 +220,19 @@ export default function FormContestDetail() {
} }
}, [detail?.targetOutput]); }, [detail?.targetOutput]);
// useEffect(() => { useEffect(() => {
// if (detail?.targetParticipantTopLevel) { if (detail?.targetParticipantTopLevel) {
// const outputSet = new Set( const outputSet = new Set(
// detail.targetParticipantTopLevel.split(",").map(Number) detail.targetParticipantTopLevel.split(",").map(Number)
// ); );
// setUnitSelection({ setUnitSelection({
// allUnit: outputSet.has(0), allUnit: outputSet.has(0),
// mabes: outputSet.has(1), mabes: outputSet.has(1),
// polda: outputSet.has(2), polda: outputSet.has(2),
// polres: outputSet.has(3), polres: outputSet.has(3),
// }); });
// } }
// }, [detail?.targetParticipantTopLevel]); }, [detail?.targetParticipantTopLevel]);
const handleCheckboxChange = (levelId: number) => { const handleCheckboxChange = (levelId: number) => {
setCheckedLevels((prev) => { setCheckedLevels((prev) => {
@ -244,11 +252,11 @@ export default function FormContestDetail() {
const save = async (data: ContestSchema) => { const save = async (data: ContestSchema) => {
const fileTypeMapping = { const fileTypeMapping = {
all: "1", all: "0",
video: "2", video: "2",
audio: "3", audio: "4",
image: "4", image: "1",
text: "5", text: "3",
}; };
const unitMapping = { const unitMapping = {
@ -268,26 +276,38 @@ export default function FormContestDetail() {
.map((key) => fileTypeMapping[key as keyof typeof fileTypeMapping]) // Konversi ke nilai string .map((key) => fileTypeMapping[key as keyof typeof fileTypeMapping]) // Konversi ke nilai string
.join(","); .join(",");
// Pastikan `data.duration` ada dan dikonversi ke `Date`
const startDate = data.duration?.[0] ? new Date(data.duration[0]) : null;
const endDate = data.duration?.[1] ? new Date(data.duration[1]) : null;
const formattedDuration = startDate
? endDate
? `${getOnlyDate(startDate)} - ${getOnlyDate(endDate)}`
: getOnlyDate(startDate)
: "";
const requestData: { const requestData: {
id?: any; id?: any;
theme: string; theme: string;
assignedToLevel: any; duration: string;
assignmentPurpose: any; targetParticipantTopLevel: any;
targetParticipant: any;
hastagCode: string; hastagCode: string;
description: string; description: string;
assignmentMainTypeId: any;
scoringFormula: string; scoringFormula: string;
fileTypeOutput: any; targetOutput: any;
attachmentUrl: string[];
} = { } = {
...data, ...data,
hastagCode: data.hastagCode, hastagCode: data.hastagCode,
theme: data.theme, theme: data.theme,
duration: formattedDuration,
description: data.description, description: data.description,
scoringFormula: data.scoringFormula, scoringFormula: data.scoringFormula,
assignmentMainTypeId: mainType, targetParticipantTopLevel: handlePoldaPolresChange(),
assignedToLevel: handlePoldaPolresChange(), targetParticipant: assignmentPurposeString,
assignmentPurpose: assignmentPurposeString, targetOutput: selectedOutputs,
fileTypeOutput: selectedOutputs, attachmentUrl: links,
}; };
// if (id != undefined) { // if (id != undefined) {
@ -299,7 +319,7 @@ export default function FormContestDetail() {
console.log("Form Data Submitted:", requestData); console.log("Form Data Submitted:", requestData);
console.log("response", response); console.log("response", response);
const id = response?.data?.data.id; const id = response?.data?.data?.id;
loading(); loading();
if (imageFiles?.length == 0) { if (imageFiles?.length == 0) {
setIsImageUploadFinish(true); setIsImageUploadFinish(true);
@ -334,16 +354,6 @@ export default function FormContestDetail() {
"0" // Optional: Replace with actual duration if available "0" // Optional: Replace with actual duration if available
); );
}); });
// MySwal.fire({
// title: "Sukses",
// text: "Data berhasil disimpan.",
// icon: "success",
// confirmButtonColor: "#3085d6",
// confirmButtonText: "OK",
// }).then(() => {
// router.push("/en/shared/contest");
// });
}; };
const onSubmit = (data: ContestSchema) => { const onSubmit = (data: ContestSchema) => {
@ -584,29 +594,33 @@ export default function FormContestDetail() {
</div> </div>
<div className="flex flex-col mt-5"> <div className="flex flex-col mt-5">
<Label className="mr-3 mb-1">Tanggal</Label> <Label className="mr-3 mb-1">Tanggal</Label>
<Controller
control={control}
name="duration"
render={({ field: { onChange, value } }) => (
<Popover> <Popover>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<Button <Button
value={detail?.createdAt}
id="date" id="date"
variant={"outline"} variant={"outline"}
className={cn( className={cn(
"w-[280px] lg:w-[300px] justify-start text-left font-normal", "w-[280px] lg:w-[300px] justify-start text-left font-normal",
!date && "text-muted-foreground" !date && "text-muted-foreground"
)} )}
value={detail?.duration}
> >
<CalendarIcon /> <CalendarIcon />
{date?.from ? ( {date?.from ? (
date.to ? ( date.to ? (
<> <>
{format(date.from, "LLL dd, y")} -{" "} {format(date.from, "yyyy-MM-dd")} -{" "}
{format(date.to, "LLL dd, y")} {format(date.to, "yyyy-MM-dd")}
</> </>
) : ( ) : (
format(date.from, "LLL dd, y") format(date.from, "yyyy-MM-dd")
) )
) : ( ) : (
<span>Pick a date</span> <span>Pilih Tanggal</span>
)} )}
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
@ -616,11 +630,31 @@ export default function FormContestDetail() {
mode="range" mode="range"
defaultMonth={date?.from} defaultMonth={date?.from}
selected={date} selected={date}
onSelect={setDate} onSelect={(newDate) => {
setDate(newDate); // Update state lokal
if (newDate?.from) {
const formattedDate = [
format(newDate.from, "yyyy-MM-dd"),
newDate.to
? format(newDate.to, "yyyy-MM-dd")
: "",
].filter(Boolean); // Hanya menyimpan yang tidak undefined
onChange(formattedDate); // Simpan ke React Hook Form
} else {
onChange([]); // Reset jika tidak ada tanggal
}
}}
numberOfMonths={1} numberOfMonths={1}
/> />
</PopoverContent> </PopoverContent>
</Popover> </Popover>
)}
/>
{errors.duration?.message && (
<p className="text-red-400 text-sm">
{errors.duration.message}
</p>
)}
</div> </div>
<div className="mt-5"> <div className="mt-5">
<Label>Output Lomba</Label> <Label>Output Lomba</Label>
@ -763,7 +797,7 @@ export default function FormContestDetail() {
)} )}
</div> </div>
<div className="mt-7"> <div className="mt-7">
<Label>Rumus Penilaian</Label> <Label>Panduan Penilaian</Label>
<Controller <Controller
control={control} control={control}
name="scoringFormula" name="scoringFormula"

View File

@ -17,7 +17,7 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { CalendarIcon, Clock1, MapPin, User2 } from "lucide-react"; import { CalendarIcon, Clock1, MapPin, Plus, User2 } from "lucide-react";
import { Calendar } from "@/components/ui/calendar"; import { Calendar } from "@/components/ui/calendar";
import { addDays, format, parseISO, setDate } from "date-fns"; import { addDays, format, parseISO, setDate } from "date-fns";
import { DateRange } from "react-day-picker"; import { DateRange } from "react-day-picker";
@ -41,6 +41,8 @@ import {
AccordionTrigger, AccordionTrigger,
} from "@/components/ui/accordion"; } from "@/components/ui/accordion";
import { formatDate } from "@fullcalendar/core/index.js"; import { formatDate } from "@fullcalendar/core/index.js";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { Link } from "@/i18n/routing";
const taskSchema = z.object({ const taskSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }), title: z.string().min(1, { message: "Judul diperlukan" }),
@ -60,6 +62,7 @@ interface Detail {
} }
export default function FormEventDetail() { export default function FormEventDetail() {
const [open, setOpen] = useState(false);
const { id } = useParams() as { id: string }; const { id } = useParams() as { id: string };
console.log(id); console.log(id);
const router = useRouter(); const router = useRouter();
@ -327,16 +330,110 @@ export default function FormEventDetail() {
)} )}
</div> </div>
</div> </div>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<div className="flex justify-between">
<Button color="primary" size="sm" type="button">
<Plus /> Tambah Lampiran
</Button>
<p>0 Lampiran</p>
</div>
</DialogTrigger>
<DialogContent className="max-w-md p-6 bg-white rounded-lg shadow-lg h-[420px] w-[700px]">
<h2 className="text-lg font-semibold">
Pilih Jenis Lampiran
</h2>
<div className=" space-y-4 gap-y-4">
<Link href={"/contributor/schedule/media/video/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-video.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">
Audio Visual
</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/image/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-image.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Foto</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/text/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-text.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Teks</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/audio/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-audio.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Audio</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
</div>
</DialogContent>
</Dialog>
</div> </div>
) : ( ) : (
"" ""
)} )}
{/* Submit Button </div>
<div className="mt-4"> <div className="mt-4 flex justify-end">
<Button type="submit" color="primary"> <Button type="submit" color="primary">
Submit Submit
</Button> </Button>
</div> */}
</div> </div>
</Card> </Card>
<Card className="w-full lg:w-3/12"> <Card className="w-full lg:w-3/12">

View File

@ -26,7 +26,7 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { CalendarIcon } from "lucide-react"; import { CalendarIcon, Plus } from "lucide-react";
import { Calendar } from "@/components/ui/calendar"; import { Calendar } from "@/components/ui/calendar";
import { addDays, format, setDate } from "date-fns"; import { addDays, format, setDate } from "date-fns";
import { DateRange } from "react-day-picker"; import { DateRange } from "react-day-picker";
@ -149,6 +149,23 @@ export default function FormEvent() {
}); });
}; };
const handleUploadAttachment = () => {
const scheduleId = Cookies.get("scheduleId");
if (scheduleId == undefined) {
MySwal.fire({
title: "Simpan Jadwal Terlebih Dahulu",
icon: "info",
confirmButtonColor: "#3085d6",
confirmButtonText: "Ok",
}).then((result) => {
if (result.isConfirmed) {
return true;
}
});
}
};
return ( return (
<div className="flex flex-col lg:flex-row gap-2"> <div className="flex flex-col lg:flex-row gap-2">
<Card className="w-full lg:w-9/12"> <Card className="w-full lg:w-9/12">
@ -351,8 +368,19 @@ export default function FormEvent() {
</div> </div>
</div> </div>
{/* Submit Button */} <div className="flex flex-row items-center justify-between">
<div className="mt-4"> <Button
onClick={() => handleUploadAttachment()}
color="primary"
size="sm"
type="button"
>
<Plus />
Tambah Lampiran
</Button>
<p>0 Llampiran</p>
</div>
<div className="mt-4 flex justify-end">
<Button type="submit" color="primary"> <Button type="submit" color="primary">
Submit Submit
</Button> </Button>

View File

@ -17,7 +17,7 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { CalendarIcon } from "lucide-react"; import { CalendarIcon, Plus } from "lucide-react";
import { Calendar } from "@/components/ui/calendar"; import { Calendar } from "@/components/ui/calendar";
import { addDays, format, parseISO, setDate } from "date-fns"; import { addDays, format, parseISO, setDate } from "date-fns";
import { DateRange } from "react-day-picker"; import { DateRange } from "react-day-picker";
@ -29,6 +29,8 @@ import { Textarea } from "@/components/ui/textarea";
import { error, loading } from "@/lib/swal"; import { error, loading } from "@/lib/swal";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { detailSchedule, postSchedule } from "@/service/schedule/schedule"; import { detailSchedule, postSchedule } from "@/service/schedule/schedule";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { Link } from "@/i18n/routing";
const taskSchema = z.object({ const taskSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }), title: z.string().min(1, { message: "Judul diperlukan" }),
@ -48,6 +50,7 @@ interface Detail {
} }
export default function FormEventUpdate() { export default function FormEventUpdate() {
const [open, setOpen] = useState(false);
const { id } = useParams() as { id: string }; const { id } = useParams() as { id: string };
console.log(id); console.log(id);
const router = useRouter(); const router = useRouter();
@ -379,12 +382,107 @@ export default function FormEventUpdate() {
)} )}
</div> </div>
</div> </div>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<div className="flex justify-between">
<Button color="primary" size="sm" type="button">
<Plus /> Tambah Lampiran
</Button>
<p>0 Lampiran</p>
</div>
</DialogTrigger>
<DialogContent className="max-w-md p-6 bg-white rounded-lg shadow-lg h-[420px] w-[700px]">
<h2 className="text-lg font-semibold">
Pilih Jenis Lampiran
</h2>
<div className=" space-y-4 gap-y-4">
<Link href={"/contributor/schedule/media/video/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-video.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">
Audio Visual
</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/image/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-image.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Foto</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/text/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-text.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Teks</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/audio/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-audio.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Audio</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
</div>
</DialogContent>
</Dialog>
</div> </div>
) : ( ) : (
"" ""
)} )}
{/* Submit Button */}
<div className="mt-4"> <div className="mt-4 flex justify-end">
<Button type="submit" color="primary"> <Button type="submit" color="primary">
Submit Submit
</Button> </Button>

View File

@ -17,7 +17,7 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { CalendarIcon, Clock1, MapPin, User2 } from "lucide-react"; import { CalendarIcon, Clock1, MapPin, Plus, User2 } from "lucide-react";
import { Calendar } from "@/components/ui/calendar"; import { Calendar } from "@/components/ui/calendar";
import { addDays, format, parseISO, setDate } from "date-fns"; import { addDays, format, parseISO, setDate } from "date-fns";
import { DateRange } from "react-day-picker"; import { DateRange } from "react-day-picker";
@ -48,6 +48,8 @@ import {
AccordionTrigger, AccordionTrigger,
} from "@/components/ui/accordion"; } from "@/components/ui/accordion";
import { formatDate } from "@fullcalendar/core/index.js"; import { formatDate } from "@fullcalendar/core/index.js";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { Link } from "@/i18n/routing";
const taskSchema = z.object({ const taskSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }), title: z.string().min(1, { message: "Judul diperlukan" }),
@ -67,7 +69,9 @@ interface Detail {
} }
export default function FormDetailPressRillis() { export default function FormDetailPressRillis() {
const [open, setOpen] = useState(false);
const { id } = useParams() as { id: string }; const { id } = useParams() as { id: string };
const MySwal = withReactContent(Swal);
console.log(id); console.log(id);
const router = useRouter(); const router = useRouter();
const [isLiveStreamingEnabled, setIsLiveStreamingEnabled] = useState(false); const [isLiveStreamingEnabled, setIsLiveStreamingEnabled] = useState(false);
@ -135,6 +139,23 @@ export default function FormDetailPressRillis() {
setEndTime(e.target.value); setEndTime(e.target.value);
}; };
const handleUploadAttachment = () => {
const scheduleId = Cookies.get("scheduleId");
if (scheduleId == undefined) {
MySwal.fire({
title: "Simpan Jadwal Terlebih Dahulu",
icon: "info",
confirmButtonColor: "#3085d6",
confirmButtonText: "Ok",
}).then((result) => {
if (result.isConfirmed) {
return true;
}
});
}
};
return ( return (
<div className="flex flex-col lg:flex-row gap-2"> <div className="flex flex-col lg:flex-row gap-2">
<Card className="w-full lg:w-9/12"> <Card className="w-full lg:w-9/12">
@ -352,16 +373,110 @@ export default function FormDetailPressRillis() {
)} )}
</div> </div>
</div> </div>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<div className="flex justify-between">
<Button color="primary" size="sm" type="button">
<Plus /> Tambah Lampiran
</Button>
<p>0 Lampiran</p>
</div>
</DialogTrigger>
<DialogContent className="max-w-md p-6 bg-white rounded-lg shadow-lg h-[420px] w-[700px]">
<h2 className="text-lg font-semibold">
Pilih Jenis Lampiran
</h2>
<div className=" space-y-4 gap-y-4">
<Link href={"/contributor/schedule/media/video/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-video.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">
Audio Visual
</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/image/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-image.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Foto</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/text/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-text.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Teks</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/audio/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-audio.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Audio</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
</div>
</DialogContent>
</Dialog>
</div> </div>
) : ( ) : (
"" ""
)} )}
{/* Submit Button <div className="mt-4 flex justify-end">
<div className="mt-4">
<Button type="submit" color="primary"> <Button type="submit" color="primary">
Submit Submit
</Button> </Button>
</div> */} </div>
</div> </div>
</Card> </Card>
<Card className="w-full lg:w-3/12"> <Card className="w-full lg:w-3/12">

View File

@ -17,7 +17,7 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { CalendarIcon } from "lucide-react"; import { CalendarIcon, Plus } from "lucide-react";
import { Calendar } from "@/components/ui/calendar"; import { Calendar } from "@/components/ui/calendar";
import { addDays, format, parseISO, setDate } from "date-fns"; import { addDays, format, parseISO, setDate } from "date-fns";
import { DateRange } from "react-day-picker"; import { DateRange } from "react-day-picker";
@ -36,6 +36,8 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { Link } from "@/i18n/routing";
const taskSchema = z.object({ const taskSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }), title: z.string().min(1, { message: "Judul diperlukan" }),
@ -55,6 +57,7 @@ interface Detail {
} }
export default function FormUpdatePressRelease() { export default function FormUpdatePressRelease() {
const [open, setOpen] = useState(false);
const { id } = useParams() as { id: string }; const { id } = useParams() as { id: string };
console.log(id); console.log(id);
const router = useRouter(); const router = useRouter();
@ -403,6 +406,101 @@ export default function FormUpdatePressRelease() {
)} )}
</div> </div>
</div> </div>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<div className="flex justify-between">
<Button color="primary" size="sm" type="button">
<Plus /> Tambah Lampiran
</Button>
<p>0 Lampiran</p>
</div>
</DialogTrigger>
<DialogContent className="max-w-md p-6 bg-white rounded-lg shadow-lg h-[420px] w-[700px]">
<h2 className="text-lg font-semibold">
Pilih Jenis Lampiran
</h2>
<div className=" space-y-4 gap-y-4">
<Link href={"/contributor/schedule/media/video/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-video.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">
Audio Visual
</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/image/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-image.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Foto</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/text/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-text.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Teks</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
<Link href={"/contributor/schedule/media/audio/create"}>
<div className="flex flex-row items-center space-x-4">
<div className="flex flex-col w-4/12 items-center">
<img
src={"/assets/img/upload-audio.png"}
alt={"item.label"}
className="w-12 h-12"
/>
<h3 className="text-base font-semibold">Audio</h3>
</div>
<div className="w-8/12">
<p className="text-sm text-gray-600">
Unggah media berupa video dengan format avi, wmv,
atau mp4 dengan ukuran minimal 2mb dan maksimal
500mb.
</p>
</div>
</div>
</Link>
</div>
</DialogContent>
</Dialog>
</div> </div>
) : ( ) : (
"" ""

View File

@ -27,7 +27,7 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { CalendarIcon } from "lucide-react"; import { CalendarIcon, Plus } from "lucide-react";
import { Calendar } from "@/components/ui/calendar"; import { Calendar } from "@/components/ui/calendar";
import { addDays, format, setDate } from "date-fns"; import { addDays, format, setDate } from "date-fns";
import { DateRange } from "react-day-picker"; import { DateRange } from "react-day-picker";
@ -133,6 +133,23 @@ export default function FormPressRelease() {
}); });
}; };
const handleUploadAttachment = () => {
const scheduleId = Cookies.get("scheduleId");
if (scheduleId == undefined) {
MySwal.fire({
title: "Simpan Jadwal Terlebih Dahulu",
icon: "info",
confirmButtonColor: "#3085d6",
confirmButtonText: "Ok",
}).then((result) => {
if (result.isConfirmed) {
return true;
}
});
}
};
const onSubmit = (data: TaskSchema) => { const onSubmit = (data: TaskSchema) => {
MySwal.fire({ MySwal.fire({
title: "Simpan Data", title: "Simpan Data",
@ -367,9 +384,19 @@ export default function FormPressRelease() {
</div> </div>
</div> </div>
</div> </div>
<div className="flex flex-row items-center justify-between">
{/* Submit Button */} <Button
<div className="mt-4"> onClick={() => handleUploadAttachment()}
color="primary"
size="sm"
type="button"
>
<Plus />
Tambah Lampiran
</Button>
<p>0 Llampiran</p>
</div>
<div className="mt-4 flex justify-end">
<Button type="submit" color="primary"> <Button type="submit" color="primary">
Submit Submit
</Button> </Button>

View File

@ -1599,7 +1599,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: t("lomba"),
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],
@ -1783,7 +1783,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: t("lomba"),
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],
@ -1949,7 +1949,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: t("lomba"),
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],
@ -2177,7 +2177,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: t("lomba"),
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],
@ -2386,7 +2386,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: "Lomba",
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],
@ -2669,7 +2669,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: t("Lomba"),
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],
@ -2873,7 +2873,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
{ {
id: "contest", id: "contest",
href: "/shared/contest", href: "/shared/contest",
label: t("contest"), label: "Lomba",
active: pathname.includes("/contest"), active: pathname.includes("/contest"),
icon: "ic:outline-emoji-events", icon: "ic:outline-emoji-events",
submenus: [], submenus: [],

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB