import React from 'react' import styled from 'styled-components' import { Droppable, Draggable } from '@hello-pangea/dnd' import Activity from './Activity' import { Hexagon, MoreVertical, Pencil, Save, Sparkles, X } from 'lucide-react' import ConfirmationModal from '@components/Objects/StyledElements/ConfirmationModal/ConfirmationModal' import { useRouter } from 'next/navigation' import { updateChapter } from '@services/courses/chapters' import { mutate } from 'swr' import { getAPIUrl } from '@services/config/config' import { revalidateTags } from '@services/utils/ts/requests' import { useLHSession } from '@components/Contexts/LHSessionContext' interface ModifiedChapterInterface { chapterId: string chapterName: string } function Chapter(props: any) { const router = useRouter() const session = useLHSession() as any; const [modifiedChapter, setModifiedChapter] = React.useState< ModifiedChapterInterface | undefined >(undefined) const [selectedChapter, setSelectedChapter] = React.useState< string | undefined >(undefined) async function updateChapterName(chapterId: string) { if (modifiedChapter?.chapterId === chapterId) { let modifiedChapterCopy = { name: modifiedChapter.chapterName, } await updateChapter(chapterId, modifiedChapterCopy, session.data?.tokens?.access_token) await mutate(`${getAPIUrl()}chapters/course/${props.course_uuid}/meta`) await revalidateTags(['courses'], props.orgslug) router.refresh() } setSelectedChapter(undefined) } return ( {(provided, snapshot) => (
{selectedChapter === props.info.list.chapter.id ? (
setModifiedChapter({ chapterId: props.info.list.chapter.id, chapterName: e.target.value, }) } />
) : (

{props.info.list.chapter.name}

)} setSelectedChapter(props.info.list.chapter.id)} />

Delete Chapter

} functionToExecute={() => props.deleteChapter(props.info.list.chapter.id) } status="warning" > {(provided) => (
{props.info.list.activities.map( (activity: any, index: any) => ( ) )} {provided.placeholder}
{ props.openNewActivityModal(props.info.list.chapter.id) }} className="flex space-x-2 items-center py-5 my-3 rounded-md justify-center text-white bg-black hover:cursor-pointer" >
Add Activity +{' '}
)}
)}
) } const ChapterWrapper = styled.div` margin-bottom: 20px; padding: 12px; font-size: 15px; display: block; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.19); box-shadow: 0px 13px 33px -13px rgb(0 0 0 / 12%); transition: all 0.2s ease; h3 { padding-left: 20px; padding-right: 20px; } ` const ActivitiesList = styled.div` padding: 10px; ` export default Chapter