-
Notifications
You must be signed in to change notification settings - Fork 0
200 project card #207
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
Open
mehanana
wants to merge
9
commits into
main
Choose a base branch
from
200-project-card
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
200 project card #207
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b8b9df3
active project card created + tested
mehanana 23e46e0
archive project card + tests created
mehanana 841ecfb
Merge branch 'main' into 200-project-card
mehanana 7054939
used 1 ProjectCard type with a prop to declare if it's an active or a…
mehanana 6703a02
update package-lock.json
mehanana c83d16d
Merge branch 'main' into 200-project-card
mehanana 334d577
Merge branch 'main' into 200-project-card
mehanana 74c29dc
removed ProjectCard from page.tsx and minor css fixes
mehanana e50999d
Merge branch '200-project-card' of https://github.com/Code-4-Communit…
mehanana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import React from 'react'; | ||
| import { LuDollarSign } from "react-icons/lu"; | ||
| import { RxPeople } from "react-icons/rx"; | ||
| import { FaArrowRight } from "react-icons/fa6"; | ||
|
|
||
| interface ArchiveCardProps { | ||
| name: string; | ||
| total_budget: number; | ||
| members: number; | ||
| start_date: string; | ||
| end_date: string; | ||
| } | ||
|
|
||
| export default function ArchiveProjectCard({ name, total_budget, members, start_date, end_date }: ArchiveCardProps) { | ||
| return ( | ||
| <div className="!border-[1px] border-solid border-black-300 w-full sm:w-[50%] md:w-[35%] lg:w-[25%] rounded-[4px] overflow-hidden"> | ||
| <div className="flex flex-col !gap-3 !p-4"> | ||
| <h4>{name}</h4> | ||
| <div className="flex flex-row w-full !pb-3 !border-b-[2px] border-black-300 justify-center !gap-2 !px-2"> | ||
| <div className="flex flex-col !gap-1 !pr-4 !border-r-[2px] border-black-300 flex-1"> | ||
| <div className="flex flex-row items-center !gap-1"> | ||
| <LuDollarSign /> | ||
| <h5 className="!font-bold">Budget</h5> | ||
| </div> | ||
| <p className="truncate">${total_budget.toLocaleString()}</p> | ||
| </div> | ||
| <div className="flex flex-col !gap-1 !pl-4 flex-1"> | ||
| <div className="flex flex-row items-center !gap-1"> | ||
| <RxPeople /> | ||
| <h5 className="!font-bold">Staff</h5> | ||
| </div> | ||
| <p className="truncate">{members.toLocaleString()} members</p> | ||
| </div> | ||
| </div> | ||
| <div className="grid grid-cols-[1fr_auto_1fr] w-full items-center !gap-2 !px-2"> | ||
| <div className="flex flex-col !gap-1"> | ||
| <h5 className="!font-bold">Start Date</h5> | ||
| <p>{start_date}</p> | ||
| </div> | ||
| <FaArrowRight className="justify-self-center" /> | ||
| <div className="flex flex-col !gap-1"> | ||
| <h5 className="!font-bold">End Date</h5> | ||
| <p>{end_date}</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import React from 'react'; | ||
| import { LuDollarSign } from "react-icons/lu"; | ||
| import { RxPeople } from "react-icons/rx"; | ||
| import { FaArrowRight } from "react-icons/fa6"; | ||
|
|
||
| type ActiveProps = { | ||
| variant: 'active'; | ||
| name: string; | ||
| total_budget: number; | ||
| budget_used: number; | ||
| members: number; | ||
| }; | ||
|
|
||
| type ArchiveProps = { | ||
| variant: 'archive'; | ||
| name: string; | ||
| total_budget: number; | ||
| members: number; | ||
| start_date: string; | ||
| end_date: string; | ||
| }; | ||
|
|
||
| type ProjectCardProps = ActiveProps | ArchiveProps; | ||
|
|
||
| export default function ProjectCard(props: ProjectCardProps) { | ||
| return ( | ||
| <div className="!border-[1px] border-solid border-black-300 w-full sm:w-[50%] md:w-[35%] lg:w-[25%] rounded-[4px] overflow-hidden"> | ||
| <div className="flex flex-col !gap-4 !p-4"> | ||
| <h4 className="!px-2">{props.name}</h4> | ||
| <div className="flex flex-row !px-2 !gap-4 min-w-0"> | ||
| <div className="flex flex-col !gap-1 !pr-4 !border-r-[2px] border-black-300 min-w-0"> | ||
| <div className="flex flex-row items-center !gap-1 !pr-4"> | ||
| <LuDollarSign /> | ||
| <h5 className="!font-bold">Budget</h5> | ||
| </div> | ||
| <p className="truncate"> | ||
| {props.variant === 'active' | ||
| ? `$${props.budget_used.toLocaleString()}/$${props.total_budget.toLocaleString()}` | ||
| : `$${props.total_budget.toLocaleString()}`} | ||
| </p> | ||
| </div> | ||
| <div className="flex flex-col !gap-1 !pl-1 min-w-0"> | ||
| <div className="flex flex-row items-center !gap-1"> | ||
| <RxPeople /> | ||
| <h5 className="!font-bold">Staff</h5> | ||
| </div> | ||
| <p className="truncate">{props.members.toLocaleString()} members</p> | ||
| </div> | ||
| </div> | ||
| {props.variant === 'active' ? ( | ||
| <div className="flex flex-row items-center !gap-2"> | ||
| <div className="w-full !h-[24px] rounded-full bg-black-100"> | ||
| <div | ||
| style={{ width: `${Math.round((props.budget_used / props.total_budget) * 100)}%` }} | ||
| className="!h-full rounded-full bg-core-green" | ||
| /> | ||
| </div> | ||
| <p>{Math.round((props.budget_used / props.total_budget) * 100)}%</p> | ||
| </div> | ||
| ) : ( | ||
| <div className="flex flex-row w-full items-center !gap-4 !px-2"> | ||
| <div className="flex flex-col !gap-1"> | ||
| <h5 className="!font-bold">Start Date</h5> | ||
| <p>{props.start_date}</p> | ||
| </div> | ||
| <FaArrowRight className="shrink-0" /> | ||
| <div className="flex flex-col !gap-1"> | ||
| <h5 className="!font-bold">End Date</h5> | ||
| <p>{props.end_date}</p> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { render, screen } from '../utils'; | ||
| import ProjectCard from '@/app/components/ProjectCard'; | ||
|
|
||
| const activeMockProps = { | ||
| variant: 'active' as const, | ||
| name: 'Clinician Communication Study', | ||
| total_budget: 500000, | ||
| budget_used: 150000, | ||
| members: 3, | ||
| }; | ||
|
|
||
| const archiveMockProps = { | ||
| variant: 'archive' as const, | ||
| name: 'Health Education Initiative', | ||
| total_budget: 300000, | ||
| members: 2, | ||
| start_date: 'Jan 1, 2025', | ||
| end_date: 'Mar 1, 2026', | ||
| }; | ||
|
|
||
| describe('ProjectCard (active)', () => { | ||
| it('renders the project name', () => { | ||
| render(<ProjectCard {...activeMockProps} />); | ||
| expect(screen.getByText('Clinician Communication Study')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the budget label and values', () => { | ||
| render(<ProjectCard {...activeMockProps} />); | ||
| expect(screen.getByText('Budget')).toBeInTheDocument(); | ||
| expect(screen.getByText((content) => content.includes('150,000') && content.includes('500,000'))).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the staff label and member count', () => { | ||
| render(<ProjectCard {...activeMockProps} />); | ||
| expect(screen.getByText('Staff')).toBeInTheDocument(); | ||
| expect(screen.getByText('3 members')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the correct percentage', () => { | ||
| render(<ProjectCard {...activeMockProps} />); | ||
| const percentage = Math.round((activeMockProps.budget_used / activeMockProps.total_budget) * 100); | ||
| expect(screen.getByText(`${percentage}%`)).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('ProjectCard (archive)', () => { | ||
| it('renders the project name', () => { | ||
| render(<ProjectCard {...archiveMockProps} />); | ||
| expect(screen.getByText('Health Education Initiative')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the budget label and total', () => { | ||
| render(<ProjectCard {...archiveMockProps} />); | ||
| expect(screen.getByText('Budget')).toBeInTheDocument(); | ||
| expect(screen.getByText('$300,000')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the staff label and member count', () => { | ||
| render(<ProjectCard {...archiveMockProps} />); | ||
| expect(screen.getByText('Staff')).toBeInTheDocument(); | ||
| expect(screen.getByText('2 members')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the start and end date labels', () => { | ||
| render(<ProjectCard {...archiveMockProps} />); | ||
| expect(screen.getByText('Start Date')).toBeInTheDocument(); | ||
| expect(screen.getByText('End Date')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the correct start and end date values', () => { | ||
| render(<ProjectCard {...archiveMockProps} />); | ||
| expect(screen.getByText('Jan 1, 2025')).toBeInTheDocument(); | ||
| expect(screen.getByText('Mar 1, 2026')).toBeInTheDocument(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this file meant to still be in this PR?