@@ -2,8 +2,10 @@ import { authFetch } from "@/api/auth";
22
33import type { BenefitDetail , ScreenerResult } from "@/types" ;
44
5+ const apiUrl = import . meta. env . VITE_API_URL ;
6+
57export const fetchProjects = async ( ) => {
6- const url = "/api /screeners";
8+ const url = apiUrl + " /screeners";
79 try {
810 const response = await authFetch ( url , {
911 method : "GET" ,
@@ -23,8 +25,8 @@ export const fetchProjects = async () => {
2325 }
2426} ;
2527
26- export const fetchProject = async ( screenerId : string ) => {
27- const url = `/api/ screener/${ screenerId } ` ;
28+ export const fetchProject = async ( screenerId ) => {
29+ const url = apiUrl + "/ screener/" + screenerId ;
2830 try {
2931 const response = await authFetch ( url , {
3032 method : "GET" ,
@@ -45,7 +47,7 @@ export const fetchProject = async (screenerId: string) => {
4547} ;
4648
4749export const createNewScreener = async ( screenerData ) => {
48- const url = "/api /screener";
50+ const url = apiUrl + " /screener";
4951 try {
5052 const response = await authFetch ( url , {
5153 method : "POST" ,
@@ -68,7 +70,7 @@ export const createNewScreener = async (screenerData) => {
6870} ;
6971
7072export const updateScreener = async ( screenerData ) => {
71- const url = "/api /screener";
73+ const url = apiUrl + " /screener";
7274 try {
7375 const response = await authFetch ( url , {
7476 method : "PUT" ,
@@ -89,7 +91,7 @@ export const updateScreener = async (screenerData) => {
8991} ;
9092
9193export const deleteScreener = async ( screenerData ) => {
92- const url = "/api /screener/delete?screenerId=" + screenerData . id ;
94+ const url = apiUrl + " /screener/delete?screenerId=" + screenerData . id ;
9395 try {
9496 const response = await authFetch ( url , {
9597 method : "DELETE" ,
@@ -112,7 +114,7 @@ export const saveFormSchema = async (screenerId, schema) => {
112114 const requestData : any = { } ;
113115 requestData . screenerId = screenerId ;
114116 requestData . schema = schema ;
115- const url = "/api /save-form-schema";
117+ const url = apiUrl + " /save-form-schema";
116118 try {
117119 const response = await authFetch ( url , {
118120 method : "POST" ,
@@ -133,7 +135,7 @@ export const saveFormSchema = async (screenerId, schema) => {
133135} ;
134136
135137export const publishScreener = async ( screenerId : string ) : Promise < void > => {
136- const url = "/api /publish";
138+ const url = apiUrl + " /publish";
137139 try {
138140 const response = await authFetch ( url , {
139141 method : "POST" ,
@@ -153,11 +155,8 @@ export const publishScreener = async (screenerId: string): Promise<void> => {
153155 }
154156} ;
155157
156- export const addCustomBenefit = async (
157- screenerId : string ,
158- benefit : BenefitDetail
159- ) => {
160- const url = `/api/screener/${ screenerId } /benefit` ;
158+ export const addCustomBenefit = async ( screenerId : string , benefit : BenefitDetail ) => {
159+ const url = apiUrl + "/screener/" + screenerId + "/benefit" ;
161160 try {
162161 const response = await authFetch ( url , {
163162 method : "POST" ,
@@ -177,11 +176,8 @@ export const addCustomBenefit = async (
177176 }
178177} ;
179178
180- export const removeCustomBenefit = async (
181- screenerId : string ,
182- benefitId : string
183- ) => {
184- const url = `/screener/${ screenerId } /benefit/${ benefitId } ` ;
179+ export const removeCustomBenefit = async ( screenerId : string , benefitId : string ) => {
180+ const url = apiUrl + "/screener/" + screenerId + "/benefit/" + benefitId ;
185181 try {
186182 const response = await authFetch ( url , {
187183 method : "DELETE" ,
@@ -192,21 +188,16 @@ export const removeCustomBenefit = async (
192188 } ) ;
193189
194190 if ( ! response . ok ) {
195- throw new Error (
196- `Delete of benefit failed with status: ${ response . status } `
197- ) ;
191+ throw new Error ( `Delete of benefit failed with status: ${ response . status } ` ) ;
198192 }
199193 } catch ( error ) {
200194 console . error ( "Error deleting custom benefit:" , error ) ;
201195 throw error ;
202196 }
203197} ;
204198
205- export const evaluateScreener = async (
206- screenerId : string ,
207- inputData : any
208- ) : Promise < ScreenerResult > => {
209- const url = `/api/decision/v2?screenerId=${ screenerId } ` ;
199+ export const evaluateScreener = async ( screenerId : string , inputData : any ) : Promise < ScreenerResult > => {
200+ const url = apiUrl + "/decision/v2?screenerId=" + screenerId ;
210201 try {
211202 const response = await authFetch ( url , {
212203 method : "POST" ,
@@ -220,7 +211,7 @@ export const evaluateScreener = async (
220211 if ( ! response . ok ) {
221212 throw new Error ( `Evaluation failed with status: ${ response . status } ` ) ;
222213 }
223-
214+
224215 const data = await response . json ( ) ;
225216 return data ;
226217 } catch ( error ) {
0 commit comments