Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: tree details page #96

Merged
merged 8 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-intl": "^6.6.8",
"react-router-dom": "^6.24.1",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"vaul": "^0.9.1",
Expand Down
34 changes: 34 additions & 0 deletions dashboard/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions dashboard/src/App.css

This file was deleted.

18 changes: 0 additions & 18 deletions dashboard/src/App.tsx

This file was deleted.

17 changes: 17 additions & 0 deletions dashboard/src/api/TreeDetails.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useQuery, UseQueryResult } from '@tanstack/react-query';

import { TreeDetails } from '@/types/tree/TreeDetails';

import http from './api';

const fetchTreeDetailData = async (treeId: string): Promise<TreeDetails> => {
const res = await http.get(`/api/tree/${treeId}`);
return res.data;
};

export const useTreeDetails = (treeId: string): UseQueryResult<TreeDetails> => {
return useQuery({
queryKey: ['treeData', treeId],
queryFn: () => fetchTreeDetailData(treeId),
});
};
8 changes: 4 additions & 4 deletions dashboard/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CollapsibleTrigger,
} from '../ui/collapsible';
import ColoredCircle from '../ColoredCircle/ColoredCircle';
import { ComponentType } from '../ListingComponentItem/ListingComponentItem';
import { ItemType } from '../ListingItem/ListingItem';

export interface IAccordion {
headers: string[];
Expand Down Expand Up @@ -97,7 +97,7 @@ const AccordionBuildsTrigger = ({ trigger }: IAccordionItems): JSX.Element => {
<ColoredCircle
className="max-w-6"
quantity={triggerInfo.buildErrors ?? 0}
type={ComponentType.Error}
type={ItemType.Error}
/>
</TableCell>
<TableCell>{triggerInfo.buildTime}</TableCell>
Expand All @@ -120,11 +120,11 @@ const AccordionTestsTrigger = ({ trigger }: IAccordionItems): JSX.Element => {
<TableCell className="flex flex-row gap-1">
<ColoredCircle
quantity={triggerInfo.testErrors ?? 0}
type={ComponentType.Error}
type={ItemType.Error}
/>
<ColoredCircle
quantity={triggerInfo.testSuccessfull ?? 0}
type={ComponentType.Warning}
type={ItemType.Warning}
/>
</TableCell>
<TableCell>
Expand Down
28 changes: 28 additions & 0 deletions dashboard/src/components/Button/ButtonWithIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ReactElement } from 'react';
import classNames from 'classnames';

import { Button } from '../ui/button';

interface IButtonWithIcon {
icon?: ReactElement;
label?: ReactElement;
className?: string;
}

const buttonsClassName =
'bg-lightGray border border-black text-black rounded-full items-center gap-2 hover:bg-darkGray px-6';

const ButtonWithIcon = ({
icon,
label,
className,
}: IButtonWithIcon): JSX.Element => {
return (
<Button className={classNames(buttonsClassName, className)}>
{label}
{icon}
</Button>
);
};

export default ButtonWithIcon;
4 changes: 2 additions & 2 deletions dashboard/src/components/Cards/BaseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { ReactElement } from 'react';
import classNames from 'classnames';

interface IBaseCard {
title: string;
title: ReactElement;
content: ReactElement;
className?: string;
}

const containerClassName =
'flex flex-col rounded-xl bg-white w-1/2 h-fit border border-darkGray text-black';
'flex flex-col rounded-xl bg-white w-full h-fit border border-darkGray text-black';

const BaseCard = ({ title, content, className }: IBaseCard): JSX.Element => {
return (
Expand Down

This file was deleted.

This file was deleted.

46 changes: 46 additions & 0 deletions dashboard/src/components/CardsGroup/CardsGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { useMemo } from 'react';

import Summary, { ISummary } from '../Summary/Summary';
import BaseCard from '../Cards/BaseCard';
import ListingContent, {
IListingContent,
} from '../ListingContent/ListingContent';

interface ICardsGroup {
cards: (IListingContent | ISummary)[];
}

interface ICardContent {
card: IListingContent | ISummary;
}

const CardsGroup = ({ cards }: ICardsGroup): JSX.Element => {
const cardsList = useMemo(() => {
return cards.map(card => (
<BaseCard
key={card.title.key}
title={card.title}
content={<CardContent card={card} />}
/>
));
}, [cards]);
return <div className="grid grid-cols-2 gap-8">{cardsList}</div>;
};

const CardContent = ({ card }: ICardContent): JSX.Element => {
if (card.type === 'listing' && card.items) {
return <ListingContent key={card.title.key} items={card.items} />;
} else if (card.type === 'summary' && card.summaryBody) {
return (
<Summary
key=""
summaryHeaders={card?.summaryHeaders}
summaryBody={card?.summaryBody}
/>
);
} else {
return <></>;
}
};

export default CardsGroup;
Loading
Loading