Show service provider IP address while creating custom domain

This commit is contained in:
Shreerang Kale 2025-01-30 16:10:03 +05:30 committed by IshaVenikar
parent 56eccb48b3
commit 5d9c965f54
3 changed files with 54 additions and 14 deletions

View File

@ -250,11 +250,11 @@ type Auction {
} }
type DNSRecordAttributes { type DNSRecordAttributes {
name: string; name: String
value: string; value: String
request: string; request: String
resourceType: string; resourceType: String
version: string; version: String
} }
input AuctionParams { input AuctionParams {

View File

@ -1,4 +1,4 @@
import { useState } from 'react'; import { useEffect, useState } from 'react';
import { Domain, DomainStatus, Project } from 'gql-client'; import { Domain, DomainStatus, Project } from 'gql-client';
import { import {
@ -23,6 +23,7 @@ import {
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { Heading } from 'components/shared/Heading'; import { Heading } from 'components/shared/Heading';
import { Button } from 'components/shared/Button'; import { Button } from 'components/shared/Button';
import { useParams } from 'react-router-dom';
enum RefreshStatus { enum RefreshStatus {
IDLE, IDLE,
@ -56,9 +57,11 @@ const DomainCard = ({
onUpdate, onUpdate,
}: DomainCardProps) => { }: DomainCardProps) => {
const { toast, dismiss } = useToast(); const { toast, dismiss } = useToast();
const { id } = useParams();
const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE); const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [editDialogOpen, setEditDialogOpen] = useState(false); const [editDialogOpen, setEditDialogOpen] = useState(false);
const [IPAddress, setIPAddress] = useState<string>();
const client = useGQLClient(); const client = useGQLClient();
@ -83,6 +86,26 @@ const DomainCard = ({
} }
}; };
useEffect(() => {
const fetchDNSData = async () => {
if (id === undefined) {
toast({
id: 'domain_cannot_find_project',
title: 'Cannot find project',
variant: 'error',
onDismiss: dismiss,
});
return;
}
const dnsData = await client.getLatestDNSDataByProjectId(id);
setIPAddress(dnsData.value);
};
fetchDNSData();
}, [id, client]);
return ( return (
<> <>
<div className="flex justify-between py-3"> <div className="flex justify-between py-3">
@ -192,7 +215,7 @@ const DomainCard = ({
<tr> <tr>
<td>{DOMAIN_RECORD.type}</td> <td>{DOMAIN_RECORD.type}</td>
<td>{DOMAIN_RECORD.name}</td> <td>{DOMAIN_RECORD.name}</td>
<td>{DOMAIN_RECORD.value}</td> <td>{IPAddress}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -7,6 +7,7 @@ import { InlineNotification } from 'components/shared/InlineNotification';
import { ArrowRightCircleIcon } from 'components/shared/CustomIcon'; import { ArrowRightCircleIcon } from 'components/shared/CustomIcon';
import { ProjectSettingContainer } from 'components/projects/project/settings/ProjectSettingContainer'; import { ProjectSettingContainer } from 'components/projects/project/settings/ProjectSettingContainer';
import { useToast } from 'components/shared/Toast'; import { useToast } from 'components/shared/Toast';
import { useEffect, useState } from 'react';
const Config = () => { const Config = () => {
const { id, orgSlug } = useParams(); const { id, orgSlug } = useParams();
@ -16,6 +17,8 @@ const Config = () => {
const primaryDomainName = searchParams.get('name'); const primaryDomainName = searchParams.get('name');
const { toast, dismiss } = useToast(); const { toast, dismiss } = useToast();
const [IPAddress, setIPAddress] = useState<string>();
const handleSubmitDomain = async () => { const handleSubmitDomain = async () => {
if (primaryDomainName === null) { if (primaryDomainName === null) {
toast({ toast({
@ -59,6 +62,26 @@ const Config = () => {
} }
}; };
useEffect(() => {
const fetchDNSData = async () => {
if (id === undefined) {
toast({
id: 'domain_cannot_find_project',
title: 'Cannot find project',
variant: 'error',
onDismiss: dismiss,
});
return;
}
const dnsData = await client.getLatestDNSDataByProjectId(id);
setIPAddress(dnsData.value);
};
fetchDNSData();
}, [id, client]);
// TODO: Figure out DNS Provider if possible and update appropriatly // TODO: Figure out DNS Provider if possible and update appropriatly
return ( return (
<ProjectSettingContainer headingText="Setup domain name"> <ProjectSettingContainer headingText="Setup domain name">
@ -79,13 +102,7 @@ const Config = () => {
<Table.Row> <Table.Row>
<Table.RowHeaderCell>A</Table.RowHeaderCell> <Table.RowHeaderCell>A</Table.RowHeaderCell>
<Table.Cell>@</Table.Cell> <Table.Cell>@</Table.Cell>
<Table.Cell>IP.OF.THE.SP</Table.Cell> <Table.Cell>{IPAddress}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.RowHeaderCell>CNAME</Table.RowHeaderCell>
<Table.Cell>subdomain</Table.Cell>
<Table.Cell>domain.of.the.sp</Table.Cell>
</Table.Row> </Table.Row>
</Table.Body> </Table.Body>
</Table> </Table>