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();
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,
];
},

View file

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

View file

@ -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,
},
},
}),
),
},