(props: {
groupId: string | null;
setGroupId: (actionGroupId: string | null) => void;
groups: { name: string; id: string }[];
setQuestions: React.Dispatch<React.SetStateAction<UIQuestionMessageData[]>>;
variableData: ApprovalVariable[];
})
| 10 | import { UIQuestionMessageData } from "../../pages/approval"; |
| 11 | |
| 12 | export function AddQuestionModal(props: { |
| 13 | groupId: string | null; |
| 14 | setGroupId: (actionGroupId: string | null) => void; |
| 15 | groups: { name: string; id: string }[]; |
| 16 | setQuestions: React.Dispatch<React.SetStateAction<UIQuestionMessageData[]>>; |
| 17 | variableData: ApprovalVariable[]; |
| 18 | }) { |
| 19 | const { profile } = useProfile(); |
| 20 | const supabase = useSupabaseClient<Database>(); |
| 21 | const [questionText, setQuestionText] = useState<string>(""); |
| 22 | const [error, setError] = useState<string | null>(null); |
| 23 | const [loading, setLoading] = useState<boolean>(false); |
| 24 | const [chosenGroupId, setChosenGroupId] = useState<string | null>(null); |
| 25 | useEffect(() => { |
| 26 | if (props.groupId) { |
| 27 | setChosenGroupId(props.groupId); |
| 28 | } |
| 29 | setQuestionText(""); |
| 30 | }, [props.groupId]); |
| 31 | |
| 32 | return ( |
| 33 | <ClarifyCloseModal |
| 34 | open={props.groupId !== null} |
| 35 | setOpen={() => props.setGroupId(null)} |
| 36 | classNames={"max-w-2xl overflow-visible"} |
| 37 | shouldClarify={Boolean(questionText)} |
| 38 | > |
| 39 | <div className="w-full flex flex-col"> |
| 40 | <h1 className={"text-lg text-gray-200 mb-2"}>Add Question</h1> |
| 41 | <input |
| 42 | value={questionText} |
| 43 | onChange={(e) => setQuestionText(e.target.value)} |
| 44 | className="rounded-md bg-gray-700 border-gray-400 text-gray-100 px-2 py-1 placeholder:text-gray-400" |
| 45 | placeholder={"Question - include parameters like {parameter}"} |
| 46 | /> |
| 47 | {error && <div className="text-red-500 text-sm mt-1">{error}</div>} |
| 48 | <div className="flex flex-row place-items-center gap-x-4 w-1/2 mt-4"> |
| 49 | <div className={"text-gray-300"}>Group:</div> |
| 50 | <SelectBox |
| 51 | options={props.groups} |
| 52 | selected={chosenGroupId} |
| 53 | setSelected={async (selected: string) => { |
| 54 | setChosenGroupId(selected); |
| 55 | }} |
| 56 | theme={"dark"} |
| 57 | includeNull={true} |
| 58 | /> |
| 59 | </div> |
| 60 | |
| 61 | <div className={"flex flex-row justify-end gap-x-2 mt-2"}> |
| 62 | <button |
| 63 | className={"bg-gray-500 rounded px-2 py-1 text-gray-50"} |
| 64 | onClick={() => props.setGroupId(null)} |
| 65 | > |
| 66 | Cancel |
| 67 | </button> |
| 68 | <button |
| 69 | className={classNames( |
nothing calls this directly
no test coverage detected