mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-29 08:46:22 +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();
|
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,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
@ -112,10 +112,7 @@ export const participants = router({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
select: {
|
include: {
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
poll: {
|
poll: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|
|
@ -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,
|
||||||
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue