Skip to content

Commit

Permalink
Fix ts issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Dec 22, 2024
1 parent 1b46326 commit 226dd40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions apps/web/src/components/poll/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export const useAddParticipantMutation = () => {
const queryClient = trpc.useUtils();

return trpc.polls.participants.add.useMutation({
onSuccess: (newParticipant, input) => {
const { pollId, name, email } = newParticipant;
onSuccess: (res, input) => {
const { poll, ...newParticipant } = res;
const { name, email } = newParticipant;
const pollId = poll.id;
queryClient.polls.participants.list.setData(
{ pollId },
(existingParticipants = []) => {
return [
{ ...newParticipant, votes: input.votes },
{ ...newParticipant, votes: input.votes, pollId },
...existingParticipants,
];
},
Expand Down
5 changes: 1 addition & 4 deletions apps/web/src/trpc/routers/polls/participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ export const participants = router({
},
},
},
select: {
id: true,
name: true,
email: true,
include: {
poll: {
select: {
id: true,
Expand Down
6 changes: 6 additions & 0 deletions packages/database/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ async function createPollForUser(userId: string) {
() => ({
name: faker.name.fullName(),
email: faker.internet.email(),
user: {
create: {
id: faker.random.alpha(10),
isGuest: true,
},
},
}),
),
},
Expand Down

0 comments on commit 226dd40

Please sign in to comment.