mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-31 23:19:15 +02:00
If need be (#168)
This commit is contained in:
parent
6375e80641
commit
17dc9519d2
48 changed files with 1033 additions and 642 deletions
|
@ -1,15 +1,20 @@
|
|||
import { Participant, Vote, VoteType } from "@prisma/client";
|
||||
import axios from "axios";
|
||||
|
||||
export interface UpdateParticipantPayload {
|
||||
pollId: string;
|
||||
participantId: string;
|
||||
name: string;
|
||||
votes: string[];
|
||||
votes: Array<{ optionId: string; type: VoteType }>;
|
||||
}
|
||||
|
||||
export const updateParticipant = async (
|
||||
payload: UpdateParticipantPayload,
|
||||
): Promise<void> => {
|
||||
): Promise<Participant & { votes: Vote[] }> => {
|
||||
const { pollId, participantId, ...body } = payload;
|
||||
await axios.patch(`/api/poll/${pollId}/participant/${participantId}`, body);
|
||||
const res = await axios.patch<Participant & { votes: Vote[] }>(
|
||||
`/api/poll/${pollId}/participant/${participantId}`,
|
||||
body,
|
||||
);
|
||||
return res.data;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue