MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / AddGroupModal

Function AddGroupModal

components/approval/addQuestionModal.tsx:520–593  ·  view source on GitHub ↗
(props: {
  open: boolean;
  close: () => void;
  setGroups: React.Dispatch<
    React.SetStateAction<
      { name: string; id: string; questions: UIQuestionMessageData[] }[]
    >
  >;
})

Source from the content-addressed store, hash-verified

518}
519
520export function AddGroupModal(props: {
521 open: boolean;
522 close: () => void;
523 setGroups: React.Dispatch<
524 React.SetStateAction<
525 { name: string; id: string; questions: UIQuestionMessageData[] }[]
526 >
527 >;
528}) {
529 const { profile } = useProfile();
530 const supabase = useSupabaseClient<Database>();
531 const [groupName, setGroupName] = useState<string>("");
532 const [error, setError] = useState<string | null>(null);
533
534 return (
535 <ClarifyCloseModal
536 open={props.open}
537 setOpen={props.close}
538 classNames={"max-w-xl overflow-visible"}
539 shouldClarify={Boolean(groupName)}
540 >
541 <div className="w-full flex flex-col">
542 <h1 className={"text-lg text-gray-200 mb-2"}>Add Question Group</h1>
543 <input
544 value={groupName}
545 onChange={(e) => setGroupName(e.target.value)}
546 className="rounded-md bg-gray-700 border-gray-400 text-gray-100 px-2 py-1 placeholder:text-gray-400"
547 placeholder={"E.g. Sales"}
548 />
549 {error && <div className="text-red-500 text-sm mt-1">{error}</div>}
550
551 <div className={"flex flex-row justify-end gap-x-2 mt-2"}>
552 <button
553 className={"bg-gray-500 rounded px-2 py-1 text-gray-50"}
554 onClick={props.close}
555 >
556 Cancel
557 </button>
558 <button
559 className={classNames(
560 "rounded px-2 py-1 text-gray-50",
561 !groupName
562 ? "bg-gray-600 cursor-not-allowed"
563 : "bg-green-600 cursor-pointer",
564 )}
565 onClick={async () => {
566 if (!profile?.org_id || !groupName) return;
567 const { data, error } = await supabase
568 .from("approval_answer_groups")
569 .insert({
570 org_id: profile.org_id,
571 name: groupName,
572 })
573 .select()
574 .single();
575 if (error) {
576 setError(`Failed to save group: ${error.message}`);
577 console.error(`Failed to save group: ${error.message}`);

Callers

nothing calls this directly

Calls 2

useProfileFunction · 0.90
classNamesFunction · 0.90

Tested by

no test coverage detected