If need be (#168)

This commit is contained in:
Luke Vella 2022-05-13 08:44:35 +01:00 committed by GitHub
parent 6375e80641
commit 17dc9519d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 1033 additions and 642 deletions

View file

@ -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;
};