fix: detail vidio admin and ticketing

This commit is contained in:
Sabda Yagra 2025-08-11 11:03:32 +07:00
parent 74cae6134b
commit 1cbfd35a76
2 changed files with 104 additions and 32 deletions

View File

@ -36,12 +36,11 @@ import { list, parse } from "postcss";
import { htmlToString } from "@/utils/globals"; import { htmlToString } from "@/utils/globals";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { error } from "@/lib/swal"; import { error } from "@/lib/swal";
import { useRouter } from "next/navigation";
import { useMediaQuery } from "react-responsive"; import { useMediaQuery } from "react-responsive";
import { DetailTicket } from "../ticketing/info-lainnya-types"; import { DetailTicket } from "../ticketing/info-lainnya-types";
import InfoLainnyaModal from "../ticketing/info-lainnya"; import InfoLainnyaModal from "../ticketing/info-lainnya";
import { Description } from "@radix-ui/react-toast"; import { Description } from "@radix-ui/react-toast";
import { Link } from "@/i18n/routing"; import { Link, useRouter } from "@/i18n/routing";
import { import {
Popover, Popover,
PopoverContent, PopoverContent,
@ -140,6 +139,7 @@ export default function FormQuestionsReply() {
control, control,
handleSubmit, handleSubmit,
reset, reset,
setValue,
formState: { errors }, formState: { errors },
} = useForm({ } = useForm({
resolver: zodResolver(taskSchema), resolver: zodResolver(taskSchema),
@ -149,9 +149,11 @@ export default function FormQuestionsReply() {
async function initState() { async function initState() {
setReplyValue(0); setReplyValue(0);
const response = await getQuestionTicket(id); const response = await getQuestionTicket(id);
setDetailTicketsQuestions(response?.data?.data || null); setDetailTicketsQuestions(response?.data?.data || null);
setTicketInternal(response?.data?.data || null); setTicketInternal(response?.data?.data || null);
setDetail(response?.data?.data); setDetail(response?.data?.data);
setValue('title', response?.data?.data?.message)
if (response?.data !== null) { if (response?.data !== null) {
setDetailTickets(response?.data?.data); setDetailTickets(response?.data?.data);
@ -268,8 +270,49 @@ export default function FormQuestionsReply() {
} }
}; };
// const onSubmit = async (data: any) => {
// try {
// const payload = {
// id,
// title: data.title,
// description: data.description,
// priorityId: selectedPriority,
// statusId: 1,
// typeId: detailTickets?.typeId,
// parentCommentId: detailTickets?.feedId,
// operatorTeam: selectedOperator.join(","),
// };
// const response = await saveTicketsQuestion(payload);
// MySwal.fire({
// title: "Sukses",
// text: "Data berhasil diperbarui.",
// icon: "success",
// });
// getTicketReply();
// } catch (error) {
// console.error("Gagal update:", error);
// MySwal.fire({
// title: "Error",
// text: "Terjadi kesalahan saat memperbarui.",
// icon: "error",
// });
// }
// };
const onSubmit = async (data: any) => { const onSubmit = async (data: any) => {
try { try {
MySwal.fire({
title: "Menyimpan...",
text: "Mohon tunggu sebentar",
allowOutsideClick: false,
didOpen: () => {
MySwal.showLoading();
},
});
const payload = { const payload = {
id, id,
title: data.title, title: data.title,
@ -281,17 +324,17 @@ export default function FormQuestionsReply() {
operatorTeam: selectedOperator.join(","), operatorTeam: selectedOperator.join(","),
}; };
const response = await saveTicketsQuestion(payload); await saveTicketsQuestion(payload);
MySwal.fire({ MySwal.fire({
title: "Sukses", title: "Sukses",
text: "Data berhasil diperbarui.", text: "Data berhasil diperbarui.",
icon: "success", icon: "success",
confirmButtonText: "OK",
}).then(() => {
router.push("/supervisor/ticketing");
}); });
getTicketReply();
} catch (error) { } catch (error) {
console.error("Gagal update:", error);
MySwal.fire({ MySwal.fire({
title: "Error", title: "Error",
text: "Terjadi kesalahan saat memperbarui.", text: "Terjadi kesalahan saat memperbarui.",
@ -512,8 +555,10 @@ export default function FormQuestionsReply() {
<Input <Input
size="md" size="md"
type="text" type="text"
defaultValue={detailTickets?.message} // defaultValue={detailTickets?.message}
{...field} value={field.value}
// {...field}
onChange={field.onChange}
placeholder="Masukkan judul" placeholder="Masukkan judul"
/> />
)} )}

View File

@ -63,6 +63,7 @@ import { useTranslations } from "next-intl";
import SuggestionModal from "@/components/modal/suggestions-modal"; import SuggestionModal from "@/components/modal/suggestions-modal";
import { formatDateToIndonesian } from "@/utils/globals"; import { formatDateToIndonesian } from "@/utils/globals";
import ApprovalHistoryModal from "@/components/modal/approval-history-modal"; import ApprovalHistoryModal from "@/components/modal/approval-history-modal";
import VideoPlayer from "@/utils/video-player";
const imageSchema = z.object({ const imageSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }), title: z.string().min(1, { message: "Judul diperlukan" }),
@ -418,7 +419,9 @@ export default function FormVideoDetail() {
<div className="flex flex-col lg:flex-row gap-10"> <div className="flex flex-col lg:flex-row gap-10">
<Card className="w-full lg:w-8/12"> <Card className="w-full lg:w-8/12">
<div className="px-6 py-6"> <div className="px-6 py-6">
<p className="text-lg font-semibold mb-3">{t("form-video", { defaultValue: "Form Video" })}</p> <p className="text-lg font-semibold mb-3">
{t("form-video", { defaultValue: "Form Video" })}
</p>
<div className="gap-5 mb-5"> <div className="gap-5 mb-5">
{/* Input Title */} {/* Input Title */}
<div className="space-y-2 py-3"> <div className="space-y-2 py-3">
@ -458,7 +461,11 @@ export default function FormVideoDetail() {
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
{/* Show the category from details if it doesn't exist in categories list */} {/* Show the category from details if it doesn't exist in categories list */}
{detail && !categories.find(cat => String(cat.id) === String(detail.category.id)) && ( {detail &&
!categories.find(
(cat) =>
String(cat.id) === String(detail.category.id)
) && (
<SelectItem <SelectItem
key={String(detail.category.id)} key={String(detail.category.id)}
value={String(detail.category.id)} value={String(detail.category.id)}
@ -467,7 +474,10 @@ export default function FormVideoDetail() {
</SelectItem> </SelectItem>
)} )}
{categories.map((category) => ( {categories.map((category) => (
<SelectItem key={String(category.id)} value={String(category.id)}> <SelectItem
key={String(category.id)}
value={String(category.id)}
>
{category.name} {category.name}
</SelectItem> </SelectItem>
))} ))}
@ -477,7 +487,9 @@ export default function FormVideoDetail() {
</div> </div>
<div className="py-3 space-y-2"> <div className="py-3 space-y-2">
<Label>{t("description", { defaultValue: "Description" })}</Label> <Label>
{t("description", { defaultValue: "Description" })}
</Label>
<Controller <Controller
control={control} control={control}
name="description" name="description"
@ -492,7 +504,10 @@ export default function FormVideoDetail() {
)} )}
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label className="text-xl "> {t("file-media", { defaultValue: "File Media" })}</Label> <Label className="text-xl ">
{" "}
{t("file-media", { defaultValue: "File Media" })}
</Label>
<div className="w-full"> <div className="w-full">
<Swiper <Swiper
thumbs={{ swiper: thumbsSwiper }} thumbs={{ swiper: thumbsSwiper }}
@ -502,12 +517,19 @@ export default function FormVideoDetail() {
> >
{files?.map((data: any) => ( {files?.map((data: any) => (
<SwiperSlide key={data.id}> <SwiperSlide key={data.id}>
<div className="relative max-h-screen overflow-hidden">
<div className="w-full max-h-screen aspect-video">
<div className="w-full h-full object-contain">
<video <video
className="object-fill h-full w-full" className="object-contain h-full w-full"
src={data.secondaryUrl} src={data.secondaryUrl}
controls controls
title={`Video ${data.id}`} title={`Video ${data.id}`}
/> />
</div>
</div>
<div className="absolute top-4 left-4"></div>
</div>
</SwiperSlide> </SwiperSlide>
))} ))}
</Swiper> </Swiper>
@ -593,7 +615,9 @@ export default function FormVideoDetail() {
</div> </div>
<div className="px-3 py-3"> <div className="px-3 py-3">
<div className="flex flex-col gap-6 space-y-2"> <div className="flex flex-col gap-6 space-y-2">
<Label>{t("publish-target", { defaultValue: "Publish Target" })}</Label> <Label>
{t("publish-target", { defaultValue: "Publish Target" })}
</Label>
<div className="flex gap-2 items-center"> <div className="flex gap-2 items-center">
<Checkbox <Checkbox
id="5" id="5"
@ -655,7 +679,9 @@ export default function FormVideoDetail() {
<Dialog open={modalOpen} onOpenChange={setModalOpen}> <Dialog open={modalOpen} onOpenChange={setModalOpen}>
<DialogContent size="md"> <DialogContent size="md">
<DialogHeader> <DialogHeader>
<DialogTitle>{t("leave-comment", { defaultValue: "Leave Comment" })}</DialogTitle> <DialogTitle>
{t("leave-comment", { defaultValue: "Leave Comment" })}
</DialogTitle>
</DialogHeader> </DialogHeader>
{status == "2" {status == "2"
? files?.map((file, index) => ( ? files?.map((file, index) => (
@ -874,7 +900,8 @@ export default function FormVideoDetail() {
color="primary" color="primary"
type="button" type="button"
> >
<Icon icon="fa:check" className="mr-3" /> {t("accept", { defaultValue: "Accept" })} <Icon icon="fa:check" className="mr-3" />{" "}
{t("accept", { defaultValue: "Accept" })}
</Button> </Button>
<Button <Button
onClick={() => actionApproval("3")} onClick={() => actionApproval("3")}