mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-25 23:06:20 +02:00
Fix ts issues
This commit is contained in:
parent
1b4632654c
commit
226dd4062c
3 changed files with 12 additions and 7 deletions
|
@ -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,
|
||||
];
|
||||
},
|
||||
|
|
|
@ -112,10 +112,7 @@ export const participants = router({
|
|||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
email: true,
|
||||
include: {
|
||||
poll: {
|
||||
select: {
|
||||
id: true,
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue