From 0198ec50c3ba477079df8bed53d51789913663d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A6Ltorio?= Date: Wed, 6 Nov 2024 15:39:52 +0100 Subject: [PATCH] ajout de la documentation et des commentaires dans le composant HeroComboPrompts --- src/aipane/components/HeroComboPrompts.tsx | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/aipane/components/HeroComboPrompts.tsx b/src/aipane/components/HeroComboPrompts.tsx index ab0dce5..94cd02f 100644 --- a/src/aipane/components/HeroComboPrompts.tsx +++ b/src/aipane/components/HeroComboPrompts.tsx @@ -1,15 +1,28 @@ -/* -========================================================= -* © 2024 Ronan LE MEILLAT for SCTG Development -========================================================= -*/ +/** + * ========================================================= + * © 2024 Ronan LE MEILLAT for SCTG Development + * ========================================================= + * @file HeroComboPrompts.tsx + * @description The HeroComboPrompts component for the AI pane. + * @author Ronan LE MEILLAT + * @copyright 2024 Ronan LE MEILLAT for SCTG Development + * @license AGPLv3 + * This component is part of the AI pane module for the Outlook add-in. + */ import * as React from "react"; import { Dropdown, Label, makeStyles, Option, SelectionEvents, useId } from "@fluentui/react-components"; import { useState, useEffect, useCallback, useMemo } from "react"; import { getPrompts, type AIPrompt } from "../AIPrompt"; import { config } from "../config"; interface HeroComboPromptsProps { + /** + * Callback function to notify the parent component of the selected value. + * @param selectedValue The selected value. + */ onChange: (selectedValue: string) => void; + /** + * Flag indicating whether the component is running in standalone mode (ie not running inside Outlook). + */ standalone: boolean | null; } @@ -40,16 +53,20 @@ const HeroComboPrompts: React.FC = ({ onChange, standalon console.log(`Retrieving prompts with: standalone=${standalone}`); return getPrompts(standalone || false); } else { - console.error("Standalone mode not set"); + // console.error("Standalone mode not set"); return []; } }, [standalone]); + // Compute the default value for the dropdown const defaultValue = useMemo(() => { + // Use the summary and user properties of the first prompt as the default value return (config.prompts[0].summary || config.prompts[0].system) + " " + config.prompts[0].user; }, [config.prompts[0]]); + // Compute the options for the dropdown const options = useMemo(() => { + // Map each prompt to an Option component return prompts.map((prompt: AIPrompt) => (