Úprava API pro podporu TypeScript
This commit is contained in:
parent
a2167038da
commit
414664b2d7
@ -63,7 +63,7 @@ async function blobRequest(
|
|||||||
export const api = {
|
export const api = {
|
||||||
get: <TResponse>(url: string) => request<TResponse>(url),
|
get: <TResponse>(url: string) => request<TResponse>(url),
|
||||||
blobGet: (url: string) => blobRequest(url),
|
blobGet: (url: string) => blobRequest(url),
|
||||||
post: <TBody extends BodyInit, TResponse>(url: string, body: TBody) => request<TResponse>(url, { method: 'POST', body, headers: { 'Content-Type': 'application/json' } }),
|
post: <TBody, TResponse>(url: string, body?: TBody) => request<TResponse>(url, { method: 'POST', body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } }),
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getQrUrl = (login: string) => {
|
export const getQrUrl = (login: string) => {
|
||||||
@ -79,5 +79,5 @@ export const getData = async (dayIndex?: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const login = async (login?: string) => {
|
export const login = async (login?: string) => {
|
||||||
return await api.post<any, any>('/api/login', JSON.stringify({ login }));
|
return await api.post<any, any>('/api/login', { login });
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,25 @@ import { api } from "./Api";
|
|||||||
const FOOD_API_PREFIX = '/api/food';
|
const FOOD_API_PREFIX = '/api/food';
|
||||||
|
|
||||||
export const addChoice = async (locationIndex: number, foodIndex?: number, dayIndex?: number) => {
|
export const addChoice = async (locationIndex: number, foodIndex?: number, dayIndex?: number) => {
|
||||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/addChoice`, JSON.stringify({ locationIndex, foodIndex, dayIndex }));
|
return await api.post<any, any>(`${FOOD_API_PREFIX}/addChoice`, { locationIndex, foodIndex, dayIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeChoices = async (locationIndex: number, dayIndex?: number) => {
|
export const removeChoices = async (locationIndex: number, dayIndex?: number) => {
|
||||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/removeChoices`, JSON.stringify({ locationIndex, dayIndex }));
|
return await api.post<any, any>(`${FOOD_API_PREFIX}/removeChoices`, { locationIndex, dayIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeChoice = async (locationIndex: number, foodIndex: number, dayIndex?: number) => {
|
export const removeChoice = async (locationIndex: number, foodIndex: number, dayIndex?: number) => {
|
||||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/removeChoice`, JSON.stringify({ locationIndex, foodIndex, dayIndex }));
|
return await api.post<any, any>(`${FOOD_API_PREFIX}/removeChoice`, { locationIndex, foodIndex, dayIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateNote = async (note?: string, dayIndex?: number) => {
|
export const updateNote = async (note?: string, dayIndex?: number) => {
|
||||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/updateNote`, JSON.stringify({ note, dayIndex }));
|
return await api.post<any, any>(`${FOOD_API_PREFIX}/updateNote`, { note, dayIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const changeDepartureTime = async (time: string, dayIndex?: number) => {
|
export const changeDepartureTime = async (time: string, dayIndex?: number) => {
|
||||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/changeDepartureTime`, JSON.stringify({ time, dayIndex }));
|
return await api.post<any, any>(`${FOOD_API_PREFIX}/changeDepartureTime`, { time, dayIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const jdemeObed = async () => {
|
export const jdemeObed = async () => {
|
||||||
return await api.post<any, any>(`${FOOD_API_PREFIX}/jdemeObed`, JSON.stringify({}));
|
return await api.post<any, any>(`${FOOD_API_PREFIX}/jdemeObed`, undefined);
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,21 @@ export const finishOrder = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const finishDelivery = async (bankAccount?: string, bankAccountHolder?: string) => {
|
export const finishDelivery = async (bankAccount?: string, bankAccountHolder?: string) => {
|
||||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/finishDelivery`, JSON.stringify({ bankAccount, bankAccountHolder }));
|
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/finishDelivery`, { bankAccount, bankAccountHolder });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addPizza = async (pizzaIndex: number, pizzaSizeIndex: number) => {
|
export const addPizza = async (pizzaIndex: number, pizzaSizeIndex: number) => {
|
||||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/add`, JSON.stringify({ pizzaIndex, pizzaSizeIndex }));
|
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/add`, { pizzaIndex, pizzaSizeIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removePizza = async (pizzaOrder: PizzaOrder) => {
|
export const removePizza = async (pizzaOrder: PizzaOrder) => {
|
||||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/remove`, JSON.stringify({ pizzaOrder }));
|
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/remove`, { pizzaOrder });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updatePizzaDayNote = async (note?: string) => {
|
export const updatePizzaDayNote = async (note?: string) => {
|
||||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, JSON.stringify({ note }));
|
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, { note });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updatePizzaFee = async (login: string, text?: string, price?: number) => {
|
export const updatePizzaFee = async (login: string, text?: string, price?: number) => {
|
||||||
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, JSON.stringify({ login, text, price }));
|
return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, { login, text, price });
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ export const getFeatureVotes = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const updateFeatureVote = async (option: FeatureRequest, active: boolean) => {
|
export const updateFeatureVote = async (option: FeatureRequest, active: boolean) => {
|
||||||
return await api.post<any, any>(`${VOTING_API_PREFIX}/updateVote`, JSON.stringify({ option, active }));
|
return await api.post<any, any>(`${VOTING_API_PREFIX}/updateVote`, { option, active });
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user