Otypování requestů na API
This commit is contained in:
@@ -4,7 +4,7 @@ import { api } from "./Api";
|
||||
const EASTER_EGGS_API_PREFIX = '/api/easterEggs';
|
||||
|
||||
export const getEasterEgg = async (): Promise<EasterEgg | undefined> => {
|
||||
return await api.get(`${EASTER_EGGS_API_PREFIX}`);
|
||||
return await api.get<EasterEgg>(`${EASTER_EGGS_API_PREFIX}`);
|
||||
}
|
||||
|
||||
export const getImage = async (url: string) => {
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
import { AddChoiceRequest, ChangeDepartureTimeRequest, RemoveChoiceRequest, RemoveChoicesRequest, UpdateNoteRequest } from "../types";
|
||||
import { api } from "./Api";
|
||||
|
||||
const FOOD_API_PREFIX = '/api/food';
|
||||
|
||||
export const addChoice = async (locationIndex: number, foodIndex?: number, dayIndex?: number) => {
|
||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/addChoice`, { locationIndex, foodIndex, dayIndex });
|
||||
return await api.post<AddChoiceRequest, void>(`${FOOD_API_PREFIX}/addChoice`, { locationIndex, foodIndex, dayIndex });
|
||||
}
|
||||
|
||||
export const removeChoices = async (locationIndex: number, dayIndex?: number) => {
|
||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/removeChoices`, { locationIndex, dayIndex });
|
||||
return await api.post<RemoveChoicesRequest, void>(`${FOOD_API_PREFIX}/removeChoices`, { locationIndex, dayIndex });
|
||||
}
|
||||
|
||||
export const removeChoice = async (locationIndex: number, foodIndex: number, dayIndex?: number) => {
|
||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/removeChoice`, { locationIndex, foodIndex, dayIndex });
|
||||
return await api.post<RemoveChoiceRequest, void>(`${FOOD_API_PREFIX}/removeChoice`, { locationIndex, foodIndex, dayIndex });
|
||||
}
|
||||
|
||||
export const updateNote = async (note?: string, dayIndex?: number) => {
|
||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/updateNote`, { note, dayIndex });
|
||||
return await api.post<UpdateNoteRequest, void>(`${FOOD_API_PREFIX}/updateNote`, { note, dayIndex });
|
||||
}
|
||||
|
||||
export const changeDepartureTime = async (time: string, dayIndex?: number) => {
|
||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/changeDepartureTime`, { time, dayIndex });
|
||||
return await api.post<ChangeDepartureTimeRequest, void>(`${FOOD_API_PREFIX}/changeDepartureTime`, { time, dayIndex });
|
||||
}
|
||||
|
||||
export const jdemeObed = async () => {
|
||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/jdemeObed`, undefined);
|
||||
return await api.post<undefined, void>(`${FOOD_API_PREFIX}/jdemeObed`);
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
import { PizzaOrder } from "../types";
|
||||
import { AddPizzaRequest, FinishDeliveryRequest, PizzaOrder, RemovePizzaRequest, UpdatePizzaDayNoteRequest, UpdatePizzaFeeRequest } from "../types";
|
||||
import { api } from "./Api";
|
||||
|
||||
const PIZZADAY_API_PREFIX = '/api/pizzaDay';
|
||||
|
||||
export const createPizzaDay = async () => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/create`, undefined);
|
||||
return await api.post<undefined, void>(`${PIZZADAY_API_PREFIX}/create`);
|
||||
}
|
||||
|
||||
export const deletePizzaDay = async () => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/delete`, undefined);
|
||||
return await api.post<undefined, void>(`${PIZZADAY_API_PREFIX}/delete`);
|
||||
}
|
||||
|
||||
export const lockPizzaDay = async () => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/lock`, undefined);
|
||||
return await api.post<undefined, void>(`${PIZZADAY_API_PREFIX}/lock`);
|
||||
}
|
||||
|
||||
export const unlockPizzaDay = async () => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/unlock`, undefined);
|
||||
return await api.post<undefined, void>(`${PIZZADAY_API_PREFIX}/unlock`);
|
||||
}
|
||||
|
||||
export const finishOrder = async () => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/finishOrder`, undefined);
|
||||
return await api.post<undefined, void>(`${PIZZADAY_API_PREFIX}/finishOrder`);
|
||||
}
|
||||
|
||||
export const finishDelivery = async (bankAccount?: string, bankAccountHolder?: string) => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/finishDelivery`, { bankAccount, bankAccountHolder });
|
||||
return await api.post<FinishDeliveryRequest, void>(`${PIZZADAY_API_PREFIX}/finishDelivery`, { bankAccount, bankAccountHolder });
|
||||
}
|
||||
|
||||
export const addPizza = async (pizzaIndex: number, pizzaSizeIndex: number) => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/add`, { pizzaIndex, pizzaSizeIndex });
|
||||
return await api.post<AddPizzaRequest, void>(`${PIZZADAY_API_PREFIX}/add`, { pizzaIndex, pizzaSizeIndex });
|
||||
}
|
||||
|
||||
export const removePizza = async (pizzaOrder: PizzaOrder) => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/remove`, { pizzaOrder });
|
||||
return await api.post<RemovePizzaRequest, void>(`${PIZZADAY_API_PREFIX}/remove`, { pizzaOrder });
|
||||
}
|
||||
|
||||
export const updatePizzaDayNote = async (note?: string) => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, { note });
|
||||
return await api.post<UpdatePizzaDayNoteRequest, void>(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, { note });
|
||||
}
|
||||
|
||||
export const updatePizzaFee = async (login: string, text?: string, price?: number) => {
|
||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, { login, text, price });
|
||||
return await api.post<UpdatePizzaFeeRequest, void>(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, { login, text, price });
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { FeatureRequest } from "../types";
|
||||
import { FeatureRequest, UpdateFeatureVoteRequest } from "../types";
|
||||
import { api } from "./Api";
|
||||
|
||||
const VOTING_API_PREFIX = '/api/voting';
|
||||
|
||||
export const getFeatureVotes = async () => {
|
||||
return await api.get<any>(`${VOTING_API_PREFIX}/getVotes`);
|
||||
return await api.get<FeatureRequest[]>(`${VOTING_API_PREFIX}/getVotes`);
|
||||
}
|
||||
|
||||
export const updateFeatureVote = async (option: FeatureRequest, active: boolean) => {
|
||||
return await api.post<any, any>(`${VOTING_API_PREFIX}/updateVote`, { option, active });
|
||||
return await api.post<UpdateFeatureVoteRequest, void>(`${VOTING_API_PREFIX}/updateVote`, { option, active });
|
||||
}
|
||||
Reference in New Issue
Block a user