({
onSubmit,
organizationId,
})
| 131 | } |
| 132 | |
| 133 | const AddUsersDialog: FC<AddUsersDialogProps> = ({ |
| 134 | onSubmit, |
| 135 | organizationId, |
| 136 | }) => { |
| 137 | const [addUserDialogOpen, setAddUserDialogOpen] = useState(false); |
| 138 | const [submitting, setSubmitting] = useState(false); |
| 139 | const [filter, setFilter] = useState(""); |
| 140 | const [selected, setSelected] = useState<OrganizationMemberWithUserData[]>( |
| 141 | [], |
| 142 | ); |
| 143 | const closeDialog = () => { |
| 144 | setAddUserDialogOpen(false); |
| 145 | setFilter(""); |
| 146 | setSelected([]); |
| 147 | }; |
| 148 | |
| 149 | return ( |
| 150 | <> |
| 151 | <Button size="lg" onClick={() => setAddUserDialogOpen(true)}> |
| 152 | <UserPlusIcon /> |
| 153 | Add users |
| 154 | </Button> |
| 155 | <Dialog |
| 156 | open={addUserDialogOpen} |
| 157 | onOpenChange={(open) => { |
| 158 | if (!open) { |
| 159 | closeDialog(); |
| 160 | } |
| 161 | }} |
| 162 | > |
| 163 | <DialogContent |
| 164 | data-testid="dialog" |
| 165 | className="max-w-md gap-4 border-border-default bg-surface-primary p-8 text-content-primary" |
| 166 | > |
| 167 | <DialogTitle className="font-semibold text-content-primary"> |
| 168 | Add user(s) |
| 169 | </DialogTitle> |
| 170 | <MultiMemberSelect |
| 171 | organizationId={organizationId} |
| 172 | filter={filter} |
| 173 | setFilter={setFilter} |
| 174 | onChange={(user, checked) => { |
| 175 | if (checked) { |
| 176 | setSelected([...selected, user]); |
| 177 | } else { |
| 178 | setSelected(selected.filter((s) => s.user_id !== user.user_id)); |
| 179 | } |
| 180 | }} |
| 181 | selected={selected} |
| 182 | /> |
| 183 | <DialogFooter className="mt-4 flex-row justify-end gap-3"> |
| 184 | <Button |
| 185 | variant="outline" |
| 186 | onClick={closeDialog} |
| 187 | disabled={submitting} |
| 188 | > |
| 189 | Cancel |
| 190 | </Button> |
nothing calls this directly
no test coverage detected