Fix ts issues

This commit is contained in:
Luke Vella 2024-12-22 11:36:48 +01:00
parent 1b4632654c
commit 226dd4062c
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
3 changed files with 12 additions and 7 deletions

View file

@ -20,13 +20,15 @@ export const useAddParticipantMutation = () => {
const queryClient = trpc.useUtils(); const queryClient = trpc.useUtils();
return trpc.polls.participants.add.useMutation({ return trpc.polls.participants.add.useMutation({
onSuccess: (newParticipant, input) => { onSuccess: (res, input) => {
const { pollId, name, email } = newParticipant; const { poll, ...newParticipant } = res;
const { name, email } = newParticipant;
const pollId = poll.id;
queryClient.polls.participants.list.setData( queryClient.polls.participants.list.setData(
{ pollId }, { pollId },
(existingParticipants = []) => { (existingParticipants = []) => {
return [ return [
{ ...newParticipant, votes: input.votes }, { ...newParticipant, votes: input.votes, pollId },
...existingParticipants, ...existingParticipants,
]; ];
}, },

View file

@ -112,10 +112,7 @@ export const participants = router({
}, },
}, },
}, },
select: { include: {
id: true,
name: true,
email: true,
poll: { poll: {
select: { select: {
id: true, id: true,

View file

@ -63,6 +63,12 @@ async function createPollForUser(userId: string) {
() => ({ () => ({
name: faker.name.fullName(), name: faker.name.fullName(),
email: faker.internet.email(), email: faker.internet.email(),
user: {
create: {
id: faker.random.alpha(10),
isGuest: true,
},
},
}), }),
), ),
}, },