From 1097337acd479d554f22b74342f7c2bae72e5f9b Mon Sep 17 00:00:00 2001 From: Joe Slain Date: Wed, 27 Nov 2024 11:15:43 +0100 Subject: [PATCH] chore: remove unused code --- src/components/Chat/Avatar.tsx | 29 ---- src/components/Chat/AvatarContainer.tsx | 9 -- .../Chat/ChatAdditionalContainer.tsx | 17 --- src/components/Chat/ChatHeightContainer.tsx | 9 -- src/components/Chat/GlobalChatContainer.tsx | 7 - src/components/Chat/NewQuestion.tsx | 24 ---- src/components/Chat/StreamingMessage.tsx | 11 -- .../Meeting/MeetingAdditionalInformation.tsx | 32 ----- .../Meeting/MeetingDefaultQuestions.tsx | 42 ------ .../Meeting/MeetingEditQuestion.tsx | 10 -- src/components/Meeting/MeetingFeedback.tsx | 64 --------- .../Meeting/MeetingFirstQuestionSidePanel.tsx | 21 --- src/components/Meeting/MeetingInputButton.tsx | 61 -------- src/components/Meeting/MeetingInputFields.tsx | 34 ----- src/components/Meeting/MeetingInputs.tsx | 58 -------- .../Meeting/MeetingMainInformations.tsx | 43 ------ .../Meeting/MeetingPromptAdvice.tsx | 46 ------- src/components/Meeting/MeetingQR.tsx | 69 ---------- src/components/Meeting/MeetingSeparator.tsx | 3 - src/components/Sheets/DisplaySheets.tsx | 40 ------ .../Sheets/SheetsAdditionalButtons.tsx | 103 -------------- .../Sheets/SheetsAdditionalTilesTitle.tsx | 7 - src/components/Sheets/SheetsTiles.tsx | 78 ----------- .../Sheets/SheetsTilesContainer.tsx | 79 ----------- src/constants/meeting.tsx | 130 ------------------ 25 files changed, 1026 deletions(-) delete mode 100644 src/components/Chat/Avatar.tsx delete mode 100644 src/components/Chat/AvatarContainer.tsx delete mode 100644 src/components/Chat/ChatAdditionalContainer.tsx delete mode 100644 src/components/Chat/ChatHeightContainer.tsx delete mode 100644 src/components/Chat/GlobalChatContainer.tsx delete mode 100644 src/components/Chat/NewQuestion.tsx delete mode 100644 src/components/Chat/StreamingMessage.tsx delete mode 100644 src/components/Meeting/MeetingAdditionalInformation.tsx delete mode 100644 src/components/Meeting/MeetingDefaultQuestions.tsx delete mode 100644 src/components/Meeting/MeetingEditQuestion.tsx delete mode 100644 src/components/Meeting/MeetingFeedback.tsx delete mode 100644 src/components/Meeting/MeetingInputButton.tsx delete mode 100644 src/components/Meeting/MeetingInputFields.tsx delete mode 100644 src/components/Meeting/MeetingInputs.tsx delete mode 100644 src/components/Meeting/MeetingMainInformations.tsx delete mode 100644 src/components/Meeting/MeetingPromptAdvice.tsx delete mode 100644 src/components/Meeting/MeetingQR.tsx delete mode 100644 src/components/Meeting/MeetingSeparator.tsx delete mode 100644 src/components/Sheets/DisplaySheets.tsx delete mode 100644 src/components/Sheets/SheetsAdditionalButtons.tsx delete mode 100644 src/components/Sheets/SheetsAdditionalTilesTitle.tsx delete mode 100644 src/components/Sheets/SheetsTiles.tsx delete mode 100644 src/components/Sheets/SheetsTilesContainer.tsx delete mode 100644 src/constants/meeting.tsx diff --git a/src/components/Chat/Avatar.tsx b/src/components/Chat/Avatar.tsx deleted file mode 100644 index 5b7fc6f1..00000000 --- a/src/components/Chat/Avatar.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import agentAvatar from '../../../icons/chat/Bulle-Albert.svg' -import userAvatar from '../../../icons/chat/Bulle-Utilisateur.svg' - -export function Avatar({ user }) { - const theme = localStorage.getItem('scheme') - return ( -
- {user === 'agent' ? ( - theme === 'dark' ? ( -
- Avatar de Albert -
- ) : ( -
- Avatar de Albert -
- ) - ) : theme === 'dark' ? ( -
- Avatar de l'utilisateur -
- ) : ( -
- Avatar de l'utilisateur -
- )} -
- ) -} diff --git a/src/components/Chat/AvatarContainer.tsx b/src/components/Chat/AvatarContainer.tsx deleted file mode 100644 index fb45b355..00000000 --- a/src/components/Chat/AvatarContainer.tsx +++ /dev/null @@ -1,9 +0,0 @@ -export function AvatarContainer({ children }) { - return ( -
-
-
{children}
-
-
- ) -} diff --git a/src/components/Chat/ChatAdditionalContainer.tsx b/src/components/Chat/ChatAdditionalContainer.tsx deleted file mode 100644 index 8d88fd49..00000000 --- a/src/components/Chat/ChatAdditionalContainer.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { useSelector } from 'react-redux' -import { GlobalColContainer } from '../Global/GlobalColContainer' -import { OneThirdScreenWidth } from '../Global/OneThirdScreenWidth' -import { DisplaySheets } from '../Sheets/DisplaySheets' - -/* - * Wrapper around sheets - */ -export function ChatAdditionalContainer({ archive }) { - return ( - - - - - - ) -} diff --git a/src/components/Chat/ChatHeightContainer.tsx b/src/components/Chat/ChatHeightContainer.tsx deleted file mode 100644 index f87f7187..00000000 --- a/src/components/Chat/ChatHeightContainer.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { GlobalColContainer } from '../Global/GlobalColContainer' - -export function ChatHeightContainer({ children }) { - return ( - -
{children}
-
- ) -} diff --git a/src/components/Chat/GlobalChatContainer.tsx b/src/components/Chat/GlobalChatContainer.tsx deleted file mode 100644 index bd9b166e..00000000 --- a/src/components/Chat/GlobalChatContainer.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export const GlobalChatContainer = ({ children }) => { - return ( -
- {children} -
- ) -} diff --git a/src/components/Chat/NewQuestion.tsx b/src/components/Chat/NewQuestion.tsx deleted file mode 100644 index 70953b7e..00000000 --- a/src/components/Chat/NewQuestion.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { redoUserQuestion } from '@constants/chatbotProps' -import type { RootState } from '@types' -import { useSelector } from 'react-redux' -import { NotifyArchiving } from '../Archive/NotifyArchiving' -import { BotQuestion } from '../Global/BotQuestion' -import { GlobalRowContainer } from '../Global/GlobalRowContainer' -import { Avatar } from './Avatar' - -export function NewQuestion() { - const user = useSelector((state: RootState) => state.user) - - return ( - <> - -
- -
- {redoUserQuestion} -
- {/* */} - {/* {!user.choices.newQuestion && } */} - - ) -} diff --git a/src/components/Chat/StreamingMessage.tsx b/src/components/Chat/StreamingMessage.tsx deleted file mode 100644 index f906fdfa..00000000 --- a/src/components/Chat/StreamingMessage.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { GlobalColContainer } from '../Global/GlobalColContainer' - -export function StreamingMessage({ children }) { - return ( - -
-

{children}

-
-
- ) -} diff --git a/src/components/Meeting/MeetingAdditionalInformation.tsx b/src/components/Meeting/MeetingAdditionalInformation.tsx deleted file mode 100644 index 85aef1b8..00000000 --- a/src/components/Meeting/MeetingAdditionalInformation.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { meetingContextualInfosTitle } from '@constants/meeting' -import type { MeetingInputContext } from '@types' -import { GlobalColContainer } from '../Global/GlobalColContainer' -import { GlobalSubtitle } from '../Global/GlobalSubtitle' -import { MeetingAdditionalInput } from './MeetingAdditionalInput' -import { MeetingDefaultQuestions } from './MeetingDefaultQuestions' - -/* - MeetingadditionalInformations: optional inputs for themes and administrations - COMPONENTS: - - ** MeetingAdditionalInput: set context from user input - - ** MeetingDefaultQuestions: proposes default questions to user and set context onClick() - - */ - -export function MeetingAdditionalInformations({ - context, - setContext, -}: { - context: MeetingInputContext - setContext: React.Dispatch> -}) { - return ( - - {meetingContextualInfosTitle} - - - - ) -} diff --git a/src/components/Meeting/MeetingDefaultQuestions.tsx b/src/components/Meeting/MeetingDefaultQuestions.tsx deleted file mode 100644 index ef8c6bf5..00000000 --- a/src/components/Meeting/MeetingDefaultQuestions.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { Button } from '@codegouvfr/react-dsfr/Button' -import { defaultButtonChoice } from '@constants/chatbotProps' -import { - defaultInputFields, - meetingDefaultQuestionsIntroduction, -} from '@constants/meeting' -import { CurrQuestionContext } from '@utils/context/questionContext' -import { useContext } from 'react' -import { GlobalRowContainer } from '../Global/GlobalRowContainer' - -export function MeetingDefaultQuestions({ setContext }) { - const { currQuestion, updateCurrQuestion } = useContext(CurrQuestionContext) - - const handleClick = (field) => { - updateCurrQuestion({ - ...currQuestion, - query: field.question, - }) - setContext({ themes: field.themes, administrations: field.administrations }) - } - - return ( - - - {meetingDefaultQuestionsIntroduction} - {defaultInputFields.map((field, index) => { - return ( - - ) - })} - - - ) -} diff --git a/src/components/Meeting/MeetingEditQuestion.tsx b/src/components/Meeting/MeetingEditQuestion.tsx deleted file mode 100644 index 2f4bdddc..00000000 --- a/src/components/Meeting/MeetingEditQuestion.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyButton } from '../Global/ModifyButton' - -export function MeetingEditQuestion({ setGenerate }) { - // Set generate to false allows us to go from to the response page to the input page - const handleClick = async () => { - setGenerate(false) - } - - return -} diff --git a/src/components/Meeting/MeetingFeedback.tsx b/src/components/Meeting/MeetingFeedback.tsx deleted file mode 100644 index ea46b266..00000000 --- a/src/components/Meeting/MeetingFeedback.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { feedbackUrl } from '@api' -import { thankFeedback } from '@constants/feedback' -import type { RootState } from '@types' -import { useFetch } from '@utils/hooks' -import { setHeaders } from '@utils/setData' -import { useState } from 'react' -import { useSelector } from 'react-redux' -import thumbsDown from '../../../icons/feedbacks/thumbsDown.svg' -import { GlobalParagraph } from '../Global/GlobalParagraph' - -/* - * User can select thumps up / down to give feedback - */ -export const MeetingFeedback = () => { - const streamId = useSelector((state: RootState) => state.user.streamId) - const [isClicked, setIsClicked] = useState(null) - - const handleClick = (isGood: boolean | null) => { - const data = { - is_good: isGood, - message: '', - } - useFetch(`${feedbackUrl}/${streamId}`, 'POST', { - data: JSON.stringify(data), - headers: setHeaders(false), - }) - - setIsClicked(isGood) - } - - return ( -
- - - {isClicked !== null && ( - {thankFeedback} - )} -
- ) -} diff --git a/src/components/Meeting/MeetingFirstQuestionSidePanel.tsx b/src/components/Meeting/MeetingFirstQuestionSidePanel.tsx index 63b2b8ab..cb6d9b80 100644 --- a/src/components/Meeting/MeetingFirstQuestionSidePanel.tsx +++ b/src/components/Meeting/MeetingFirstQuestionSidePanel.tsx @@ -3,27 +3,6 @@ import { GlobalColContainer } from 'components/Global/GlobalColContainer' import { OneThirdScreenWidth } from 'components/Global/OneThirdScreenWidth' import { useEffect } from 'react' -export function FirstQuestionExample({ - setQuestionInput, -}: { setQuestionInput: (question: string) => void }) { - return ( -
-
- Première utilisation ? -
-

Cliquez sur la question pour tester Albert

- -
- ) -} export function MeetingFirstQuestionHelper({ setContext, }: { diff --git a/src/components/Meeting/MeetingInputButton.tsx b/src/components/Meeting/MeetingInputButton.tsx deleted file mode 100644 index f9282956..00000000 --- a/src/components/Meeting/MeetingInputButton.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { chatUrl } from '@api' -import Button from '@codegouvfr/react-dsfr/Button' -import { meetingGenerateButton } from '@constants/meeting' -import type { MeetingInputContext, RootState } from '@types' -import { CurrQuestionContext } from '@utils/context/questionContext' -import { useFetch } from '@utils/hooks' -import { setHeaders } from '@utils/setData' -import { useContext } from 'react' -import { useDispatch, useSelector } from 'react-redux' - -/** - Button to send user query to /stream endpoint & switch to meeting stream page - FUNCTIONS: - - handleClick: setGenerate to true to switch to meeting stream page + create new chat id for meeting - context: - - **/ - -export function MeetingInputButton({ - setGenerate, - context, -}: { - setGenerate: React.Dispatch> - context: MeetingInputContext -}) { - const dispatch = useDispatch() - const stream = useSelector((state: RootState) => state.stream) - - const { currQuestion, updateCurrQuestion } = useContext(CurrQuestionContext) - const isDisable = - !currQuestion.query || (currQuestion.query && currQuestion.query.length === 0) - - const handleClick = async () => { - const headers = setHeaders(false) - const chat = await useFetch(chatUrl, 'POST', { - data: JSON.stringify({ chat_type: 'meeting' }), - headers, - }) - if (chat?.id && !stream.isStreaming) { - dispatch({ type: 'SET_USER_QUERY', nextUserQuery: currQuestion.query }) - updateCurrQuestion({ - ...currQuestion, - query: currQuestion.query, - }) - dispatch({ type: 'SET_CHAT_ID', nextChatId: chat.id }) - - setGenerate(true) - } - } - - return ( - - ) -} diff --git a/src/components/Meeting/MeetingInputFields.tsx b/src/components/Meeting/MeetingInputFields.tsx deleted file mode 100644 index 5c412bb1..00000000 --- a/src/components/Meeting/MeetingInputFields.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { meetingTitle } from '@constants/meeting' -import type { MeetingInputContext } from '@types' -import { GlobalRowContainer } from '../Global/GlobalRowContainer' -import { GlobalTitle } from '../Global/GlobalTitle' -import { MeetingAdditionalInformations } from './MeetingAdditionalInformation' -import { MeetingMainInformations } from './MeetingMainInformations' - -/****************************************************************************** - - COMPONENTS: - - ** MeetingMainInformations: set current question / user description - - ** MeetingAdditionalInformations: set context / administrations & themes - - ******************************************************************************/ - -export function MeetingInputFields({ - context, - setContext, -}: { - context: MeetingInputContext - setContext: React.Dispatch> -}) { - return ( - <> - {meetingTitle} - - - - - - ) -} diff --git a/src/components/Meeting/MeetingInputs.tsx b/src/components/Meeting/MeetingInputs.tsx deleted file mode 100644 index cbf91d19..00000000 --- a/src/components/Meeting/MeetingInputs.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import type { MeetingInputContext } from '@types' -import { CurrQuestionContext } from '@utils/context/questionContext' -import { updateQuestion } from '@utils/setData' -import { useContext, useEffect, useState } from 'react' -import { useDispatch } from 'react-redux' -import { GlobalDiv } from '../Global/GlobalDiv' -import { GlobalRowContainer } from '../Global/GlobalRowContainer' -import { MeetingInputButton } from './MeetingInputButton' -import { MeetingInputFields } from './MeetingInputFields' - -/***************************************************************************************************** - - VARIABLES: - - ** generate: to determine whether the user is in the description or stream phase - true: user entered prompt informations & click on generate button - false: - - user has just arrived on the meeting page - - OR clicked on the modify button. If so, emitCloseStream is called - - ** currQuestion: description provided by the user - ** context: additional informations provided by the user: administrations and themes tags - - ------------------------------------------------------------------------------------------------- - - COMPONENTS: - - ** MeetingInputFields: set current question & context (administrations / themes) from user input - - ** MeetingInputButton: setGenerate to true to switch to meeting stream page onClick - ! Meeting generation button is disable when current question is empty - - *****************************************************************************************************/ - -export function MeetingInputs({ - setGenerate, -}: { - setGenerate: React.Dispatch> -}) { - const [context, setContext] = useState({ - administrations: [], - themes: [], - }) - const dispatch = useDispatch() - const { currQuestion, updateCurrQuestion } = useContext(CurrQuestionContext) - //TODO: REMOVE USEEFFECT - useEffect(() => { - currQuestion.query && updateQuestion(currQuestion, updateCurrQuestion) - dispatch({ type: 'RESET_USER' }) - }, []) - - return ( -
- - -
- ) -} diff --git a/src/components/Meeting/MeetingMainInformations.tsx b/src/components/Meeting/MeetingMainInformations.tsx deleted file mode 100644 index 0ce77170..00000000 --- a/src/components/Meeting/MeetingMainInformations.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import Input from '@codegouvfr/react-dsfr/Input' -import { meetingSubtitle } from '@constants/meeting' -import { CurrQuestionContext } from '@utils/context/questionContext' -import { handleTextareaResize } from '@utils/manageEffects' -import { useContext } from 'react' -import { GlobalColContainer } from '../Global/GlobalColContainer' -import { GlobalSubtitle } from '../Global/GlobalSubtitle' -import { MeetingPromptAdvice } from './MeetingPromptAdvice' - -/* - * Meeting user's question input - */ -export function MeetingMainInformations() { - const { currQuestion, updateCurrQuestion } = useContext(CurrQuestionContext) - - const handleChange = (e) => { - e.preventDefault() - - updateCurrQuestion({ - ...currQuestion, - query: e.target.value, - }) - } - - return ( - - {meetingSubtitle} - - - - ) -} diff --git a/src/components/Meeting/MeetingPromptAdvice.tsx b/src/components/Meeting/MeetingPromptAdvice.tsx deleted file mode 100644 index e91c4931..00000000 --- a/src/components/Meeting/MeetingPromptAdvice.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { meetingInputGuidelines, meetingPromptExamples } from '@constants/meeting' -import { useState } from 'react' - -/* - * Advices and examples of good and bad prompts - */ -export function MeetingPromptAdvice() { - const [isAccordionOpen, setIsAccordionOpen] = useState(false) - - const handleToggleAll = () => { - setIsAccordionOpen(!isAccordionOpen) - } - - return ( - <> -
{meetingInputGuidelines}
-
-

- Voir des exemples -

- -
- {meetingPromptExamples.map((ex, index) => ( -
-
- {ex.alt} - - {ex.title} -
-
{ex.description}
-
- ))} - - ) -} diff --git a/src/components/Meeting/MeetingQR.tsx b/src/components/Meeting/MeetingQR.tsx deleted file mode 100644 index 921d64a1..00000000 --- a/src/components/Meeting/MeetingQR.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import type { RootState } from '@types' -import { createRef, useEffect, useState } from 'react' -import { useSelector } from 'react-redux' - -/***************************************************************************************** - - COMPONENTS: - - Frequently asked question suggestions - We get the related questions from the sheets - *****************************************************************************************/ -export function MeetingQR({ - setQuestion, -}: { - setQuestion: (question: string) => void -}) { - const sheets = useSelector((state: RootState) => state.user.sheets) - const [relatedQuestions, setRelatedQuestions] = useState([]) - - useEffect(() => { - if (!sheets || !sheets.length) return - - let updatedQuestions = [] - setRelatedQuestions([]) - - for (const sheet of sheets) { - if (sheet.related_questions) { - for (const qr of sheet.related_questions) { - const objectExists = updatedQuestions.some((obj) => obj.sid === qr.sid) - - if (!objectExists) { - updatedQuestions = [ - ...updatedQuestions, - { question: qr.question, sid: qr.sid, url: qr.url }, - ] - } - } - } - } - - setRelatedQuestions(updatedQuestions) - }, [sheets]) - - return ( -
- {relatedQuestions.length !== 0 && ( -

- Des questions posées fréquemment pour des situations similaires : -

- )} - {relatedQuestions.slice(0, 3).map((rq, index) => { - return ( - - ) - })} -
- ) -} diff --git a/src/components/Meeting/MeetingSeparator.tsx b/src/components/Meeting/MeetingSeparator.tsx deleted file mode 100644 index 246d4a3f..00000000 --- a/src/components/Meeting/MeetingSeparator.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export function MeetingSeparator({ children }) { - return
{children}
-} diff --git a/src/components/Sheets/DisplaySheets.tsx b/src/components/Sheets/DisplaySheets.tsx deleted file mode 100644 index 9a6f9c76..00000000 --- a/src/components/Sheets/DisplaySheets.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import type { ArchiveType } from '@types' -import { useState } from 'react' -import { SheetsAdditionalButtons } from './SheetsAdditionalButtons' -import { SheetsTilesContainer } from './SheetsTilesContainer' - -/***************************************************************************************** - - COMPONENTS: - - ** SheetsAdditionalButtons: allows user to add/delete sheets. Deleted sheets - from main section sheets permits to set must_not_sids and regenerate - stream - - ** SheetsTilesContainer: change main/additional sheets cards - - ! Additional sheets / tiles & must_not_sids are different - * must_not_sids: - - sheets id deleted ONLY FROM initial main sheets (user.sheets) - - have an impact on regeneration stream - - * sheets / tiles order: - - have an impact on what user sees but not always on regeneration (only if - it changes must_not_sids variable) - - *****************************************************************************************/ - -export function DisplaySheets({ archive }: { archive: ArchiveType | undefined }) { - const [isModifiable, setIsModifiable] = useState(false) - - return ( - <> - - - - ) -} diff --git a/src/components/Sheets/SheetsAdditionalButtons.tsx b/src/components/Sheets/SheetsAdditionalButtons.tsx deleted file mode 100644 index b6f023ed..00000000 --- a/src/components/Sheets/SheetsAdditionalButtons.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import type { ArchiveType, RootState } from '@types' -import { useContext, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' - -import { indexesUrl, streamUrl } from '@api' -import { sheetsTitle } from '@constants/sheets' -import { CurrQuestionContext } from '@utils/context/questionContext' -import { getIndexes } from '@utils/setData' -import { GlobalSecondaryTitle } from 'components/Global/GlobalSecondaryTitle' -import { ModifyButton } from 'components/Global/ModifyButton' - -/***************************************************************************************** - - USEEFFECT [isModifiable]: set deleted sheets: - - if a new deleted sheet has been added from initial main sheets - - no regeneration on archive view - - user was on edition mode and has saved his/her changes - - USEEFFECT [deletedSheets]: regenerate stream - - *****************************************************************************************/ - -export const SheetsAdditionalButtons = ({ - isModifiable, - setIsModifiable, - archive, -}: { - isModifiable: boolean - setIsModifiable: React.Dispatch> - archive: ArchiveType | undefined -}) => { - const buttonTitle = isModifiable ? 'Enregistrer' : 'Modifier la section' - const buttonIcon = isModifiable - ? 'fr-icon-save-3-fill fr-icon--sm flex items-center' - : 'fr-icon-settings-5-fill fr-icon--sm flex items-center' - const user = useSelector((state: RootState) => state.user) - const [deletedSheets, setDeletedSheets] = useState([]) - const dispatch = useDispatch() - const { currQuestion, updateCurrQuestion } = useContext(CurrQuestionContext) - const handleClick = () => { - setIsModifiable(!isModifiable) - } - - useEffect(() => { - if ( - !archive && - !isModifiable && - JSON.stringify(deletedSheets) !== JSON.stringify(user.question.must_not_sids) - ) - setDeletedSheets(user.question.must_not_sids) - }, [isModifiable]) - - useEffect(() => { - if (archive) return - - if (!deletedSheets.length && !currQuestion.must_not_sids.length) return - - updateCurrQuestion({ - ...currQuestion, - must_not_sids: deletedSheets, - }) - }, [deletedSheets]) - - useEffect(() => { - if (!user.streamId || archive || !currQuestion.query) return - - const data = { - question: currQuestion.query, - must_not_sids: user.question.must_not_sids, - } - getIndexes( - data, - dispatch, - 'chunks', - currQuestion.limit, - JSON.stringify(user.streamId), - indexesUrl, - ) - getIndexes( - data, - dispatch, - 'sheets', - currQuestion.limit, - JSON.stringify(user.streamId), - indexesUrl, - ) - }, [user.streamId, currQuestion]) - - return ( -
- {sheetsTitle} - <> - {!archive && ( - - )} - -
- ) -} diff --git a/src/components/Sheets/SheetsAdditionalTilesTitle.tsx b/src/components/Sheets/SheetsAdditionalTilesTitle.tsx deleted file mode 100644 index 4747e1fe..00000000 --- a/src/components/Sheets/SheetsAdditionalTilesTitle.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export const SheetsAdditionalTilesTitle = () => { - return ( -

- D'autres liens pratiques qui pourraient vous intéresser : -

- ) -} diff --git a/src/components/Sheets/SheetsTiles.tsx b/src/components/Sheets/SheetsTiles.tsx deleted file mode 100644 index 7e75e852..00000000 --- a/src/components/Sheets/SheetsTiles.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { Tile } from '@codegouvfr/react-dsfr/Tile' -import { Tile as TileType } from '@types' -import { useDispatch } from 'react-redux' - -export const SheetsTiles = ({ - tiles, - isModifiable, - type, -}: { - tiles: any[] - isModifiable: boolean - type: string -}) => { - const text = type === 'main' ? 'X Supprimer' : '+ Ajouter' - const dispatch = useDispatch() - const handleClick = (key: number) => { - if (type === 'main') dispatch({ type: 'REMOVE_SHEETS', indexToRemove: key }) - else dispatch({ type: 'ADD_SHEETS', indexToAdd: key }) - } - - return ( - <> - {tiles.map((tile, key) => ( -
- - {isModifiable && ( -
handleClick(key)} - > - {text} -
- )} -
- ))} - - ) -} - -function TileTest() { - return ( -
-
-
-

- - Rejoindre la communauté - -

-

- Le Système de Design réunit 550 membres experts du numérique : designers, - développeurs, chefs de produit ou chefs de projet. Rejoignez-nous ! -

-
-
{' '} -
-
- -
-
-
- ) -} diff --git a/src/components/Sheets/SheetsTilesContainer.tsx b/src/components/Sheets/SheetsTilesContainer.tsx deleted file mode 100644 index 8c7ea425..00000000 --- a/src/components/Sheets/SheetsTilesContainer.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { getSheetsUrl, indexesUrl } from '@api' -import type { ArchiveType, RootState, Sheet } from '@types' -import { CurrQuestionContext } from '@utils/context/questionContext' -import { useFetch } from '@utils/hooks' -import { setHeaders, setIndexesData, setTilesFromSheets } from '@utils/setData' -import { useContext, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' -import { SheetsAdditionalTilesTitle } from './SheetsAdditionalTilesTitle' -import { SheetsTiles } from './SheetsTiles' - -/**************************************************************************************** - - USEEFFECT [currQuestion]: set user.sheets & user.additionalSheets from GET /indexes - sheets data OR from archive - -*****************************************************************************************/ - -export const SheetsTilesContainer = ({ - archive, - isModifiable, -}: { - archive: ArchiveType - isModifiable: boolean -}) => { - const user = useSelector((state: RootState) => state.user) - const [tiles, setTiles] = useState([]) - const [additionalTiles, setAdditionalTiles] = useState([]) - const { currQuestion } = useContext(CurrQuestionContext) - const dispatch = useDispatch() - useEffect(() => { - const data = { - question: currQuestion.query, - must_not_sids: user.question.must_not_sids, - } - const streamId = archive ? archive.id : user.streamId - if (!streamId) return - - setIndexesData(data, setTiles, dispatch, JSON.stringify(streamId), indexesUrl) - }, [user.streamId, currQuestion]) - - const getSheets = async () => { - const data = { - uids: archive.search_sids, - } - const sheets: Sheet[] = await useFetch(getSheetsUrl, 'POST', { - headers: setHeaders(false), - data: JSON.stringify(data), - }) - setTilesFromSheets(sheets, setTiles) - } - - useEffect(() => { - if (!archive || !archive.search_sids) return - - getSheets() - }, []) - - useEffect(() => { - if (archive) return - setTilesFromSheets(user.sheets, setTiles) - setTilesFromSheets(user.additionalSheets, setAdditionalTiles) - }, [user.additionalSheets]) - - return ( - <> - - {isModifiable && additionalTiles.length !== 0 && ( - <> - - - - )} - - ) -} diff --git a/src/constants/meeting.tsx b/src/constants/meeting.tsx deleted file mode 100644 index 896d78f9..00000000 --- a/src/constants/meeting.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import thumbsDown from '../../icons/feedbacks/thumbsDown.svg' -import thumbsUp from '../../icons/feedbacks/thumbsUp.svg' -import { GlobalRowContainer } from '../components/Global/GlobalRowContainer' - -export const meetingTitle = 'Échanger avec Albert' -export const meetingSubtitle = 'Description de la situation de l’usager' -export const meetingInputGuidelines = ( - <> -

- Quelques bonnes pratiques pour décrire la situation d’un usager -

-
- -

- Utiliser des termes précis (eg. parler de « formulaire cerfa » au lieu de « - demande papier ») -

-
-
- -

- Formuler une question à la fin de la description pour orienter la recherche - d’Albert. -

-
-
- -

- Éviter d’indiquer des informations personnelles, notamment celles trouvées sur un - compte administratif de l’usager. -

-
-
- -

- Éviter d’utiliser seulement des mots clés pour décrire la situation de l’usager. -

-
- -) - -export const meetingPromptExamples = [ - { - img: thumbsUp, - alt: "Pouce en l'air", - title: ( -

- Exemple de bonne description -

- ), - description: ( -

- L'usagère ne comprend pas son allocation RSA ait diminué. -
- Après étude de son compte, il semble que la CAF opère une retenue sur son - allocation. -
- La CAF peut-elle faire une saisie sur le RSA et sous quelles conditions ? -

- ), - }, - { - img: thumbsDown, - alt: 'Pouce vers le bas', - title: ( -

- Exemple de mauvaise description -

- ), - description: ( -

- [Monsieur Durant] ne comprend pas que son allocation RSA ait diminué. -
- Après avoir saisi ses [identifiants n°XXX mot de passe XXX], il semble que la CAF - opère une retenue sur son allocation. -
- [Pas de question de fin] -

- ), - }, -] - -export const meetingContextualInfosTitle = 'Informations contextuelles' -export const meetingGenerateButton = 'Échanger avec Albert' -export const meetingAppointmentInformations = - 'Votre question sur la situation de l’usager' -export const meetingAppointmentTitle = 'Échanger avec Albert' - -export const meetingDefaultQuestionsIntroduction = ( - -
Tester Albert
-

- Ceci est votre première utilisation d’Albert et vous souhaitez comprendre simplement - son fonctionnement ? Nous vous avons préparé deux scénarios de tests pour cela. Il - suffit de cliquer sur l’une des options ci-dessous. -

-
-) - -export const defaultInputFields = [ - { - title: 'Comprendre une saisie RSA par la CAF', - question: - 'Une usagère ne comprend par le montant d’allocations sociales qu’elle touche ce mois-ci. En effet, le montant a été divisé par deux par rapport aux mois précédents et elle n’a plus que 150€. Elle cherche à comprendre pourquoi le montant a ainsi diminué.\n\nAprès avoir consulté le compte CAF de l’usagère avec son accord, il semble que la CAF opère une retenue sur le montant du RSA allouée à l’usagère suite à une déclaration erronée par le passé.\n\nLa CAF peut-elle faire une saisie sur le RSA et sous quelles conditions ? Comment débloquer la situation ?', - themes: ['Allocation sociale', 'RSA'], - administrations: ['CAF'], - }, -] - -export const resultMeetingTitle = 'Réponse proposée par Albert' -export const meetingQRTitle = - 'Des questions posées fréquemment pour des situations similaires :'