({
group,
errors,
onSubmit,
onCancel,
isLoading,
})
| 35 | } |
| 36 | |
| 37 | const UpdateGroupForm: FC<UpdateGroupFormProps> = ({ |
| 38 | group, |
| 39 | errors, |
| 40 | onSubmit, |
| 41 | onCancel, |
| 42 | isLoading, |
| 43 | }) => { |
| 44 | const form = useFormik<FormData>({ |
| 45 | initialValues: { |
| 46 | name: group.name, |
| 47 | display_name: group.display_name, |
| 48 | avatar_url: group.avatar_url, |
| 49 | quota_allowance: group.quota_allowance, |
| 50 | }, |
| 51 | validationSchema, |
| 52 | onSubmit, |
| 53 | }); |
| 54 | const getFieldHelpers = getFormHelpers<FormData>(form, errors); |
| 55 | const nameField = getFieldHelpers("name"); |
| 56 | const displayNameField = getFieldHelpers("display_name", { |
| 57 | helperText: "Keep empty to default to the name.", |
| 58 | }); |
| 59 | const quotaField = getFieldHelpers("quota_allowance", { |
| 60 | helperText: `This group gives ${form.values.quota_allowance} quota credits to each |
| 61 | of its members.`, |
| 62 | }); |
| 63 | |
| 64 | return ( |
| 65 | <form className="flex flex-col gap-10 pb-8" onSubmit={form.handleSubmit}> |
| 66 | <section className="flex flex-col gap-4 max-w-md"> |
| 67 | <div className="flex flex-col gap-2"> |
| 68 | <h2 className="text-xl font-semibold text-content-primary m-0"> |
| 69 | General |
| 70 | </h2> |
| 71 | </div> |
| 72 | <div className="flex flex-col gap-6"> |
| 73 | <div className="flex flex-col items-start gap-2"> |
| 74 | <Label htmlFor={nameField.id}>Name</Label> |
| 75 | <Input |
| 76 | id={nameField.id} |
| 77 | name={nameField.name} |
| 78 | value={nameField.value} |
| 79 | onChange={onChangeTrimmed(form)} |
| 80 | onBlur={nameField.onBlur} |
| 81 | autoComplete="name" |
| 82 | autoFocus |
| 83 | disabled={isEveryoneGroup(group)} |
| 84 | aria-invalid={nameField.error} |
| 85 | /> |
| 86 | {nameField.helperText && ( |
| 87 | <span |
| 88 | className={`text-xs text-left ${ |
| 89 | nameField.error |
| 90 | ? "text-content-destructive" |
| 91 | : "text-content-secondary" |
| 92 | }`} |
| 93 | > |
| 94 | {nameField.helperText} |
nothing calls this directly
no test coverage detected