Add project status

pull/7289/head
Kamran Ahmed 2 months ago
parent efbd1d7f04
commit 6b118d14d3
  1. 8
      src/components/Projects/ProjectCard.tsx
  2. 11
      src/components/Projects/ProjectsList.tsx
  3. 1
      src/components/Projects/ProjectsPage.tsx

@ -24,10 +24,8 @@ export function ProjectCard(props: ProjectCardProps) {
const { project, userCount = 0, status } = props; const { project, userCount = 0, status } = props;
const { frontmatter, id } = project; const { frontmatter, id } = project;
const isAuthed = isLoggedIn(); const isLoadingStatus = status === undefined;
const isLoadingStatus = isAuthed && status === undefined; const userStartedCount = status !== 'none' && userCount === 0 ? userCount + 1 : userCount;
const userStartedCount =
status && status !== 'none' ? userCount + 1 : userCount;
return ( return (
<a <a
@ -62,7 +60,7 @@ export function ProjectCard(props: ProjectCardProps) {
)} )}
</span> </span>
{status !== 'none' && isAuthed && ( {status !== 'none' && (
<span <span
className={cn( className={cn(
'flex items-center gap-1.5 rounded-full border border-current px-2 py-0.5 capitalize', 'flex items-center gap-1.5 rounded-full border border-current px-2 py-0.5 capitalize',

@ -61,6 +61,11 @@ export function ProjectsList(props: ProjectsListProps) {
useState<ListProjectStatusesResponse>(); useState<ListProjectStatusesResponse>();
const loadProjectStatuses = async () => { const loadProjectStatuses = async () => {
if (!isLoggedIn()) {
setProjectStatuses({});
return;
}
const projectIds = projects.map((project) => project.id); const projectIds = projects.map((project) => project.id);
const { response, error } = await httpPost( const { response, error } = await httpPost(
`${import.meta.env.PUBLIC_API_URL}/v1-list-project-statuses`, `${import.meta.env.PUBLIC_API_URL}/v1-list-project-statuses`,
@ -99,10 +104,6 @@ export function ProjectsList(props: ProjectsListProps) {
: projects; : projects;
useEffect(() => { useEffect(() => {
if (!isLoggedIn()) {
return;
}
loadProjectStatuses().finally(); loadProjectStatuses().finally();
}, []); }, []);
@ -172,7 +173,7 @@ export function ProjectsList(props: ProjectsListProps) {
userCount={count} userCount={count}
status={ status={
projectStatuses projectStatuses
? (projectStatuses?.[matchingProject.id] ?? 'none') ? (projectStatuses?.[matchingProject.id] || 'none')
: undefined : undefined
} }
/> />

@ -190,6 +190,7 @@ export function ProjectsPage(props: ProjectsPageProps) {
key={project.id} key={project.id}
project={project} project={project}
userCount={userCounts[project.id] || 0} userCount={userCounts[project.id] || 0}
status={'none'}
/> />
))} ))}
</div> </div>

Loading…
Cancel
Save