forked from ChatGPTNextWeb/ChatGPT-Next-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
8 changed files
with
315 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.button-add { | ||
background-color: transparent; | ||
border: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import styles from "./inputList.module.scss"; | ||
import AddIcon from "../../../icons/add.svg"; | ||
import { InputListValue } from "../../types"; | ||
import InputListItem from "./inputListItem/inputListItem"; | ||
import { SalesGPTIconButton } from "../salesGPTIconButton"; | ||
|
||
type InputListProps = { | ||
inputListValues: InputListValue[]; | ||
setInputListValues: React.Dispatch<React.SetStateAction<InputListValue[]>>; | ||
}; | ||
|
||
const InputList = ({ inputListValues, setInputListValues }: InputListProps) => { | ||
function addValue(value: string) { | ||
const updatedValues: InputListValue[] = [ | ||
...inputListValues, | ||
{ index: inputListValues.length, value }, | ||
]; | ||
setInputListValues(updatedValues); | ||
} | ||
|
||
function updateValue(index: number, newValue: string) { | ||
const updatedValues = [...inputListValues]; | ||
updatedValues[index] = { index, value: newValue }; | ||
setInputListValues(updatedValues); | ||
} | ||
|
||
function deleteValue(valueToDelete: string) { | ||
let updatedValues: InputListValue[] = []; | ||
inputListValues.map((value) => { | ||
if (value.value !== valueToDelete) { | ||
updatedValues.push(value); | ||
} | ||
}); | ||
updateIndex(updatedValues); | ||
} | ||
|
||
function updateIndex(listToUpdate: InputListValue[]) { | ||
let updatedIndexValues: InputListValue[] = []; | ||
listToUpdate.map((inputListValue, index) => { | ||
updatedIndexValues.push({ index: index, value: inputListValue.value }); | ||
}); | ||
setInputListValues(updatedIndexValues); | ||
} | ||
|
||
return ( | ||
<> | ||
{inputListValues.map((inputListValue) => { | ||
return ( | ||
<InputListItem | ||
key={inputListValue.index} | ||
updateValue={updateValue} | ||
deleteValue={deleteValue} | ||
InputListValue={inputListValue} | ||
/> | ||
); | ||
})} | ||
<SalesGPTIconButton | ||
role="button" | ||
className={styles["button-add"]} | ||
text={""} | ||
icon={<AddIcon />} | ||
onClick={() => addValue("")} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default InputList; |
40 changes: 40 additions & 0 deletions
40
app/salesGPT/components/inputLIst/inputListItem/inputListItem.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.input-list-item { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
|
||
.label-input { | ||
padding-right: 6px; | ||
} | ||
|
||
@mixin sharedStyle { | ||
font-size: 1rem; | ||
|
||
border: 0.5px solid white; | ||
padding: 1rem; | ||
|
||
height: 48px; | ||
|
||
color: black; | ||
background-color: white; | ||
} | ||
|
||
input[type="text"].input { | ||
@include sharedStyle(); | ||
|
||
width: 100%; | ||
|
||
border-radius: 10px 0 0 10px; | ||
|
||
text-align: left; | ||
|
||
background-color: white; | ||
color: black; | ||
} | ||
|
||
.button-remove { | ||
@include sharedStyle(); | ||
|
||
border-radius: 0 10px 10px 0; | ||
} |
42 changes: 42 additions & 0 deletions
42
app/salesGPT/components/inputLIst/inputListItem/inputListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { InputListValue } from "@/app/salesGPT/types"; | ||
import styles from "./inputListItem.module.scss"; | ||
import CloseIcon from "../../../../icons/close.svg"; | ||
import { SalesGPTIconButton } from "../../salesGPTIconButton"; | ||
|
||
type ListInputProps = { | ||
InputListValue: InputListValue; | ||
updateValue: Function; | ||
deleteValue: Function; | ||
}; | ||
|
||
const ListInput = ({ | ||
InputListValue, | ||
updateValue, | ||
deleteValue, | ||
}: ListInputProps) => { | ||
return ( | ||
<div className={styles["input-list-item"]}> | ||
<label className={styles["label-input"]} htmlFor="requirements"> | ||
{InputListValue.index + 1}: | ||
</label> | ||
|
||
<input | ||
className={styles["input"]} | ||
type="text" | ||
id="requirements" | ||
placeholder={""} | ||
value={InputListValue.value} | ||
onChange={(e) => updateValue(InputListValue.index, e.target.value)} | ||
/> | ||
|
||
<SalesGPTIconButton | ||
role="button" | ||
className={styles["button-remove"]} | ||
icon={<CloseIcon />} | ||
onClick={() => deleteValue(InputListValue.value)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ListInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.