@@ -2,10 +2,8 @@ import { authFetch } from "@/api/auth";
22
33import type { BenefitDetail , ScreenerResult } from "@/types" ;
44
5- const apiUrl = import . meta. env . VITE_API_URL ;
6-
75export const fetchProjects = async ( ) => {
8- const url = apiUrl + " /screeners";
6+ const url = "/api /screeners";
97 try {
108 const response = await authFetch ( url , {
119 method : "GET" ,
@@ -25,8 +23,8 @@ export const fetchProjects = async () => {
2523 }
2624} ;
2725
28- export const fetchProject = async ( screenerId ) => {
29- const url = apiUrl + "/ screener/" + screenerId ;
26+ export const fetchProject = async ( screenerId : string ) => {
27+ const url = `/api/ screener/${ screenerId } ` ;
3028 try {
3129 const response = await authFetch ( url , {
3230 method : "GET" ,
@@ -47,7 +45,7 @@ export const fetchProject = async (screenerId) => {
4745} ;
4846
4947export const createNewScreener = async ( screenerData ) => {
50- const url = apiUrl + " /screener";
48+ const url = "/api /screener";
5149 try {
5250 const response = await authFetch ( url , {
5351 method : "POST" ,
@@ -70,7 +68,7 @@ export const createNewScreener = async (screenerData) => {
7068} ;
7169
7270export const updateScreener = async ( screenerData ) => {
73- const url = apiUrl + " /screener";
71+ const url = "/api /screener";
7472 try {
7573 const response = await authFetch ( url , {
7674 method : "PUT" ,
@@ -91,7 +89,7 @@ export const updateScreener = async (screenerData) => {
9189} ;
9290
9391export const deleteScreener = async ( screenerData ) => {
94- const url = apiUrl + " /screener/delete?screenerId=" + screenerData . id ;
92+ const url = "/api /screener/delete?screenerId=" + screenerData . id ;
9593 try {
9694 const response = await authFetch ( url , {
9795 method : "DELETE" ,
@@ -114,7 +112,7 @@ export const saveFormSchema = async (screenerId, schema) => {
114112 const requestData : any = { } ;
115113 requestData . screenerId = screenerId ;
116114 requestData . schema = schema ;
117- const url = apiUrl + " /save-form-schema";
115+ const url = "/api /save-form-schema";
118116 try {
119117 const response = await authFetch ( url , {
120118 method : "POST" ,
@@ -135,7 +133,7 @@ export const saveFormSchema = async (screenerId, schema) => {
135133} ;
136134
137135export const publishScreener = async ( screenerId : string ) : Promise < void > => {
138- const url = apiUrl + " /publish";
136+ const url = "/api /publish";
139137 try {
140138 const response = await authFetch ( url , {
141139 method : "POST" ,
@@ -155,8 +153,11 @@ export const publishScreener = async (screenerId: string): Promise<void> => {
155153 }
156154} ;
157155
158- export const addCustomBenefit = async ( screenerId : string , benefit : BenefitDetail ) => {
159- const url = apiUrl + "/screener/" + screenerId + "/benefit" ;
156+ export const addCustomBenefit = async (
157+ screenerId : string ,
158+ benefit : BenefitDetail
159+ ) => {
160+ const url = `/api/screener/${ screenerId } /benefit` ;
160161 try {
161162 const response = await authFetch ( url , {
162163 method : "POST" ,
@@ -176,8 +177,11 @@ export const addCustomBenefit = async (screenerId: string, benefit: BenefitDetai
176177 }
177178} ;
178179
179- export const removeCustomBenefit = async ( screenerId : string , benefitId : string ) => {
180- const url = apiUrl + "/screener/" + screenerId + "/benefit/" + benefitId ;
180+ export const removeCustomBenefit = async (
181+ screenerId : string ,
182+ benefitId : string
183+ ) => {
184+ const url = `/screener/${ screenerId } /benefit/${ benefitId } ` ;
181185 try {
182186 const response = await authFetch ( url , {
183187 method : "DELETE" ,
@@ -188,16 +192,21 @@ export const removeCustomBenefit = async (screenerId: string, benefitId: string)
188192 } ) ;
189193
190194 if ( ! response . ok ) {
191- throw new Error ( `Delete of benefit failed with status: ${ response . status } ` ) ;
195+ throw new Error (
196+ `Delete of benefit failed with status: ${ response . status } `
197+ ) ;
192198 }
193199 } catch ( error ) {
194200 console . error ( "Error deleting custom benefit:" , error ) ;
195201 throw error ;
196202 }
197203} ;
198204
199- export const evaluateScreener = async ( screenerId : string , inputData : any ) : Promise < ScreenerResult > => {
200- const url = apiUrl + "/decision/v2?screenerId=" + screenerId ;
205+ export const evaluateScreener = async (
206+ screenerId : string ,
207+ inputData : any
208+ ) : Promise < ScreenerResult > => {
209+ const url = `/api/decision/v2?screenerId=${ screenerId } ` ;
201210 try {
202211 const response = await authFetch ( url , {
203212 method : "POST" ,
@@ -211,7 +220,7 @@ export const evaluateScreener = async (screenerId: string, inputData: any): Prom
211220 if ( ! response . ok ) {
212221 throw new Error ( `Evaluation failed with status: ${ response . status } ` ) ;
213222 }
214-
223+
215224 const data = await response . json ( ) ;
216225 return data ;
217226 } catch ( error ) {
0 commit comments