Remove redirect domain creation while adding custom domain
This commit is contained in:
parent
c202554002
commit
4ae4670dca
@ -1243,7 +1243,7 @@ export class Service {
|
||||
data: { name: string },
|
||||
): Promise<{
|
||||
primaryDomain: Domain;
|
||||
redirectedDomain: Domain;
|
||||
// redirectedDomain: Domain;
|
||||
}> {
|
||||
const currentProject = await this.db.getProjectById(projectId);
|
||||
|
||||
@ -1259,22 +1259,22 @@ export class Service {
|
||||
|
||||
const savedPrimaryDomain = await this.db.addDomain(primaryDomainDetails);
|
||||
|
||||
const domainArr = data.name.split('www.');
|
||||
// const domainArr = data.name.split('www.');
|
||||
|
||||
const redirectedDomainDetails = {
|
||||
name: domainArr.length > 1 ? domainArr[1] : `www.${domainArr[0]}`,
|
||||
branch: currentProject.prodBranch,
|
||||
project: currentProject,
|
||||
redirectTo: savedPrimaryDomain,
|
||||
};
|
||||
// const redirectedDomainDetails = {
|
||||
// name: domainArr.length > 1 ? domainArr[1] : `www.${domainArr[0]}`,
|
||||
// branch: currentProject.prodBranch,
|
||||
// project: currentProject,
|
||||
// redirectTo: savedPrimaryDomain,
|
||||
// };
|
||||
|
||||
const savedRedirectedDomain = await this.db.addDomain(
|
||||
redirectedDomainDetails,
|
||||
);
|
||||
// const savedRedirectedDomain = await this.db.addDomain(
|
||||
// redirectedDomainDetails,
|
||||
// );
|
||||
|
||||
return {
|
||||
primaryDomain: savedPrimaryDomain,
|
||||
redirectedDomain: savedRedirectedDomain,
|
||||
// redirectedDomain: savedRedirectedDomain,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
// import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { Heading } from 'components/shared/Heading';
|
||||
import { InlineNotification } from 'components/shared/InlineNotification';
|
||||
// import { InlineNotification } from 'components/shared/InlineNotification';
|
||||
import { Input } from 'components/shared/Input';
|
||||
import { Button } from 'components/shared/Button';
|
||||
import { Radio } from 'components/shared/Radio';
|
||||
// import { Radio } from 'components/shared/Radio';
|
||||
|
||||
interface SetupDomainFormValues {
|
||||
domainName: string;
|
||||
@ -18,47 +18,45 @@ const SetupDomain = () => {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isValid },
|
||||
watch,
|
||||
setValue,
|
||||
// watch,
|
||||
// setValue,
|
||||
} = useForm<SetupDomainFormValues>({
|
||||
defaultValues: {
|
||||
domainName: '',
|
||||
isWWW: 'false',
|
||||
// isWWW: 'false',
|
||||
},
|
||||
mode: 'onChange',
|
||||
});
|
||||
|
||||
const [domainStr, setDomainStr] = useState<string>('');
|
||||
// const [domainStr, setDomainStr] = useState<string>('');
|
||||
const navigate = useNavigate();
|
||||
const isWWWRadioOptions = [
|
||||
{ label: domainStr, value: 'false' },
|
||||
{ label: `www.${domainStr}`, value: 'true' },
|
||||
];
|
||||
// const isWWWRadioOptions = [
|
||||
// { label: domainStr, value: 'false' },
|
||||
// { label: `www.${domainStr}`, value: 'true' },
|
||||
// ];
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = watch((value, { name }) => {
|
||||
if (name === 'domainName' && value.domainName) {
|
||||
const domainArr = value.domainName.split('www.');
|
||||
const cleanedDomain =
|
||||
domainArr.length > 1 ? domainArr[1] : domainArr[0];
|
||||
setDomainStr(cleanedDomain);
|
||||
// useEffect(() => {
|
||||
// const subscription = watch((value, { name }) => {
|
||||
// if (name === 'domainName' && value.domainName) {
|
||||
// const domainArr = value.domainName.split('www.');
|
||||
// const cleanedDomain =
|
||||
// domainArr.length > 1 ? domainArr[1] : domainArr[0];
|
||||
// setDomainStr(cleanedDomain);
|
||||
|
||||
setValue(
|
||||
'isWWW',
|
||||
value.domainName.startsWith('www.') ? 'true' : 'false',
|
||||
);
|
||||
}
|
||||
});
|
||||
// setValue(
|
||||
// 'isWWW',
|
||||
// value.domainName.startsWith('www.') ? 'true' : 'false',
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
|
||||
return () => subscription.unsubscribe();
|
||||
}, [watch, setValue]);
|
||||
// return () => subscription.unsubscribe();
|
||||
// }, [watch, setValue]);
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSubmit(() => {
|
||||
watch('isWWW') === 'true'
|
||||
? navigate(`config?name=www.${domainStr}`)
|
||||
: navigate(`config?name=${domainStr}`);
|
||||
onSubmit={handleSubmit((e) => {
|
||||
navigate(`config?name=${e.domainName}`)
|
||||
})}
|
||||
className="flex flex-col gap-6 w-full"
|
||||
>
|
||||
@ -80,7 +78,7 @@ const SetupDomain = () => {
|
||||
label="Domain name"
|
||||
/>
|
||||
|
||||
{isValid && (
|
||||
{/* {isValid && (
|
||||
<div className="self-stretch flex flex-col gap-4">
|
||||
<Heading className="text-sky-950 text-lg font-medium leading-normal">
|
||||
Primary domain
|
||||
@ -99,7 +97,7 @@ const SetupDomain = () => {
|
||||
}. Redirect preferences can be changed later`}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
)} */}
|
||||
|
||||
<div className="self-stretch">
|
||||
<Button disabled={!isValid} type="submit" shape="default">
|
||||
|
@ -61,15 +61,19 @@ const Domains = () => {
|
||||
<ProjectSettingContainer
|
||||
headingText="Domains"
|
||||
button={
|
||||
<Button
|
||||
as="a"
|
||||
href="add"
|
||||
variant="secondary"
|
||||
leftIcon={<PlusIcon />}
|
||||
size="md"
|
||||
>
|
||||
Add domain
|
||||
</Button>
|
||||
<>
|
||||
{domains.length == 0 && (
|
||||
<Button
|
||||
as="a"
|
||||
href="add"
|
||||
variant="secondary"
|
||||
leftIcon={<PlusIcon />}
|
||||
size="md"
|
||||
>
|
||||
Add domain
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
{domains.map((domain) => {
|
||||
|
Loading…
Reference in New Issue
Block a user