mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
25 lines
540 B
TypeScript
25 lines
540 B
TypeScript
import { Poll } from "@prisma/client";
|
|
import axios from "axios";
|
|
|
|
export interface UpdatePollPayload {
|
|
title?: string;
|
|
timeZone?: string;
|
|
location?: string;
|
|
description?: string;
|
|
optionsToDelete?: string[];
|
|
optionsToAdd?: string[];
|
|
notifications?: boolean;
|
|
closed?: boolean;
|
|
}
|
|
|
|
export const updatePoll = async (
|
|
urlId: string,
|
|
payload: UpdatePollPayload,
|
|
): Promise<Poll> => {
|
|
try {
|
|
const { data } = await axios.patch<Poll>(`/api/poll/${urlId}`, payload);
|
|
return data;
|
|
} catch (err) {
|
|
throw err;
|
|
}
|
|
};
|