forked from cerc-io/snowballtools-base
* Add fixture data and populate database with it * Use node to run commands in package scripts * Move test directory out of src directory * Save projects with user and organization relation * Refactor and add generalized function to load data * Populate userOrganization entity with test data * Change project id type from number to string --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import { useParams, Link, useOutletContext } from 'react-router-dom';
|
|
|
|
import { Button, Typography } from '@material-tailwind/react';
|
|
|
|
import DomainCard from './DomainCard';
|
|
import {
|
|
DomainDetails,
|
|
ProjectsOutletContext,
|
|
} from '../../../../types/project';
|
|
|
|
const Domains = () => {
|
|
const { id } = useParams();
|
|
|
|
const { projects } = useOutletContext<ProjectsOutletContext>();
|
|
|
|
const currProject = useMemo(() => {
|
|
return projects.find((project) => {
|
|
return project.id === id;
|
|
});
|
|
}, [id, projects]);
|
|
|
|
const linkedRepo = useMemo(() => {
|
|
return currProject?.repositories.find(
|
|
(repo: any) => repo.id === Number(currProject?.repositoryId),
|
|
);
|
|
}, [currProject]);
|
|
|
|
const domains = currProject?.deployments
|
|
.filter((deployment) => {
|
|
return deployment.domain != null;
|
|
})
|
|
.map((deployment) => deployment.domain);
|
|
|
|
return (
|
|
<>
|
|
<div className="flex justify-between p-2">
|
|
<Typography variant="h3">Domain</Typography>
|
|
<Link to="domain/add">
|
|
<Button color="blue" variant="outlined" className="rounded-full">
|
|
<i>^</i> Add domain
|
|
</Button>
|
|
</Link>
|
|
</div>
|
|
|
|
{(domains as DomainDetails[]).map((domain) => {
|
|
return (
|
|
<DomainCard
|
|
domain={domain}
|
|
key={domain.id}
|
|
repo={linkedRepo!}
|
|
project={currProject!}
|
|
/>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Domains;
|