Fix groupQuit
This commit is contained in:
parent
ae69c4ed08
commit
db4a619b17
1 changed files with 4 additions and 8 deletions
|
@ -10,7 +10,7 @@ import Button from '@/ui/Button';
|
||||||
import Select from '@/ui/Select';
|
import Select from '@/ui/Select';
|
||||||
|
|
||||||
type SettingsData = {
|
type SettingsData = {
|
||||||
group: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
|
@ -18,7 +18,7 @@ export default function Page() {
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { register, handleSubmit } = useForm<SettingsData>({
|
const { register, handleSubmit } = useForm<SettingsData>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
group: ''
|
name: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -29,13 +29,9 @@ export default function Page() {
|
||||||
})) || [];
|
})) || [];
|
||||||
|
|
||||||
async function onSubmit(data: SettingsData) {
|
async function onSubmit(data: SettingsData) {
|
||||||
const formData = new FormData();
|
|
||||||
|
|
||||||
formData.append('group', data.group);
|
|
||||||
|
|
||||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/groupQuit`, {
|
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/groupQuit`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${cookies.get('token')}}`
|
Authorization: `Bearer ${cookies.get('token')}}`
|
||||||
}
|
}
|
||||||
|
@ -49,7 +45,7 @@ export default function Page() {
|
||||||
return (
|
return (
|
||||||
<section className="flex h-full w-full flex-col space-y-4">
|
<section className="flex h-full w-full flex-col space-y-4">
|
||||||
<form className="flex items-center space-x-2" onSubmit={handleSubmit(onSubmit)}>
|
<form className="flex items-center space-x-2" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<Select {...register('group')} className="w-1/4" options={groups} />
|
<Select {...register('name')} className="w-1/4" options={groups} />
|
||||||
<Button kind="brand" type="submit">
|
<Button kind="brand" type="submit">
|
||||||
Quitter
|
Quitter
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue