diff --git a/packages/frontend/src/assets/activities.json b/packages/frontend/src/assets/activities.json new file mode 100644 index 00000000..4ae7d984 --- /dev/null +++ b/packages/frontend/src/assets/activities.json @@ -0,0 +1,37 @@ +[ + { + "author": "Bob", + "authorAvatar": "^", + "createdAt": "2023-12-11T04:20:00", + "branch": "main", + "message": "Design integrate and tested" + }, + { + "author": "Alice", + "authorAvatar": "^", + "createdAt": "2023-12-11T04:20:00", + "branch": "prod", + "message": "Fix lint errors" + }, + { + "author": "Charlie", + "authorAvatar": "^", + "createdAt": "2023-12-11T04:20:00", + "branch": "main", + "message": "Sidebar changed" + }, + { + "author": "Roy", + "authorAvatar": "^", + "createdAt": "2023-12-11T04:20:00", + "branch": "staging", + "message": "Add style to the page" + }, + { + "author": "Brad", + "authorAvatar": "^", + "createdAt": "2023-12-11T04:20:00", + "branch": "dev", + "message": "404 not found" + } +] diff --git a/packages/frontend/src/assets/projects.json b/packages/frontend/src/assets/projects.json index fa50a0a0..8a5c143b 100644 --- a/packages/frontend/src/assets/projects.json +++ b/packages/frontend/src/assets/projects.json @@ -4,9 +4,13 @@ "icon": "^", "title": "iglotools", "domain": "iglotools.com", + "createdAt": "2023-12-07T04:20:00", + "createdBy": "Bob", + "deployment": "iglotools.snowball.com", + "source": "feature/add-remote-control", "latestCommit": { "message": "Subscription added", - "time": "2023-12-11T04:20:00", + "createdAt": "2023-12-11T04:20:00", "branch": "main" } }, @@ -15,9 +19,13 @@ "icon": "^", "title": "snowball-starter-kit", "domain": "snowball-starter-kit.com", + "createdAt": "2023-12-04T04:20:00", + "createdBy": "Erin", + "deployment": "snowball-starter-kit.com", + "source": "prod/add-docker-compose", "latestCommit": { "message": "404 added", - "time": "2023-12-11T04:20:00", + "createdAt": "2023-12-11T04:20:00", "branch": "staging" } }, @@ -26,9 +34,13 @@ "icon": "^", "title": "passkeys-demo", "domain": "passkeys-demo.com", + "createdAt": "2023-12-01T04:20:00", + "createdBy": "Charlie", + "deployment": "passkeys-demo.com", + "source": "dev/style-page", "latestCommit": { "message": "Design system integrated", - "time": "2023-12-11T04:20:00", + "createdAt": "2023-12-01T04:20:00", "branch": "main" } }, @@ -37,9 +49,13 @@ "icon": "^", "title": "watcher-tool", "domain": "azimuth-watcher.com", + "createdAt": "2023-12-11T04:20:00", + "createdBy": "Alice", + "deployment": "azimuth-watcher.com", + "source": "prod/fix-error", "latestCommit": { "message": "Listen for subscription", - "time": "2023-12-10T04:20:00", + "createdAt": "2023-12-09T04:20:00", "branch": "prod" } } diff --git a/packages/frontend/src/components/ActivityCard.tsx b/packages/frontend/src/components/ActivityCard.tsx new file mode 100644 index 00000000..f802989c --- /dev/null +++ b/packages/frontend/src/components/ActivityCard.tsx @@ -0,0 +1,33 @@ +import React from 'react'; + +import { relativeTime } from '../utils/time'; + +interface ActivityDetails { + author: string; + authorAvatar: string; + createdAt: string; + branch: string; + message: string; +} + +interface ActivityCardProps { + activity: ActivityDetails; +} + +const ActivityCard = ({ activity }: ActivityCardProps) => { + return ( +
+
{activity.authorAvatar}
+ +
+

{activity.author}

+

+ {relativeTime(activity.createdAt)} ^ {activity.branch} +

+

{activity.message}

+
+
+ ); +}; + +export default ActivityCard; diff --git a/packages/frontend/src/components/Overview.tsx b/packages/frontend/src/components/Overview.tsx new file mode 100644 index 00000000..2d5000d4 --- /dev/null +++ b/packages/frontend/src/components/Overview.tsx @@ -0,0 +1,57 @@ +import React from 'react'; + +import ActivityCard from './ActivityCard'; +import activityDetails from '../assets/activities.json'; +import { ProjectDetails } from '../types/project'; +import { relativeTime } from '../utils/time'; + +interface OverviewProps { + project: ProjectDetails; +} + +const Overview = ({ project }: OverviewProps) => ( +
+
+
+
^
+
+

{project.title}

+

{project.domain}

+
+
+
+

Domain

+ +
+
+

Source

+

{project.source}

+
+
+

deployment

+

{project.deployment}

+
+
+

Created

+

+ {relativeTime(project.createdAt)} by {project.createdBy} +

+
+
+
+
+

Activity

+ +
+
+ {activityDetails.map((activity, key) => { + return ; + })} +
+
+
+); + +export default Overview; diff --git a/packages/frontend/src/components/ProjectCard.tsx b/packages/frontend/src/components/ProjectCard.tsx index 599cc6ba..8d4d9486 100644 --- a/packages/frontend/src/components/ProjectCard.tsx +++ b/packages/frontend/src/components/ProjectCard.tsx @@ -1,19 +1,11 @@ import React from 'react'; -import { DateTime } from 'luxon'; import { Link } from 'react-router-dom'; -interface projectDetails { - icon: string; - title: string; - domain: string; - id: number; - latestCommit: { - [key: string]: string; - }; -} +import { relativeTime } from '../utils/time'; +import { ProjectDetails } from '../types/project'; interface ProjectCardProps { - project: projectDetails; + project: ProjectDetails; } const ProjectCard: React.FC = ({ project }) => { @@ -32,7 +24,7 @@ const ProjectCard: React.FC = ({ project }) => {

{project.latestCommit.message}

- {DateTime.fromISO(project.latestCommit.time).toRelative()} on{' '} + {relativeTime(project.latestCommit.createdAt)} on{' '} {project.latestCommit.branch}

diff --git a/packages/frontend/src/components/ProjectRepoCard.tsx b/packages/frontend/src/components/ProjectRepoCard.tsx index 5b9bdd40..c61decd5 100644 --- a/packages/frontend/src/components/ProjectRepoCard.tsx +++ b/packages/frontend/src/components/ProjectRepoCard.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { DateTime } from 'luxon'; + +import { relativeTime } from '../utils/time'; interface RepositoryDetails { title: string; @@ -16,7 +17,7 @@ const ProjectRepoCard: React.FC = ({ repository }) => {
^

{repository.title}

-

{DateTime.fromISO(repository.updatedTime).toRelative()}

+

{relativeTime(repository.updatedTime)}

); diff --git a/packages/frontend/src/components/Tab.tsx b/packages/frontend/src/components/Tab.tsx index ae4a4076..6470c1f4 100644 --- a/packages/frontend/src/components/Tab.tsx +++ b/packages/frontend/src/components/Tab.tsx @@ -1,14 +1,13 @@ import React from 'react'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; -const Overview = () => ( -
- Content of overview tab -

- Lorem Ipsum is simply dummy text of the printing and typesetting industry. -

-
-); +import Overview from './Overview'; +import { ProjectDetails } from '../types/project'; + +interface ProjectTabsProps { + project: ProjectDetails; +} + const Deployments = () => (
Content of deployments tab @@ -44,7 +43,7 @@ const Settings = () => (
); -const ProjectTab = () => { +const ProjectTabs = ({ project }: ProjectTabsProps) => { return ( { Settings - + @@ -77,4 +76,4 @@ const ProjectTab = () => { ); }; -export default ProjectTab; +export default ProjectTabs; diff --git a/packages/frontend/src/pages/projects/Create.tsx b/packages/frontend/src/pages/projects/Create.tsx index 3bad26e2..204cbc02 100644 --- a/packages/frontend/src/pages/projects/Create.tsx +++ b/packages/frontend/src/pages/projects/Create.tsx @@ -6,7 +6,7 @@ import TemplateCard from '../../components/TemplateCard'; import RepositoryList from '../../components/RepositoryList'; import ConnectAccount from '../../components/ConnectAccount'; -const isGitAuth = true; +const IS_GIT_AUTH = true; const CreateProject = () => { return ( @@ -31,7 +31,7 @@ const CreateProject = () => { })}
Import a repository
- {isGitAuth ? : } + {IS_GIT_AUTH ? : } ); }; diff --git a/packages/frontend/src/pages/projects/Project.tsx b/packages/frontend/src/pages/projects/Project.tsx index a8d8edcc..8b5b9db4 100644 --- a/packages/frontend/src/pages/projects/Project.tsx +++ b/packages/frontend/src/pages/projects/Project.tsx @@ -3,7 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import HorizontalLine from '../../components/HorizontalLine'; import projects from '../../assets/projects.json'; -import ProjectTab from '../../components/Tab'; +import ProjectTabs from '../../components/Tab'; const getProject = (id: number) => { return projects.find((project) => { @@ -18,16 +18,22 @@ const Project = () => { return (
-
- -

{project?.title}

- - -
- -
- -
+ {project ? ( + <> +
+ +

{project?.title}

+ + +
+ +
+ +
+ + ) : ( +

Project not found

+ )}
); }; diff --git a/packages/frontend/src/types/project.ts b/packages/frontend/src/types/project.ts new file mode 100644 index 00000000..675ef729 --- /dev/null +++ b/packages/frontend/src/types/project.ts @@ -0,0 +1,15 @@ +export interface ProjectDetails { + icon: string; + title: string; + domain: string; + id: number; + createdAt: string; + createdBy: string; + deployment: string; + source: string; + latestCommit: { + message: string; + createdAt: string; + branch: string; + }; +} diff --git a/packages/frontend/src/utils/time.ts b/packages/frontend/src/utils/time.ts new file mode 100644 index 00000000..f682cb63 --- /dev/null +++ b/packages/frontend/src/utils/time.ts @@ -0,0 +1,11 @@ +import { DateTime } from 'luxon'; + +/** + * Converts an ISO 8601 formatted time to a human-readable relative time with respect to the current time. + * + * @param {string} time - The input time in ISO 8601 format. + * @returns {string} - A human-readable relative time string. + */ +export const relativeTime = (time: string) => { + return DateTime.fromISO(time).toRelative(); +};