|
1 |
| -import { Button, Group } from '@mantine/core' |
| 1 | +import { Anchor, Button, Group, Text, TextInput } from '@mantine/core' |
| 2 | +import { useForm } from '@mantine/form' |
2 | 3 | import { UserCreateBotInput } from '@pubkey-link/sdk'
|
3 |
| -import { formFieldText, UiForm, UiFormField } from '@pubkey-ui/core' |
| 4 | +import { UiInfo, UiStack } from '@pubkey-ui/core' |
4 | 5 |
|
5 | 6 | export function UserBotUiCreateForm({ submit }: { submit: (res: UserCreateBotInput) => Promise<boolean> }) {
|
6 |
| - const model: UserCreateBotInput = { |
7 |
| - token: '', |
8 |
| - clientId: '', |
9 |
| - clientSecret: '', |
10 |
| - communityId: '', |
11 |
| - } |
| 7 | + const form = useForm<UserCreateBotInput>({ |
| 8 | + initialValues: { |
| 9 | + clientId: '', |
| 10 | + clientSecret: '', |
| 11 | + communityId: '', |
| 12 | + token: '', |
| 13 | + }, |
| 14 | + }) |
12 | 15 |
|
13 |
| - const fields: UiFormField<UserCreateBotInput>[] = [ |
14 |
| - formFieldText('token', { label: 'Token', required: true }), |
15 |
| - formFieldText('clientId', { label: 'Client ID', required: true }), |
16 |
| - formFieldText('clientSecret', { label: 'Client Secret', required: true }), |
17 |
| - ] |
18 | 16 | return (
|
19 |
| - <UiForm model={model} fields={fields} submit={(res) => submit(res as UserCreateBotInput)}> |
20 |
| - <Group justify="right"> |
21 |
| - <Button type="submit">Create</Button> |
22 |
| - </Group> |
23 |
| - </UiForm> |
| 17 | + <form onSubmit={form.onSubmit((values) => submit(values))}> |
| 18 | + <UiStack> |
| 19 | + <Text span size="lg"> |
| 20 | + Create an app in the{' '} |
| 21 | + <Anchor href="https://discord.com/developers/applications">Discord Developer Portal</Anchor> or use an |
| 22 | + existing one. |
| 23 | + </Text> |
| 24 | + |
| 25 | + <TextInput |
| 26 | + label="Discord Client ID" |
| 27 | + description="Copy the CLIENT ID value from the OAuth2 section of your app." |
| 28 | + placeholder="123456789987654321" |
| 29 | + {...form.getInputProps('clientId')} |
| 30 | + /> |
| 31 | + <TextInput |
| 32 | + label="Discord Client Secret" |
| 33 | + description="Copy the CLIENT SECRET value from OAuth2 section of your app." |
| 34 | + placeholder="ABCDEFGHIJKL-MNOPQRSTUVWXYZ" |
| 35 | + {...form.getInputProps('clientSecret')} |
| 36 | + /> |
| 37 | + <TextInput |
| 38 | + label="Discord Bot Token" |
| 39 | + description="Copy the TOKEN value from the Bot section of your app." |
| 40 | + placeholder="ABCDEFGHIJKLMNOPQRSTUVWXYZ.12345.ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 41 | + {...form.getInputProps('token')} |
| 42 | + /> |
| 43 | + |
| 44 | + <UiInfo message="Make sure to enable the 'SERVER MEMBERS INTENT' option in the bot settings." /> |
| 45 | + |
| 46 | + <Group justify="right"> |
| 47 | + <Button type="submit">Create</Button> |
| 48 | + </Group> |
| 49 | + </UiStack> |
| 50 | + </form> |
24 | 51 | )
|
25 | 52 | }
|
0 commit comments