From 692f8f970aa57ae833e50d51276e1048328ae1ff Mon Sep 17 00:00:00 2001 From: unknown <13521043@std.stei.itb.ac.id> Date: Fri, 17 Nov 2023 10:45:48 +0700 Subject: [PATCH] feat: call node service (not done yet) --- src/utils/api/gymApplication.ts | 10 ++++++++-- src/utils/api/job.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/api/gymApplication.ts b/src/utils/api/gymApplication.ts index d5afd3e..93ec8b6 100644 --- a/src/utils/api/gymApplication.ts +++ b/src/utils/api/gymApplication.ts @@ -1,3 +1,6 @@ +import axios from "axios"; +import config from "../config"; +import { header } from "."; import { GymApplicationFetched, GymApplicationReturned, @@ -5,7 +8,7 @@ import { } from "../validationSchema/gymApplication"; export async function getGymApplication(): Promise<GymApplicationReturned[]> { - // return (await axios.get(`${config.NODE_JS_API}/api/gym/`, header)).data; + // const res = (await axios.get(`${config.NODE_JS_API}/api/job/${username}`, header)); const myPromise = new Promise<GymApplicationFetched[]>(function (myResolve) { myResolve([ { @@ -40,7 +43,10 @@ export async function applyToGym({ gym_id, gym_name, }: GymApplicationSent): Promise<GymApplicationReturned> { - // return (await axios.get(`${config.NODE_JS_API}/api/gym/`, header)).data; + const res = (await (await axios.post(`${config.NODE_JS_API}/api/job/apply`, header)).data); + if (res.status !== 200) { + throw new Error("Failed to apply to gym"); + } const myPromise = new Promise<GymApplicationReturned>(function (myResolve) { myResolve({ acceptance: 0, diff --git a/src/utils/api/job.ts b/src/utils/api/job.ts index 12191d4..339c034 100644 --- a/src/utils/api/job.ts +++ b/src/utils/api/job.ts @@ -9,6 +9,6 @@ export async function resign({ username: string; }): Promise<UserReturned> { return ( - await axios.patch(`${config.NODE_JS_API}/api/job/${username}`, {}, header) + await axios.patch(`${config.NODE_JS_API}/api/job/resign/${username}`, {}, header) ).data.user; } -- GitLab