parent
753593cd08
commit
cf94cbce10
@ -1,48 +0,0 @@
|
||||
import { Button, Dialog } from '@tih/ui';
|
||||
|
||||
export type CreateListDialogProps = {
|
||||
onCancel: () => void;
|
||||
onCreate: () => void;
|
||||
show: boolean;
|
||||
};
|
||||
|
||||
export default function CreateListDialog({
|
||||
show,
|
||||
onCancel,
|
||||
onCreate,
|
||||
}: CreateListDialogProps) {
|
||||
return (
|
||||
<Dialog
|
||||
isShown={show}
|
||||
primaryButton={undefined}
|
||||
title="Create a new question list"
|
||||
onClose={onCancel}>
|
||||
<form className="mt-5 gap-2 sm:flex sm:items-center">
|
||||
<div className="w-full sm:max-w-xs">
|
||||
<input
|
||||
className="focus:border-primary-500 focus:ring-primary-500 block w-full rounded-md border-slate-300 shadow-sm sm:text-sm"
|
||||
id="listName"
|
||||
name="listName"
|
||||
placeholder="Enter list name"
|
||||
type="text"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
display="inline"
|
||||
label="Cancel"
|
||||
size="md"
|
||||
type="submit"
|
||||
variant="tertiary"
|
||||
onClick={onCancel}></Button>
|
||||
|
||||
<Button
|
||||
display="inline"
|
||||
label="Create"
|
||||
size="md"
|
||||
type="submit"
|
||||
variant="primary"
|
||||
onClick={onCreate}></Button>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Button, Dialog, TextInput } from '@tih/ui';
|
||||
|
||||
import { useFormRegister } from '~/utils/questions/useFormRegister';
|
||||
|
||||
export type CreateListFormData = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type CreateListDialogProps = {
|
||||
onCancel: () => void;
|
||||
onSubmit: (data: CreateListFormData) => Promise<void>;
|
||||
show: boolean;
|
||||
};
|
||||
|
||||
export default function CreateListDialog({
|
||||
show,
|
||||
onCancel,
|
||||
onSubmit,
|
||||
}: CreateListDialogProps) {
|
||||
const {
|
||||
register: formRegister,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting },
|
||||
} = useForm<CreateListFormData>();
|
||||
const register = useFormRegister(formRegister);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
isShown={show}
|
||||
primaryButton={undefined}
|
||||
title="Create question list"
|
||||
onClose={onCancel}>
|
||||
<form
|
||||
className="mt-5 gap-2 sm:flex sm:items-center"
|
||||
onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="w-full sm:max-w-xs">
|
||||
<TextInput
|
||||
id="listName"
|
||||
isLabelHidden={true}
|
||||
{...register('name')}
|
||||
autoComplete="off"
|
||||
label="Name"
|
||||
placeholder="List name"
|
||||
type="text"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
display="inline"
|
||||
label="Cancel"
|
||||
size="md"
|
||||
type="submit"
|
||||
variant="tertiary"
|
||||
onClick={onCancel}
|
||||
/>
|
||||
<Button
|
||||
display="inline"
|
||||
isLoading={isSubmitting}
|
||||
label="Create"
|
||||
size="md"
|
||||
type="submit"
|
||||
variant="primary"
|
||||
/>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue