import { NodeViewWrapper } from '@tiptap/react' import { Loader, Video } from 'lucide-react' import React, { useEffect } from 'react' import styled from 'styled-components' import { uploadNewVideoFile } from '../../../../../services/blocks/Video/video' import { getActivityBlockMediaDirectory } from '@services/media/media' import { UploadIcon } from '@radix-ui/react-icons' import { useOrg } from '@components/Contexts/OrgContext' import { useCourse } from '@components/Contexts/CourseContext' import { useEditorProvider } from '@components/Contexts/Editor/EditorContext' import { useLHSession } from '@components/Contexts/LHSessionContext' function VideoBlockComponents(props: any) { const org = useOrg() as any const course = useCourse() as any const editorState = useEditorProvider() as any const isEditable = editorState.isEditable const [video, setVideo] = React.useState(null) const session = useLHSession() as any const access_token = session?.data?.tokens?.access_token; const [isLoading, setIsLoading] = React.useState(false) const [blockObject, setblockObject] = React.useState( props.node.attrs.blockObject ) const fileId = blockObject ? `${blockObject.content.file_id}.${blockObject.content.file_format}` : null const handleVideoChange = (event: React.ChangeEvent) => { setVideo(event.target.files[0]) } const handleSubmit = async (e: any) => { e.preventDefault() setIsLoading(true) let object = await uploadNewVideoFile( video, props.extension.options.activity.activity_uuid, access_token ) setIsLoading(false) setblockObject(object) props.updateAttributes({ blockObject: object, }) } useEffect(() => { }, [course, org]) return ( {!blockObject && ( {isLoading ? ( ) : ( <>
)}
)} {blockObject && ( )}
) } const BlockVideoWrapper = styled.div` border: ${(props) => props.contentEditable ? '2px dashed #713f1117' : 'none'}; // center align-items: center; justify-content: center; text-align: center; font-size: 14px; ` const BlockVideo = styled.div` display: flex; flex-direction: column; ` export default VideoBlockComponents