({
rest,
courseId,
parentContentId,
courseTitle,
}: {
rest: any;
courseId: number;
parentContentId?: number;
courseTitle: string;
})
| 19 | } from '@/components/ui/dialog'; |
| 20 | |
| 21 | export const AddContent = ({ |
| 22 | rest, |
| 23 | courseId, |
| 24 | parentContentId, |
| 25 | courseTitle, |
| 26 | }: { |
| 27 | rest: any; |
| 28 | courseId: number; |
| 29 | parentContentId?: number; |
| 30 | courseTitle: string; |
| 31 | }) => { |
| 32 | const [type, setType] = useState('folder'); |
| 33 | const [imageUri, setImageUri] = useState(''); |
| 34 | const [title, setTitle] = useState(''); |
| 35 | const [metadata, setMetadata] = useState({}); |
| 36 | const [discordChecked, setDiscordChecked] = useState(false); |
| 37 | const [isModalOpen, setIsModalOpen] = useState(false); |
| 38 | const setTrigger = useSetRecoilState(trigger); |
| 39 | |
| 40 | const handleDiscordClick = () => { |
| 41 | setIsModalOpen(true); |
| 42 | }; |
| 43 | |
| 44 | const handleModalChoice = (choice: boolean) => { |
| 45 | setDiscordChecked(choice); |
| 46 | setIsModalOpen(false); |
| 47 | }; |
| 48 | const [adminPassword, setAdminPassword] = useState(''); |
| 49 | const [loading, setLoading] = useState<boolean>(false); |
| 50 | |
| 51 | const getLabelClassName = (value: string) => { |
| 52 | return `flex gap-1 p-4 rounded-lg items-center space-x-2 ${type === value ? 'border-[3px] border-blue-500' : 'border-[3px]' |
| 53 | }`; |
| 54 | }; |
| 55 | |
| 56 | const formatInputJSON = (value: string) => { |
| 57 | const valWithout = value.replaceAll("\\", "").slice(1, -1); |
| 58 | if (valWithout[0] === "{") { |
| 59 | return valWithout; |
| 60 | } |
| 61 | return valWithout.slice(1, -1); |
| 62 | }; |
| 63 | |
| 64 | const validateJSON = (value: string) => { |
| 65 | try { |
| 66 | JSON.parse(value); |
| 67 | return true; |
| 68 | } catch (error) { |
| 69 | return false; |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | const handleContentSubmit = async () => { |
| 74 | setLoading(true); |
| 75 | if (type === "appx") { |
| 76 | //@ts-ignore |
| 77 | metadata.appxVideoJSON = formatInputJSON(metadata.appxVideoJSON); |
| 78 | //@ts-ignore |
nothing calls this directly
no test coverage detected