feat: init project SelfChckout

This commit is contained in:
Luis Felipe Cadavid 2024-09-19 19:22:43 -05:00
parent 765cc0c7cf
commit 9d31ea245c
62 changed files with 8869 additions and 7149 deletions

View file

@ -0,0 +1 @@
export const BASE_URL_AUTHENTICATION = "/AUTHENTICATION-SERVICE/rhi-bpc/"

View file

@ -0,0 +1,32 @@
import { ReturnService } from "@package/config/ReturnService"
import i18n from "@package/utils/language/i18n"
const BASE_URL = process.env.NEXT_PUBLIC_API_URL
async function FetchData<T>(
BASE_URL_MODULE: string,
endpoint: string,
options: RequestInit = {}
): Promise<ReturnService<T>> {
const url = `${BASE_URL}${BASE_URL_MODULE}${endpoint}`
const text = i18n.t("errorProcessingAPI") as string
try {
const response = await fetch(url, options)
if (response.status === 403) {
const text = i18n.t("inCorrectAccess") as string
return new ReturnService<T>(null as unknown as T, false, text, 1)
}
if (!response.ok) {
return new ReturnService<T>(null as unknown as T, false, text, 1)
}
const data = await response.json()
return new ReturnService<T>(data as T)
} catch (error: any) {
return new ReturnService<T>(null as unknown as T, false, text || error.message, error.errorCode || 1)
}
}
export { FetchData }

View file

@ -0,0 +1,13 @@
export class ReturnService<T> {
correct: boolean
message: string
errorCode: number
object: T
constructor(object: T, correct = true, message = "", errorCode = 0) {
this.correct = correct
this.message = message
this.errorCode = errorCode
this.object = object
}
}