diff --git a/packages/frontend/src/assets/domains.json b/packages/frontend/src/assets/domains.json
index 1cff7a29..8017e914 100644
--- a/packages/frontend/src/assets/domains.json
+++ b/packages/frontend/src/assets/domains.json
@@ -1,8 +1,31 @@
[
{
- "domainid": 1,
+ "id": 1,
"projectid": 1,
- "domain": "randomurl.snowballtools.xyz",
- "status": "live"
+ "name": "randomurl.snowballtools.xyz",
+ "status": "live",
+ "record": null
+ },
+ {
+ "id": 2,
+ "projectid": 1,
+ "name": "saugatt.com",
+ "status": "pending",
+ "record": {
+ "type": "A",
+ "name": "@",
+ "value": "56.49.19.21"
+ }
+ },
+ {
+ "id": 3,
+ "projectid": 1,
+ "name": "www.saugatt.com",
+ "status": "pending",
+ "record": {
+ "type": "CNAME",
+ "name": "www",
+ "value": "cname.snowballtools.xyz"
+ }
}
]
diff --git a/packages/frontend/src/components/projects/project/settings/DomainCard.tsx b/packages/frontend/src/components/projects/project/settings/DomainCard.tsx
index 6f3d9374..1621475b 100644
--- a/packages/frontend/src/components/projects/project/settings/DomainCard.tsx
+++ b/packages/frontend/src/components/projects/project/settings/DomainCard.tsx
@@ -1,4 +1,5 @@
-import React from 'react';
+import React, { useState } from 'react';
+
import {
Chip,
Typography,
@@ -6,28 +7,55 @@ import {
MenuHandler,
MenuList,
MenuItem,
+ Card,
} from '@material-tailwind/react';
-const DomainCard = (props: { domain: string; status: string }) => {
+import { DomainDetails, DomainStatus } from '../../../../types/project';
+
+enum RefreshStatus {
+ IDLE,
+ CHECKING,
+ CHECK_SUCCESS,
+ CHECK_FAIL,
+}
+
+interface DomainCardProps {
+ domain: DomainDetails;
+}
+
+const CHECK_FAIL_TIMEOUT = 5000; // In milliseconds
+
+const DomainCard = ({ domain }: DomainCardProps) => {
+ const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
+
return (
<>
- ^ {props.domain}
+ ^ {domain.name}
^}
/>
-
- ^
+ {
+ SetRefreshStatus(RefreshStatus.CHECKING);
+ setTimeout(() => {
+ SetRefreshStatus(RefreshStatus.CHECK_FAIL);
+ }, CHECK_FAIL_TIMEOUT);
+ }}
+ >
+ {refreshStatus === RefreshStatus.CHECKING ? 'L' : 'R'}
Production
+ {domain.status === DomainStatus.PENDING && (
+
+ {refreshStatus === RefreshStatus.IDLE ? (
+
+ ^ Add these records to your domain and refresh to check
+
+ ) : refreshStatus === RefreshStatus.CHECKING ? (
+
+ ^ Checking records for {domain.name}
+
+ ) : (
+
+
^
+
+ Failed to verify records. DNS propagation can take up to 48
+ hours. Please ensure you added the correct records and refresh.
+
+
+ )}
+
+
+
+
+ Type |
+ Name |
+ Value |
+
+
+
+
+ {domain.record.type} |
+ {domain.record.name} |
+ {domain.record.value} |
+
+
+
+
+ )}
>
);
};
diff --git a/packages/frontend/src/components/projects/project/settings/Domains.tsx b/packages/frontend/src/components/projects/project/settings/Domains.tsx
index e2709d61..d706a095 100644
--- a/packages/frontend/src/components/projects/project/settings/Domains.tsx
+++ b/packages/frontend/src/components/projects/project/settings/Domains.tsx
@@ -4,6 +4,7 @@ import { Button, Typography } from '@material-tailwind/react';
import DomainCard from './DomainCard';
import domainsData from '../../../../assets/domains.json';
+import { DomainDetails } from '../../../../types/project';
const Domains = () => {
const { id } = useParams();
@@ -11,7 +12,7 @@ const Domains = () => {
return (
<>
- Domain
+ Domain
- {domainsData
+ {(domainsData as DomainDetails[])
.filter((domain) => {
return Number(id) == domain.projectid;
})
.map((domain) => {
- return (
-
- );
+ return ;
})}
>
);
diff --git a/packages/frontend/src/types/project.ts b/packages/frontend/src/types/project.ts
index 7fe677f9..a73db6d6 100644
--- a/packages/frontend/src/types/project.ts
+++ b/packages/frontend/src/types/project.ts
@@ -61,3 +61,20 @@ export enum GitSelect {
GITEA = 'gitea',
NONE = 'none',
}
+
+export enum DomainStatus {
+ LIVE = 'live',
+ PENDING = 'pending',
+}
+
+export interface DomainDetails {
+ id: number;
+ projectid: number;
+ name: string;
+ status: DomainStatus;
+ record: {
+ type: string;
+ name: string;
+ value: string;
+ };
+}