Skip to content

Commit

Permalink
Register form component correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
teeohhem committed Feb 12, 2025
1 parent e52a824 commit 034db5c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions packages/app/src/TeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ function TeamMembersSection() {
type WebhookForm = {
name: string;
url: string;
service: string;
description?: string;
};

Expand All @@ -663,16 +664,17 @@ function CreateWebhookForm({
onSuccess: VoidFunction;
}) {
const saveWebhook = api.useSaveWebhook();
const [service, setService] = useState<string>('slack');

const form = useForm<WebhookForm>({
defaultValues: {},
defaultValues: {
service: 'slack',
},
});

const onSubmit: SubmitHandler<WebhookForm> = async values => {
try {
await saveWebhook.mutateAsync({
service,
service: values.service,
name: values.name,
url: values.url,
description: values.description || '',
Expand Down Expand Up @@ -701,14 +703,22 @@ function CreateWebhookForm({
<Stack mt="sm">
<Text>Create Webhook</Text>
<Radio.Group
name="service"
label="Service Type"
value={service}
onChange={setService}
required
value={form.watch('service')}
onChange={value => form.setValue('service', value)}
>
<Group mt="xs">
<Radio value="slack" label="Slack" />
<Radio value="generic" label="Generic" />
<Radio
value="slack"
label="Slack"
{...form.register('service', { required: true })}
/>
<Radio
value="generic"
label="Generic"
{...form.register('service', { required: true })}
/>
</Group>
</Radio.Group>
<TextInput
Expand Down

0 comments on commit 034db5c

Please sign in to comment.