diff --git a/components/form/content/audio-form.tsx b/components/form/content/audio-form.tsx index 24bf5174..db820083 100644 --- a/components/form/content/audio-form.tsx +++ b/components/form/content/audio-form.tsx @@ -647,7 +647,7 @@ export default function FormAudio() { filename: file.name, filetype: file.type, duration, - isWatermark: "false", + isWatermark: "false", }, onBeforeRequest: function (req) { var xhr = req.getUnderlyingObject(); @@ -1444,9 +1444,11 @@ export default function FormAudio() {
- + + +
diff --git a/components/form/content/audio-update-form.tsx b/components/form/content/audio-update-form.tsx index d262a28a..49bc2673 100644 --- a/components/form/content/audio-update-form.tsx +++ b/components/form/content/audio-update-form.tsx @@ -50,6 +50,7 @@ import { getCsrfToken } from "@/service/auth"; import { Upload } from "tus-js-client"; import { useTranslations } from "next-intl"; import dynamic from "next/dynamic"; +import { Link } from "@/i18n/routing"; const audioSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -667,7 +668,9 @@ export default function FormAudioUpdate() {
-

{t("form-audio", { defaultValue: "Form Audio" })}

+

+ {t("form-audio", { defaultValue: "Form Audio" })} +

{/* Input Title */}
@@ -706,14 +709,18 @@ export default function FormAudioUpdate() { {/* 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.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => (
- +
- + {/*
- {t("upload-file-audio-max", { defaultValue: "Upload File Audio Max" })} + {t("upload-file-audio-max", { + defaultValue: "Upload File Audio Max", + })}
@@ -1009,7 +1022,9 @@ export default function FormAudioUpdate() {
- + {options.map((option: Option) => (
- + + +
diff --git a/components/form/content/image-update-form.tsx b/components/form/content/image-update-form.tsx index 4f6f0f1a..be13d0de 100644 --- a/components/form/content/image-update-form.tsx +++ b/components/form/content/image-update-form.tsx @@ -48,6 +48,7 @@ import { error, loading } from "@/lib/swal"; import { getCsrfToken } from "@/service/auth"; import { Upload } from "tus-js-client"; import { useTranslations } from "next-intl"; +import { Link } from "@/i18n/routing"; const imageSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -268,7 +269,7 @@ export default function FormImageUpdate() { const details = response?.data?.data; setDetail(details); - + // Set the selected target to the category ID from details setSelectedTarget(String(details.category.id)); @@ -554,7 +555,7 @@ export default function FormImageUpdate() { const fileList = files.map((file: any) => (
@@ -671,7 +672,9 @@ export default function FormImageUpdate() {
-

{t("form-image", { defaultValue: "Form Image" })}

+

+ {t("form-image", { defaultValue: "Form Image" })} +

{/* Input Title */}
@@ -710,14 +713,18 @@ export default function FormImageUpdate() { {/* 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.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => (
- + ( - + )} /> {errors.description?.message && ( @@ -747,7 +759,9 @@ export default function FormImageUpdate() { )}
- + {/*
- {t("upload-file-max", { defaultValue: "Upload File Max" })} + {t("upload-file-max", { + defaultValue: "Upload File Max", + })}
@@ -772,7 +788,9 @@ export default function FormImageUpdate() {
{fileList}
- +
@@ -812,7 +830,9 @@ export default function FormImageUpdate() { rel="noopener noreferrer" className="text-blue-500 text-sm" > - {t("view-file", { defaultValue: "View File" })} + {t("view-file", { + defaultValue: "View File", + })}
@@ -830,7 +850,9 @@ export default function FormImageUpdate() { } className="form-checkbox" /> - {t("all", { defaultValue: "All" })} + + {t("all", { defaultValue: "All" })} +
@@ -980,7 +1002,9 @@ export default function FormImageUpdate() {
- + {options.map((option: Option) => (
-

{t("suggestion-box", { defaultValue: "Suggestion Box" })} (0)

+

+ {t("suggestion-box", { defaultValue: "Suggestion Box" })} (0) +

{t("information", { defaultValue: "Information" })}:

@@ -1014,9 +1040,11 @@ export default function FormImageUpdate() {
- + + +
diff --git a/components/form/content/teks-detail-form.tsx b/components/form/content/teks-detail-form.tsx index 19804d13..1c72861b 100644 --- a/components/form/content/teks-detail-form.tsx +++ b/components/form/content/teks-detail-form.tsx @@ -18,10 +18,6 @@ import { SelectValue, } from "@/components/ui/select"; import { Checkbox } from "@/components/ui/checkbox"; -import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; - -import { register } from "module"; -import { Switch } from "@/components/ui/switch"; import Cookies from "js-cookie"; import { createMedia, @@ -119,13 +115,13 @@ export default function FormTeksDetail() { const userId = getCookiesDecrypt("uie"); const userLevelId = getCookiesDecrypt("ulie"); const roleId = getCookiesDecrypt("urie"); - + const userLevelName = Cookies.get("state"); + const userLevelNumber = getCookiesDecrypt("ulne"); const [modalOpen, setModalOpen] = useState(false); const { id } = useParams() as { id: string }; console.log(id); const editor = useRef(null); type ImageSchema = z.infer; - const [selectedFiles, setSelectedFiles] = useState([]); const taskId = Cookies.get("taskId"); const scheduleId = Cookies.get("scheduleId"); @@ -472,16 +468,23 @@ export default function FormTeksDetail() { {/* 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.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => ( - + {category.name} ))} @@ -873,7 +876,11 @@ export default function FormTeksDetail() { - {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( + {Number(detail?.needApprovalFromLevel) == Number(userLevelId) || + (detail?.needApprovalFromLevel && Number(userLevelNumber) == 1) || + (detail?.isInternationalMedia == true && + detail?.isForwardFromNational == true && + Number(detail?.statusId) == 1) ? ( Number(detail?.uploadedById) == Number(userId) ? ( "" ) : ( diff --git a/components/form/content/teks-form.tsx b/components/form/content/teks-form.tsx index fb6004dc..9f8dbb3f 100644 --- a/components/form/content/teks-form.tsx +++ b/components/form/content/teks-form.tsx @@ -1492,9 +1492,11 @@ export default function FormTeks() {
- + + +
diff --git a/components/form/content/teks-update-form.tsx b/components/form/content/teks-update-form.tsx index 8a19fb1c..c114abeb 100644 --- a/components/form/content/teks-update-form.tsx +++ b/components/form/content/teks-update-form.tsx @@ -46,6 +46,7 @@ import { Upload } from "tus-js-client"; import { getCsrfToken } from "@/service/auth"; import { useTranslations } from "next-intl"; import dynamic from "next/dynamic"; +import { Link } from "@/i18n/routing"; const teksSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -623,7 +624,9 @@ export default function FormTeksUpdate() {
-

{t("form-text", { defaultValue: "Form Text" })}

+

+ {t("form-text", { defaultValue: "Form Text" })} +

{/* Input Title */}
@@ -662,14 +665,18 @@ export default function FormTeksUpdate() { {/* 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.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => (
- +
- + {/*
- {t("upload-file-text-max", { defaultValue: "Upload File Text Max" })} + {t("upload-file-text-max", { + defaultValue: "Upload File Text Max", + })}
@@ -724,7 +737,9 @@ export default function FormTeksUpdate() {
{fileList}
- +
@@ -764,7 +779,9 @@ export default function FormTeksUpdate() { rel="noopener noreferrer" className="text-blue-500 text-sm" > - {t("view-file", { defaultValue: "View File" })} + {t("view-file", { + defaultValue: "View File", + })}
@@ -782,7 +799,9 @@ export default function FormTeksUpdate() { } className="form-checkbox" /> - {t("all", { defaultValue: "All" })} + + {t("all", { defaultValue: "All" })} +
@@ -922,7 +941,9 @@ export default function FormTeksUpdate() {
- + {options.map((option) => (
-

{t("suggestion-box", { defaultValue: "Suggestion Box" })} (0)

+

+ {t("suggestion-box", { defaultValue: "Suggestion Box" })} (0) +

{t("information", { defaultValue: "Information" })}:

@@ -957,9 +980,11 @@ export default function FormTeksUpdate() {
- + + +
diff --git a/components/form/content/video-detail-form.tsx b/components/form/content/video-detail-form.tsx index 5a5f393b..03e6435f 100644 --- a/components/form/content/video-detail-form.tsx +++ b/components/form/content/video-detail-form.tsx @@ -119,13 +119,13 @@ export default function FormVideoDetail() { const userId = getCookiesDecrypt("uie"); const userLevelId = getCookiesDecrypt("ulie"); const roleId = getCookiesDecrypt("urie"); - + const userLevelName = Cookies.get("state"); + const userLevelNumber = getCookiesDecrypt("ulne"); const [modalOpen, setModalOpen] = useState(false); const { id } = useParams() as { id: string }; console.log(id); const editor = useRef(null); type ImageSchema = z.infer; - const [selectedFiles, setSelectedFiles] = useState([]); const taskId = Cookies.get("taskId"); const scheduleId = Cookies.get("scheduleId"); @@ -141,7 +141,6 @@ export default function FormVideoDetail() { const [main, setMain] = useState([]); const [detailVideo, setDetailVideo] = useState([]); const [thumbsSwiper, setThumbsSwiper] = useState(null); - const t = useTranslations("Form"); const [filePlacements, setFilePlacements] = useState([]); const [selectedTarget, setSelectedTarget] = useState(""); @@ -149,9 +148,7 @@ export default function FormVideoDetail() { const [rejectedFiles, setRejectedFiles] = useState([]); const [isUserMabesApprover, setIsUserMabesApprover] = useState(false); const [approval, setApproval] = useState(); - let fileTypeId = "2"; - const { control, handleSubmit, @@ -212,7 +209,7 @@ export default function FormVideoDetail() { if (findCategory) { // setValue("categoryId", findCategory.id); - setSelectedCategory(findCategory.id); + setSelectedCategory(findCategory.id); const response = await getTagsBySubCategoryId(findCategory.id); setTags(response?.data?.data); } @@ -245,7 +242,7 @@ export default function FormVideoDetail() { } // Set the selected target to the category ID from details - setSelectedTarget(String(details.category.id)); + setSelectedTarget(String(details.category.id)); const filesData = details?.files || []; const fileUrls = filesData.map((files: { url: string }) => @@ -418,7 +415,9 @@ export default function FormVideoDetail() {
-

{t("form-video", { defaultValue: "Form Video" })}

+

+ {t("form-video", { defaultValue: "Form Video" })} +

{/* Input Title */}
@@ -458,16 +457,23 @@ export default function FormVideoDetail() { {/* 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.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => ( - + {category.name} ))} @@ -477,7 +483,9 @@ export default function FormVideoDetail() {
- +
- +
))} @@ -528,7 +539,7 @@ export default function FormVideoDetail() { className="object-cover h-[60px] w-[80px] cursor-pointer" src={data.secondaryUrl} muted - title={`Video ${data.id}`} + title={`Video ${data.id}`} /> ))} @@ -593,7 +604,9 @@ export default function FormVideoDetail() {
- +
- {t("leave-comment", { defaultValue: "Leave Comment" })} + + {t("leave-comment", { defaultValue: "Leave Comment" })} + {status == "2" ? files?.map((file, index) => ( @@ -864,7 +879,11 @@ export default function FormVideoDetail() { - {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( + {Number(detail?.needApprovalFromLevel) == Number(userLevelId) || + (detail?.needApprovalFromLevel && Number(userLevelNumber) == 1) || + (detail?.isInternationalMedia == true && + detail?.isForwardFromNational == true && + Number(detail?.statusId) == 1) ? ( Number(detail?.uploadedById) == Number(userId) ? ( "" ) : ( @@ -874,7 +893,8 @@ export default function FormVideoDetail() { color="primary" type="button" > - {t("accept", { defaultValue: "Accept" })} + {" "} + {t("accept", { defaultValue: "Accept" })}
- + + +
diff --git a/components/form/content/video-update-form.tsx b/components/form/content/video-update-form.tsx index 0cea11d7..e1512795 100644 --- a/components/form/content/video-update-form.tsx +++ b/components/form/content/video-update-form.tsx @@ -56,6 +56,7 @@ import { getCsrfToken } from "@/service/auth"; import { error, loading } from "@/lib/swal"; import { useTranslations } from "next-intl"; import dynamic from "next/dynamic"; +import { Link } from "@/i18n/routing"; const videoSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -106,25 +107,21 @@ const CustomEditor = dynamic( export default function FormVideoUpdate() { const MySwal = withReactContent(Swal); const router = useRouter(); - const { id } = useParams() as { id: string }; console.log(id); const editor = useRef(null); type VideoSchema = z.infer; - let progressInfo: any = []; let counterUpdateProgress = 0; const [progressList, setProgressList] = useState([]); let uploadPersen = 0; const [isStartUpload, setIsStartUpload] = useState(false); const [counterProgress, setCounterProgress] = useState(0); - const t = useTranslations("Form"); const [selectedFiles, setSelectedFiles] = useState([]); const taskId = Cookies.get("taskId"); const scheduleId = Cookies.get("scheduleId"); const scheduleType = Cookies.get("scheduleType"); - const [categories, setCategories] = useState([]); const [selectedCategory, setSelectedCategory] = useState(); const [tags, setTags] = useState([]); @@ -133,7 +130,6 @@ export default function FormVideoUpdate() { const [selectedPublishers, setSelectedPublishers] = useState([]); const [detailVideo, setDetailVideo] = useState([]); const [thumbsSwiper, setThumbsSwiper] = useState(null); - const [files, setFiles] = useState([]); const [selectedTarget, setSelectedTarget] = useState(""); const [unitSelection, setUnitSelection] = useState({ @@ -263,7 +259,7 @@ export default function FormVideoUpdate() { setDetail(details); setSelectedTarget(String(details.category.id)); - + // Set form values immediately and then again after a delay to ensure editor is ready setValue("title", details.title); setValue("description", details.htmlDescription); @@ -728,7 +724,9 @@ export default function FormVideoUpdate() {
-

{t("form-video", { defaultValue: "Form Video" })}

+

+ {t("form-video", { defaultValue: "Form Video" })} +

{/* Input Title */}
@@ -767,14 +765,18 @@ export default function FormVideoUpdate() { {/* 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.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => (
- +
- + {/*
- {t("upload-file-video-max", { defaultValue: "Upload File Video Max" })} + {t("upload-file-video-max", { + defaultValue: "Upload File Video Max", + })}
@@ -829,7 +837,9 @@ export default function FormVideoUpdate() {
{fileList}
- +
@@ -869,7 +879,9 @@ export default function FormVideoUpdate() { rel="noopener noreferrer" className="text-blue-500 text-sm" > - {t("view-file", { defaultValue: "View File" })} + {t("view-file", { + defaultValue: "View File", + })}
@@ -887,7 +899,9 @@ export default function FormVideoUpdate() { } className="form-checkbox" /> - {t("all", { defaultValue: "All" })} + + {t("all", { defaultValue: "All" })} +
@@ -1027,7 +1041,9 @@ export default function FormVideoUpdate() {
- + {options.map((option: Option) => (
-

{t("suggestion-box", { defaultValue: "Suggestion Box" })} (0)

+

+ {t("suggestion-box", { defaultValue: "Suggestion Box" })} (0) +

{t("information", { defaultValue: "Information" })}:

@@ -1061,9 +1079,11 @@ export default function FormVideoUpdate() {
- + + +