From 21b23ed8c7f8feb8bf340a6f1c896e1bc44145b0 Mon Sep 17 00:00:00 2001 From: Trym Veiby <110395932+TrymVei@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:31:22 +0100 Subject: [PATCH] Update sidebar to form (#45) * feat: possible to render different input fields based on selected value on HelpSelect(WIP) * feat: render fields based on helpSelect * feat: inputList component * fix: correct indexing when deleting elements * feat: list of requirements now works with the prompt * fix: updated styling for remove requirement button * fix: requirements colors match select * feat: validation employee selected * fix: iconbutton type can now be set * fix: idepentent iconbutton * fix: revert button --- app/salesGPT/components/employeeSelect.tsx | 1 + .../inputLIst/inputList.module.scss | 4 + .../components/inputLIst/inputList.tsx | 68 ++++++++ .../inputListItem/inputListItem.module.scss | 40 +++++ .../inputLIst/inputListItem/inputListItem.tsx | 42 +++++ app/salesGPT/components/salesGPT.tsx | 163 ++++++++++-------- .../components/salesGPTIconButton.tsx | 64 +++++++ app/salesGPT/types.ts | 5 + 8 files changed, 315 insertions(+), 72 deletions(-) create mode 100644 app/salesGPT/components/inputLIst/inputList.module.scss create mode 100644 app/salesGPT/components/inputLIst/inputList.tsx create mode 100644 app/salesGPT/components/inputLIst/inputListItem/inputListItem.module.scss create mode 100644 app/salesGPT/components/inputLIst/inputListItem/inputListItem.tsx create mode 100644 app/salesGPT/components/salesGPTIconButton.tsx diff --git a/app/salesGPT/components/employeeSelect.tsx b/app/salesGPT/components/employeeSelect.tsx index a4a3a18feb2..682495337b2 100644 --- a/app/salesGPT/components/employeeSelect.tsx +++ b/app/salesGPT/components/employeeSelect.tsx @@ -76,6 +76,7 @@ function EmployeeSelect({ return ( updateValue(InputListValue.index, e.target.value)} + /> + + } + onClick={() => deleteValue(InputListValue.value)} + /> + + ); +}; + +export default ListInput; diff --git a/app/salesGPT/components/salesGPT.tsx b/app/salesGPT/components/salesGPT.tsx index 10fc58d10d1..647250a1af2 100644 --- a/app/salesGPT/components/salesGPT.tsx +++ b/app/salesGPT/components/salesGPT.tsx @@ -1,7 +1,12 @@ "use client"; import React, { useEffect, useState } from "react"; import { Loading } from "@/app/components/chatHomepage"; -import { EmployeeItem, HelpOption, HelpOptionValue } from "../types"; +import { + EmployeeItem, + HelpOption, + HelpOptionValue, + InputListValue, +} from "../types"; import EmployeeCVSummary from "./employeeCVSummary"; import { ErrorBoundary } from "../../components/error"; import { @@ -26,6 +31,8 @@ import RightPane from "./rightPane"; import RequirementsList from "./requirementsList"; import { SALES_GPT_MASK } from "@/app/masks/no"; import { projectExperienceToText } from "@/app/function/ProjectExperienceToText"; +import InputList from "./inputLIst/inputList"; +import { SalesGPTIconButton } from "./salesGPTIconButton"; const availableHelp: HelpOption[] = [ { @@ -55,7 +62,6 @@ function _SalesGPT() { EmployeeItem | undefined >(undefined); - const [requirementText, setRequirementText] = useState(""); const [requirementResponse, setRequirementResponse] = useState< RequirementResponse[] >([]); @@ -64,13 +70,17 @@ function _SalesGPT() { const [isAnalysisLoading, setIsAnalysisLoading] = useState(false); const [selectedHelp, setSelectedHelp] = useState( - undefined, + availableHelp[0], ); const [showCVSummary, setShowCVSummary] = useState(false); const [showRequirementsList, setShowRequirementsList] = useState(false); const [concise, setConcise] = useState(false); + const [inputListValues, setInputListValues] = useState([ + { index: 0, value: "" }, + ]); + function handleSelectEmployee(newValue: EmployeeItem | undefined): void { setSelectedEmployee(newValue); // TODO: Handle query params later @@ -202,7 +212,9 @@ function _SalesGPT() { async function handleAnalyseButtonClick(): Promise { setIsAnalysisLoading(true); setRequirementResponse([]); - const requirements = requirementText.split("\n").filter((s) => s.length); + const requirements = inputListValues.map( + (requirement) => requirement.value, + ); const employeeAlias = aliasFromEmail(selectedEmployee?.email); if (selectedHelp?.value == HelpOptionValue.RequirementList) { @@ -260,74 +272,81 @@ function _SalesGPT() { >
-
- - -
-
- - -
-
- - -
-
- - -
-
- - setConcise(event.target.checked)} - /> -
-
- -
-
- -
+
{ + e.preventDefault(); + }} + > +
+ + +
+
+ +
{ + e.preventDefault(); + handleAnalyseButtonClick(); + }} + > +
+ + +
+ +
+ + +
+ + {/* TODO: Kanskje dele opp koden så vi har en getField som rendrer basert på selectedHelp. lettere hvis vi endrer på value */} + {selectedHelp?.value !== "requirementlist" && ( +
+ + +
+ )} +
+ +
+
+ +
+
void; + icon?: JSX.Element; + type?: ButtonType; + text?: string; + bordered?: boolean; + shadow?: boolean; + className?: string; + title?: string; + disabled?: boolean; + tabIndex?: number; + autoFocus?: boolean; + role?: "button" | "submit" | "reset" | undefined; +} + +export function SalesGPTIconButton({ + onClick, + icon, + type, + text, + bordered, + shadow, + className, + title, + disabled, + tabIndex, + autoFocus, + role = "button", +}: SalesGPTIconButtonProps) { + return ( + + ); +} diff --git a/app/salesGPT/types.ts b/app/salesGPT/types.ts index 4affdd850d6..af5fdec7f0d 100644 --- a/app/salesGPT/types.ts +++ b/app/salesGPT/types.ts @@ -78,3 +78,8 @@ export type HelpOption = { label: string; value: HelpOptionValue | undefined; }; + +export type InputListValue = { + index: number; + value: string; +};