Skip to content
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

Added user names in the backend; fixed request page and members list #79

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/pages/CreateProj.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default function CreateProj() {
ownerId: user?.id,
imageUrl: url,
startDate: formState.startDate,
creatorName: (user?.firstName + ' ' + user?.lastName),
tags: addedTags,
});
},
Expand Down
18 changes: 17 additions & 1 deletion client/src/pages/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Markdown from 'react-markdown';
import { RouterOutputs, trpc } from '../utils/trpc';
import { z } from 'zod';


dayjjs.extend(relativeTime);

function useGetProjectData() {
Expand All @@ -24,6 +25,7 @@ function useGetProjectData() {
};
}


export default function Project() {
const { data, isLoading, projectId } = useGetProjectData();
const { data: role, isLoading: roleIsLoading } =
Expand All @@ -32,6 +34,9 @@ export default function Project() {
const [showModal, setShowModal] = useState(false);
const utils = trpc.useUtils();

// const name = user?.getUser(data?.ownerId);


const sendJoinReqMutation =
trpc.memberships.sendProjectJoinRequest.useMutation({
onSuccess() {
Expand All @@ -57,13 +62,15 @@ export default function Project() {
ownerId: data.ownerId,
userId: user?.id,
description: description,
userName: (user?.firstName + ' ' + user?.lastName),
});
} else if (role.status === 'REJECTED') {
sendJoinReqMutation.mutate({
projectId: projectId,
ownerId: data.ownerId,
userId: user?.id,
description: description,
userName: (user?.firstName + ' ' + user?.lastName),
role: {
status: role.status,
id: role.id,
Expand Down Expand Up @@ -473,6 +480,8 @@ export function CreatePost() {

export function ProjectInfo() {
const { data, isLoading } = useGetProjectData();
// const { owner } = trpc.projects.getOwnerByID.useQuery(data?.ownerId ?? '',);


if (isLoading) return <div>loading</div>;

Expand All @@ -482,6 +491,12 @@ export function ProjectInfo() {
<div className="flex justify-between w-full gap-16">
<div className="flex flex-col gap-4">
<p className="text-zinc-800 leading-7">{data.description} </p>
<p>
<span className="underline font-semibold mr-3 underline-offset-4">
Posted By:
</span>
{data.creatorName}
</p>
<p>
<span className="underline font-semibold mr-3 underline-offset-4">
Meet Location:
Expand Down Expand Up @@ -573,6 +588,7 @@ export function ProjectPostsLayout() {
);
}


export function ProjectPost() {
const params = useParams();
const { data, isLoading } = trpc.posts.getById.useQuery(params.postId ?? '');
Expand Down Expand Up @@ -625,7 +641,7 @@ export function MemberList() {
key={member.userId}
className="flex justify-between w-full border-2 py-5 px-4 rounded-xl"
>
{member.userId}
{member.userName}

<div className="flex gap-4 items-center">
<button
Expand Down
6 changes: 6 additions & 0 deletions client/src/pages/Requests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default function Requests() {
</h1>
);


return (
<div className="w-full flex flex-col gap-4 ml-8">
{data.map((request) => (
Expand All @@ -105,6 +106,11 @@ export default function Requests() {
<h1 className="text-2xl font-bold text-zinc-800 mb-5">
<ProjectName projectId={request.projectId} />
</h1>

<p className="text-2xl font-bold text-zinc-800 mb-5">
{request.userName}
</p>

<p className="text-xl text-zinc-800 mb-5">
{request.description}
</p>
Expand Down
3 changes: 2 additions & 1 deletion server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ model Project {
memberships Memberships[]
imageUrl String
startDate String

creatorName String
}

model Tag {
Expand Down Expand Up @@ -78,6 +78,7 @@ model Memberships {
// User User @relation(fields: [userId], references: [id])
// User User @relation(fields: [userId], references: [id])
description String?
userName String

@@unique([projectId, userId])
@@index([projectId])
Expand Down
3 changes: 3 additions & 0 deletions server/src/routers/membershipsRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const membershipsRouter = router({
ownerId: z.string(),
userId: z.string(),
description: z.optional(z.string()),
userName: z.string(),
role: z.optional(
z.object({
status: z.string(),
Expand All @@ -25,6 +26,7 @@ export const membershipsRouter = router({
ownerId: input.ownerId,
userId: input.userId,
description: input.description,
userName: input.userName,
},
});
} else if (input.role.status === 'REJECTED') {
Expand All @@ -35,6 +37,7 @@ export const membershipsRouter = router({
data: {
status: 'PENDING',
description: input.description,
userName: input.userName,
},
});
}
Expand Down
4 changes: 3 additions & 1 deletion server/src/routers/projectsRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const projectsRouter = router({
select: {
id: true,
userId: true,
userName: true,
},
},
},
Expand Down Expand Up @@ -143,7 +144,7 @@ export const projectsRouter = router({
projectId: input,
},
});
}),
}),

// must be owner
createPost: authedProcedure
Expand All @@ -168,6 +169,7 @@ export const projectsRouter = router({
meetLocation: z.string(),
imageUrl: z.string(),
startDate: z.string(),
creatorName: z.string(),
tags: z.array(z.string()),
}),
)
Expand Down