Skip to content

Commit

Permalink
fix prop (#4930)
Browse files Browse the repository at this point in the history
Fixes an issue where the collaborators prop was not passed correctly
  • Loading branch information
liady authored Feb 21, 2024
1 parent 77edbb1 commit 6b0ef99
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions utopia-remix/app/routes/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,40 +454,49 @@ const CategoryTrashActions = React.memo(({ projects }: { projects: ProjectWithou
})
CategoryTrashActions.displayName = 'CategoryTrashActions'

const ProjectCards = React.memo(({ projects }: { projects: ProjectWithoutContent[] }) => {
const selectedProjectId = useProjectsStore((store) => store.selectedProjectId)
const setSelectedProjectId = useProjectsStore((store) => store.setSelectedProjectId)
const ProjectCards = React.memo(
({
projects,
collaborators,
}: {
projects: ProjectWithoutContent[]
collaborators: CollaboratorsByProject
}) => {
const selectedProjectId = useProjectsStore((store) => store.selectedProjectId)
const setSelectedProjectId = useProjectsStore((store) => store.setSelectedProjectId)

const handleProjectSelect = React.useCallback(
(project: ProjectWithoutContent) =>
setSelectedProjectId(project.proj_id === selectedProjectId ? null : project.proj_id),
[setSelectedProjectId, selectedProjectId],
)
const handleProjectSelect = React.useCallback(
(project: ProjectWithoutContent) =>
setSelectedProjectId(project.proj_id === selectedProjectId ? null : project.proj_id),
[setSelectedProjectId, selectedProjectId],
)

return (
<div
style={{
display: 'flex',
flexWrap: 'wrap',
alignContent: 'flex-start',
gap: MarginSize,
flexGrow: 1,
flexDirection: 'row',
overflowY: 'scroll',
scrollbarColor: 'lightgrey transparent',
}}
>
{projects.map((project) => (
<ProjectCard
key={project.proj_id}
project={project}
selected={project.proj_id === selectedProjectId}
onSelect={() => handleProjectSelect(project)}
/>
))}
</div>
)
})
return (
<div
style={{
display: 'flex',
flexWrap: 'wrap',
alignContent: 'flex-start',
gap: MarginSize,
flexGrow: 1,
flexDirection: 'row',
overflowY: 'scroll',
scrollbarColor: 'lightgrey transparent',
}}
>
{projects.map((project) => (
<ProjectCard
key={project.proj_id}
project={project}
selected={project.proj_id === selectedProjectId}
onSelect={() => handleProjectSelect(project)}
collaborators={collaborators[project.proj_id]}
/>
))}
</div>
)
},
)
ProjectCards.displayName = 'ProjectCards'

const ProjectCard = React.memo(
Expand Down

0 comments on commit 6b0ef99

Please sign in to comment.