mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
23 lines
507 B
TypeScript
23 lines
507 B
TypeScript
import { Participant, Vote } from "@prisma/client";
|
|
import axios from "axios";
|
|
|
|
export interface AddParticipantPayload {
|
|
pollId: string;
|
|
name: string;
|
|
votes: string[];
|
|
}
|
|
|
|
export type AddParticipantResponse = Participant & {
|
|
votes: Vote[];
|
|
};
|
|
|
|
export const addParticipant = async (
|
|
payload: AddParticipantPayload,
|
|
): Promise<AddParticipantResponse> => {
|
|
const res = await axios.post<AddParticipantResponse>(
|
|
`/api/poll/${payload.pollId}/participant`,
|
|
payload,
|
|
);
|
|
|
|
return res.data;
|
|
};
|