From f9e4d8ebd5dec874f1af3df19e82ae3c8a7dfb67 Mon Sep 17 00:00:00 2001 From: prathamesh0 <42446521+prathamesh0@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:59:28 +0530 Subject: [PATCH] Use fetched domains data in domains panel (#27) * Use fetched domains data and use it in domains page * Add record field to fetched domain data --------- Co-authored-by: neeraj --- .../projects/project/settings/DomainCard.tsx | 1 + .../projects/project/settings/Domains.tsx | 18 ++++++++++----- .../frontend/src/layouts/ProjectSearch.tsx | 22 ++++++++++++++++++- packages/frontend/src/types/project.ts | 4 ++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/components/projects/project/settings/DomainCard.tsx b/packages/frontend/src/components/projects/project/settings/DomainCard.tsx index 1a68cb05..f1b8c558 100644 --- a/packages/frontend/src/components/projects/project/settings/DomainCard.tsx +++ b/packages/frontend/src/components/projects/project/settings/DomainCard.tsx @@ -155,6 +155,7 @@ const DomainCard = ({ domain, repo, project }: DomainCardProps) => { )} + { setEditDialogOpen((preVal) => !preVal); diff --git a/packages/frontend/src/components/projects/project/settings/Domains.tsx b/packages/frontend/src/components/projects/project/settings/Domains.tsx index b4b6f80e..f6e91591 100644 --- a/packages/frontend/src/components/projects/project/settings/Domains.tsx +++ b/packages/frontend/src/components/projects/project/settings/Domains.tsx @@ -5,8 +5,6 @@ import { Button, Typography } from '@material-tailwind/react'; import DomainCard from './DomainCard'; import { DomainDetails } from '../../../../types/project'; -import domainsData from '../../../../assets/domains.json'; -import repositories from '../../../../assets/repositories.json'; const Domains = () => { const { id } = useParams(); @@ -15,15 +13,23 @@ const Domains = () => { const { projects } = useOutletContext(); const currProject = useMemo(() => { - return projects.find((data: any) => Number(data.id) === Number(id)); + return projects.find((data: any) => { + return Number(data?.id) === Number(id); + }); }, [id]); const linkedRepo = useMemo(() => { - return repositories.find( - (repo) => repo.id === Number(currProject?.repositoryId), + return currProject.repositories.find( + (repo: any) => repo.id === Number(currProject?.repositoryId), ); }, [currProject]); + const domains = currProject.deployments + .filter((deployment: any) => { + return deployment.domain != null; + }) + .map((deployment: any) => deployment.domain); + return ( <>
@@ -35,7 +41,7 @@ const Domains = () => {
- {(domainsData as DomainDetails[]).map((domain) => { + {(domains as DomainDetails[]).map((domain) => { return ( { hash: '', message: '', }, + domain: deployment.domain + ? { + ...deployment.domain, + record: { + type: '', + name: '', + value: '', + }, + } + : null, }; }); @@ -44,7 +54,17 @@ const ProjectSearch = () => { domain: null, createdBy: project.owner.name, source: '', - repositoryId: project.repository, + repositoryId: 0, + repositories: [ + { + id: 0, + title: project.repository, + updatedAt: '', + user: '', + private: false, + branch: [''], + }, + ], // TODO: populate from github API latestCommit: { message: '', diff --git a/packages/frontend/src/types/project.ts b/packages/frontend/src/types/project.ts index 62358e02..30d95dfc 100644 --- a/packages/frontend/src/types/project.ts +++ b/packages/frontend/src/types/project.ts @@ -75,8 +75,8 @@ export enum GitSelect { } export enum DomainStatus { - LIVE = 'live', - PENDING = 'pending', + LIVE = 'Live', + PENDING = 'Pending', } export interface DomainDetails {