Add form for adding new domains (#30)

* Add layout to implement addition of new domains

* Refactor code

* Add page to setup domain name

* Update layout of add domain page

* Use react-hook-form in add domain page

* Remove unnecessary code

* Handle review change

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
Nabarun Gogoi 2023-12-27 18:26:20 +05:30 committed by GitHub
parent 9b224f218a
commit 94c4da0175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 18 deletions

View File

@ -12,7 +12,7 @@ const Domains = () => {
<> <>
<div className="flex justify-between p-2"> <div className="flex justify-between p-2">
<Typography variant="h2">Domain</Typography> <Typography variant="h2">Domain</Typography>
<Link to={`domain/add`}> <Link to="domain/add">
<Button color="blue" variant="outlined" className="rounded-full"> <Button color="blue" variant="outlined" className="rounded-full">
<i>^</i> Add domain <i>^</i> Add domain
</Button> </Button>

View File

@ -1,32 +1,90 @@
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Typography, Button, Input } from '@material-tailwind/react'; import { useForm } from 'react-hook-form';
import {
Radio,
Typography,
Button,
Input,
Alert,
} from '@material-tailwind/react';
const SetupDomain = () => { const SetupDomain = () => {
const {
register,
handleSubmit,
formState: { isValid },
watch,
} = useForm({
defaultValues: {
domainName: '',
isWWW: 'false',
},
});
return ( return (
<div className="flex flex-col gap-2"> <form
onSubmit={handleSubmit(() => {})}
className="flex flex-col gap-6 w-full"
>
<div> <div>
<Typography variant="h3">Setup domain name</Typography> <Typography variant="h5">Setup domain name</Typography>
<Typography variant="small"> <Typography variant="small">
Add your domain and setup redirects Add your domain and setup redirects
</Typography> </Typography>
</div> </div>
<div>
<Typography variant="lead">Domain name</Typography> <div className="w-auto">
<Typography variant="small">Domain name</Typography>
<Input <Input
type="text" type="text"
variant="outlined" variant="outlined"
size="lg" size="lg"
className="border-2 rounded w-full" crossOrigin={undefined}
crossOrigin={''} className="w-full"
{...register('domainName', {
required: true,
})}
/> />
</div> </div>
<Button className="w-fit" color="blue">
<Link to={`config`}> {isValid && (
<div>
<Typography>Primary domain</Typography>
<div className="flex flex-col gap-3">
<Radio
label={watch('domainName')}
crossOrigin={undefined}
{...register('isWWW')}
value="false"
type="radio"
/>
<Radio
label={`www.${watch('domainName')}`}
crossOrigin={undefined}
{...register('isWWW')}
value="true"
type="radio"
/>
</div>
<Alert color="blue">
<i>^</i> For simplicity, well redirect the www variant to{' '}
{watch('domainName')}. Redirect preferences can be changed later.
</Alert>
</div>
)}
<Button
disabled={!isValid}
className="w-fit"
color={isValid ? 'blue' : 'gray'}
type="submit"
>
<Link to="config">
<i>^</i> Next <i>^</i> Next
</Link> </Link>
</Button> </Button>
</div> </form>
); );
}; };

View File

@ -53,13 +53,9 @@ const AddDomain = () => {
</div> </div>
</div> </div>
<div className="flex justify-between"> <div className="flex justify-start gap-3">
<div> <Stepper activeStep={activeStep} stepperValues={stepperValues} />
<Stepper activeStep={activeStep} stepperValues={stepperValues} /> <SetupDomain />
</div>
<div>
<SetupDomain />
</div>
</div> </div>
</div> </div>
</div> </div>