Fakultas Ilmu Komputer UI

Commit 9c0cb6c5 authored by Doan Andreas Nathanael's avatar Doan Andreas Nathanael
Browse files

[RED] implement api callback for diet recom form

parent 5162a988
......@@ -26,11 +26,12 @@ export async function api<T>(
url: string,
body: object = {},
headers: object = {},
noStringify: boolean = false,
): ApiResponse<T> {
const requestData: AxiosRequestConfig = {
url,
method,
data: JSON.stringify(body),
data: noStringify ? body : JSON.stringify(body),
headers: {
Accept: 'application/json',
'Content-Type': 'application/json;charset=UTF-8',
......
import { api, RequestMethod, ApiResponse } from '../api';
import * as apiUrls from './urls';
import { DietRecommendationResponse } from './models';
import {
DietRecommendationRequest,
DietRecommendationResponse,
} from './models';
export const retrieveDietRecommendationApi = (): ApiResponse<
DietRecommendationResponse[]
......@@ -14,3 +17,15 @@ export const retrieveDietRecommendationByIdApi = (
): ApiResponse<DietRecommendationResponse> => {
return api(RequestMethod.GET, apiUrls.dietRecommendationById(id));
};
export const submitDietRecommendationByIdApi = (id: number, body) => {
return api(
RequestMethod.PATCH,
apiUrls.dietRecommendationById(id),
body,
{
'Content-Type': 'multipart/form-data',
},
true,
);
};
......@@ -6,3 +6,9 @@ export interface DietRecommendationResponse {
nutritionist: number;
client: number;
}
export interface DietRecommendationRequest {
client_plan_meal: string;
nutritional_advice: string;
lifestyle_advice: string;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment