diff --git a/frontend/src/components/editor/YorkieIntelligenceFeature.tsx b/frontend/src/components/editor/YorkieIntelligenceFeature.tsx index 44af0526..9f2fea27 100644 --- a/frontend/src/components/editor/YorkieIntelligenceFeature.tsx +++ b/frontend/src/components/editor/YorkieIntelligenceFeature.tsx @@ -60,7 +60,6 @@ function YorkieIntelligenceFeature(props: YorkieIntelligenceFeatureProps) { ); const data = useMemo(() => followUpData || featureData, [featureData, followUpData]); const { enqueueSnackbar } = useSnackbar(); - const featureCardRef = useRef(null); const markdownPreviewRef = useRef(null); const formContext = useForm<{ content: string }>(); const { reset, formState } = formContext; @@ -82,16 +81,11 @@ function YorkieIntelligenceFeature(props: YorkieIntelligenceFeatureProps) { }, [content, mutateIntelligenceFeature]); useEffect(() => { - if (data && markdownPreviewRef.current && featureCardRef.current) { + if (data && markdownPreviewRef.current) { markdownPreviewRef.current.scrollTo({ behavior: "smooth", top: markdownPreviewRef.current.scrollHeight, }); - featureCardRef.current.scrollIntoView({ - block: "nearest", - inline: "nearest", - behavior: "smooth", - }); } }, [data]); @@ -144,7 +138,7 @@ function YorkieIntelligenceFeature(props: YorkieIntelligenceFeatureProps) { }; return ( - + {title} diff --git a/frontend/src/components/editor/YorkieIntelligenceFooter.tsx b/frontend/src/components/editor/YorkieIntelligenceFooter.tsx index 04415500..a8a3027d 100644 --- a/frontend/src/components/editor/YorkieIntelligenceFooter.tsx +++ b/frontend/src/components/editor/YorkieIntelligenceFooter.tsx @@ -1,10 +1,11 @@ -import { Box, Card, Fade, Popover, useTheme } from "@mui/material"; +import { Box, Card, Popover, useTheme } from "@mui/material"; import YorkieIntelligenceFeatureList from "./YorkieIntelligenceFeatureList"; import { useEffect, useMemo, useRef, useState } from "react"; import { IntelligenceFeature } from "../../constants/intelligence"; import YorkieIntelligenceFeature from "./YorkieIntelligenceFeature"; import { useSelector } from "react-redux"; import { selectEditor } from "../../store/editorSlice"; +import CloseIntelligenceModal from "../modals/CloseIntelligenceModal"; interface YorkieIntelligenceFooterProps { onClose: () => void; @@ -18,15 +19,13 @@ function YorkieIntelligenceFooter(props: YorkieIntelligenceFooterProps) { const [selectedTitle, setSelectedTitle] = useState(null); const [selectedFeature, setSelectedFeature] = useState(null); const [anchorEl, setAnchorEl] = useState(); - const handleSelectFeature = (feature: IntelligenceFeature, title: string) => { - setSelectedFeature(feature); - setSelectedTitle(title); - }; + const [closeModalOpen, setCloseModalOpen] = useState(false); + const cardRef = useRef(null); + const width = useMemo( () => editorStore.cmView!.contentDOM.getBoundingClientRect().width - 12, [editorStore.cmView] ); - console.log(width); useEffect(() => { if (!anchorRef.current) return; @@ -38,6 +37,15 @@ function YorkieIntelligenceFooter(props: YorkieIntelligenceFooterProps) { }; }, [anchorRef.current]); + const handleSelectFeature = (feature: IntelligenceFeature, title: string) => { + setSelectedFeature(feature); + setSelectedTitle(title); + }; + + const handleCloseModalOpen = () => { + setCloseModalOpen((prev) => !prev); + }; + return ( + ); } diff --git a/frontend/src/components/modals/CloseIntelligenceModal.tsx b/frontend/src/components/modals/CloseIntelligenceModal.tsx new file mode 100644 index 00000000..7301daeb --- /dev/null +++ b/frontend/src/components/modals/CloseIntelligenceModal.tsx @@ -0,0 +1,53 @@ +import { Button, Modal, ModalProps, Paper, Stack, Typography } from "@mui/material"; + +interface CloseIntelligenceModalProps extends Omit { + onCloseIntelligence: () => void; +} + +function CloseIntelligenceModal(props: CloseIntelligenceModalProps) { + const { onCloseIntelligence, ...modalProps } = props; + + const handleCloseModal = () => { + modalProps?.onClose?.(new Event("Close Modal"), "escapeKeyDown"); + }; + + const handleDiscard = () => { + onCloseIntelligence(); + handleCloseModal(); + }; + + return ( + + + + + yorkie + + Do you want to discard +
+ the Yorkie response? +
+
+ + + + +
+
+
+ ); +} + +export default CloseIntelligenceModal;