Skip to content

Commit

Permalink
Add project status
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Oct 1, 2024
1 parent efbd1d7 commit 6b118d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/components/Projects/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export function ProjectCard(props: ProjectCardProps) {
const { project, userCount = 0, status } = props;
const { frontmatter, id } = project;

const isAuthed = isLoggedIn();
const isLoadingStatus = isAuthed && status === undefined;
const userStartedCount =
status && status !== 'none' ? userCount + 1 : userCount;
const isLoadingStatus = status === undefined;
const userStartedCount = status !== 'none' && userCount === 0 ? userCount + 1 : userCount;

return (
<a
Expand Down Expand Up @@ -62,7 +60,7 @@ export function ProjectCard(props: ProjectCardProps) {
)}
</span>

{status !== 'none' && isAuthed && (
{status !== 'none' && (
<span
className={cn(
'flex items-center gap-1.5 rounded-full border border-current px-2 py-0.5 capitalize',
Expand Down
11 changes: 6 additions & 5 deletions src/components/Projects/ProjectsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export function ProjectsList(props: ProjectsListProps) {
useState<ListProjectStatusesResponse>();

const loadProjectStatuses = async () => {
if (!isLoggedIn()) {
setProjectStatuses({});
return;
}

const projectIds = projects.map((project) => project.id);
const { response, error } = await httpPost(
`${import.meta.env.PUBLIC_API_URL}/v1-list-project-statuses`,
Expand Down Expand Up @@ -99,10 +104,6 @@ export function ProjectsList(props: ProjectsListProps) {
: projects;

useEffect(() => {
if (!isLoggedIn()) {
return;
}

loadProjectStatuses().finally();
}, []);

Expand Down Expand Up @@ -172,7 +173,7 @@ export function ProjectsList(props: ProjectsListProps) {
userCount={count}
status={
projectStatuses
? (projectStatuses?.[matchingProject.id] ?? 'none')
? (projectStatuses?.[matchingProject.id] || 'none')
: undefined
}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/Projects/ProjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export function ProjectsPage(props: ProjectsPageProps) {
key={project.id}
project={project}
userCount={userCounts[project.id] || 0}
status={'none'}
/>
))}
</div>
Expand Down

0 comments on commit 6b118d1

Please sign in to comment.