[resumes][feat] disable inputs and buttons during form submission

This commit is contained in:
Keane Chan
2022-10-10 09:34:34 +08:00
parent f6bbbe6b02
commit 5d0c95e085
2 changed files with 22 additions and 7 deletions

View File

@ -88,35 +88,40 @@ export default function CommentsForm({
onSubmit={handleSubmit(onSubmit)}> onSubmit={handleSubmit(onSubmit)}>
<div className="mt-4 space-y-4"> <div className="mt-4 space-y-4">
<TextArea <TextArea
{...(register('general'), {})} {...register('general')}
disabled={reviewCreateMutation.isLoading}
label="General" label="General"
placeholder="General comments about the resume" placeholder="General comments about the resume"
onChange={(value) => onValueChange('general', value)} onChange={(value) => onValueChange('general', value)}
/> />
<TextArea <TextArea
{...(register('education'), {})} {...register('education')}
disabled={reviewCreateMutation.isLoading}
label="Education" label="Education"
placeholder="Comments about the Education section" placeholder="Comments about the Education section"
onChange={(value) => onValueChange('education', value)} onChange={(value) => onValueChange('education', value)}
/> />
<TextArea <TextArea
{...(register('experience'), {})} {...register('experience')}
disabled={reviewCreateMutation.isLoading}
label="Experience" label="Experience"
placeholder="Comments about the Experience section" placeholder="Comments about the Experience section"
onChange={(value) => onValueChange('experience', value)} onChange={(value) => onValueChange('experience', value)}
/> />
<TextArea <TextArea
{...(register('projects'), {})} {...register('projects')}
disabled={reviewCreateMutation.isLoading}
label="Projects" label="Projects"
placeholder="Comments about the Projects section" placeholder="Comments about the Projects section"
onChange={(value) => onValueChange('projects', value)} onChange={(value) => onValueChange('projects', value)}
/> />
<TextArea <TextArea
{...(register('skills'), {})} {...register('skills')}
disabled={reviewCreateMutation.isLoading}
label="Skills" label="Skills"
placeholder="Comments about the Skills section" placeholder="Comments about the Skills section"
onChange={(value) => onValueChange('skills', value)} onChange={(value) => onValueChange('skills', value)}
@ -125,6 +130,7 @@ export default function CommentsForm({
<div className="flex justify-end space-x-2 pt-4"> <div className="flex justify-end space-x-2 pt-4">
<Button <Button
disabled={reviewCreateMutation.isLoading}
label="Cancel" label="Cancel"
type="button" type="button"
variant="tertiary" variant="tertiary"
@ -132,7 +138,8 @@ export default function CommentsForm({
/> />
<Button <Button
disabled={!isDirty} disabled={!isDirty || reviewCreateMutation.isLoading}
isLoading={reviewCreateMutation.isLoading}
label="Submit" label="Submit"
type="submit" type="submit"
variant="primary" variant="primary"

View File

@ -140,7 +140,7 @@ export default function SubmitResumeForm() {
<div className="mb-4"> <div className="mb-4">
<TextInput <TextInput
{...register('title', { required: true })} {...register('title', { required: true })}
errorMessage={errors?.title && 'Title cannot be empty!'} disabled={isLoading}
label="Title" label="Title"
placeholder={TITLE_PLACEHOLDER} placeholder={TITLE_PLACEHOLDER}
required={true} required={true}
@ -150,6 +150,7 @@ export default function SubmitResumeForm() {
<div className="mb-4"> <div className="mb-4">
<Select <Select
{...register('role', { required: true })} {...register('role', { required: true })}
disabled={isLoading}
label="Role" label="Role"
options={ROLES} options={ROLES}
required={true} required={true}
@ -159,6 +160,7 @@ export default function SubmitResumeForm() {
<div className="mb-4"> <div className="mb-4">
<Select <Select
{...register('experience', { required: true })} {...register('experience', { required: true })}
disabled={isLoading}
label="Experience Level" label="Experience Level"
options={EXPERIENCE} options={EXPERIENCE}
required={true} required={true}
@ -168,6 +170,7 @@ export default function SubmitResumeForm() {
<div className="mb-4"> <div className="mb-4">
<Select <Select
{...register('location', { required: true })} {...register('location', { required: true })}
disabled={isLoading}
label="Location" label="Location"
name="location" name="location"
options={LOCATION} options={LOCATION}
@ -204,6 +207,7 @@ export default function SubmitResumeForm() {
{...register('file', { required: true })} {...register('file', { required: true })}
accept="application/pdf" accept="application/pdf"
className="sr-only" className="sr-only"
disabled={isLoading}
id="file-upload" id="file-upload"
name="file-upload" name="file-upload"
type="file" type="file"
@ -223,6 +227,7 @@ export default function SubmitResumeForm() {
<div className="mb-8"> <div className="mb-8">
<TextArea <TextArea
{...register('additionalInfo')} {...register('additionalInfo')}
disabled={isLoading}
label="Additional Information" label="Additional Information"
placeholder={ADDITIONAL_INFO_PLACEHOLDER} placeholder={ADDITIONAL_INFO_PLACEHOLDER}
onChange={(val) => setValue('additionalInfo', val)} onChange={(val) => setValue('additionalInfo', val)}
@ -259,12 +264,14 @@ export default function SubmitResumeForm() {
</div> </div>
<CheckboxInput <CheckboxInput
{...register('isChecked', { required: true })} {...register('isChecked', { required: true })}
disabled={isLoading}
label="I have read and will follow the guidelines stated." label="I have read and will follow the guidelines stated."
onChange={(val) => setValue('isChecked', val)} onChange={(val) => setValue('isChecked', val)}
/> />
<div className="mt-4 flex justify-end gap-4"> <div className="mt-4 flex justify-end gap-4">
<Button <Button
addonPosition="start" addonPosition="start"
disabled={isLoading}
display="inline" display="inline"
label="Clear" label="Clear"
size="md" size="md"
@ -273,6 +280,7 @@ export default function SubmitResumeForm() {
/> />
<Button <Button
addonPosition="start" addonPosition="start"
disabled={isLoading}
display="inline" display="inline"
isLoading={isLoading} isLoading={isLoading}
label="Submit" label="Submit"