@yeverlibs/ds 1.1.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +266 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +266 -151
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,15 @@ import { clsx } from 'clsx';
|
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
3
|
import * as React107 from 'react';
|
|
4
4
|
import React107__default, { forwardRef, createContext, useState, useEffect, memo, useCallback, useContext, useRef, Suspense } from 'react';
|
|
5
|
-
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|
5
|
+
import { usePathname, useRouter, useSearchParams, redirect } from 'next/navigation';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import tw5 from 'tailwind-styled-components';
|
|
8
8
|
import Image4 from 'next/image';
|
|
9
9
|
import ReactDOM from 'react-dom';
|
|
10
10
|
import { toast } from 'sonner';
|
|
11
|
+
import { revalidatePath } from 'next/cache';
|
|
12
|
+
import { headers } from 'next/headers';
|
|
13
|
+
import Cookies from 'js-cookie';
|
|
11
14
|
import Select from 'react-select';
|
|
12
15
|
import { isValid, format, parse, startOfMonth, subMonths, endOfMonth, subDays, startOfDay, endOfDay, startOfWeek, endOfWeek, addDays, isWithinInterval, isSameDay, addMonths } from 'date-fns';
|
|
13
16
|
import { ptBR } from 'date-fns/locale';
|
|
@@ -17,7 +20,6 @@ import { AnimatePresence, motion } from 'framer-motion';
|
|
|
17
20
|
import { ResponsiveBar } from '@nivo/bar';
|
|
18
21
|
import { ResponsiveLine } from '@nivo/line';
|
|
19
22
|
import { ResponsivePie } from '@nivo/pie';
|
|
20
|
-
import Cookies from 'js-cookie';
|
|
21
23
|
import currency from 'currency.js';
|
|
22
24
|
|
|
23
25
|
// src/lib/utils.ts
|
|
@@ -4098,10 +4100,259 @@ async function handleFormSubmission({
|
|
|
4098
4100
|
}
|
|
4099
4101
|
return result;
|
|
4100
4102
|
}
|
|
4103
|
+
async function getCsrfToken() {
|
|
4104
|
+
const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "http://api.yever.local";
|
|
4105
|
+
const response = await fetch(`${baseURL}/sanctum/csrf-cookie`, {
|
|
4106
|
+
credentials: "include",
|
|
4107
|
+
headers: {
|
|
4108
|
+
"X-Requested-With": "XMLHttpRequest"
|
|
4109
|
+
}
|
|
4110
|
+
});
|
|
4111
|
+
if (!response.ok) {
|
|
4112
|
+
throw new Error("Falha ao obter token CSRF");
|
|
4113
|
+
}
|
|
4114
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
4115
|
+
}
|
|
4116
|
+
async function apiFetch(options) {
|
|
4117
|
+
const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "";
|
|
4118
|
+
const isAbsolute = /^https?:\/\//i.test(options.url);
|
|
4119
|
+
const url = isAbsolute ? options.url : `${baseURL}${options.url}`;
|
|
4120
|
+
const method = (options.method ?? "GET").toString().toLowerCase();
|
|
4121
|
+
const needsCSRFToken = ["post", "put", "delete"].includes(method);
|
|
4122
|
+
const hasCSRFCookie = Cookies.get("XSRF-TOKEN");
|
|
4123
|
+
if (needsCSRFToken && !hasCSRFCookie) {
|
|
4124
|
+
await getCsrfToken();
|
|
4125
|
+
}
|
|
4126
|
+
const defaultHeaders = {
|
|
4127
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
4128
|
+
Accept: "application/json"
|
|
4129
|
+
};
|
|
4130
|
+
if (!(options.body instanceof FormData)) {
|
|
4131
|
+
defaultHeaders["Content-Type"] = "application/json";
|
|
4132
|
+
}
|
|
4133
|
+
const finalHeaders = new Headers(defaultHeaders);
|
|
4134
|
+
if (options.headers) {
|
|
4135
|
+
if (options.headers instanceof Headers) {
|
|
4136
|
+
options.headers.forEach((v, k) => finalHeaders.set(k, v));
|
|
4137
|
+
} else {
|
|
4138
|
+
Object.entries(options.headers).forEach(([k, v]) => {
|
|
4139
|
+
if (v !== void 0) finalHeaders.set(k, v);
|
|
4140
|
+
});
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
const csrfToken = Cookies.get("XSRF-TOKEN");
|
|
4144
|
+
if (csrfToken) {
|
|
4145
|
+
finalHeaders.set("X-XSRF-TOKEN", csrfToken);
|
|
4146
|
+
}
|
|
4147
|
+
let finalOptions = options;
|
|
4148
|
+
if (options.body) {
|
|
4149
|
+
finalOptions = {
|
|
4150
|
+
...options,
|
|
4151
|
+
body: options.body instanceof FormData ? options.body : JSON.stringify(options.body)
|
|
4152
|
+
};
|
|
4153
|
+
}
|
|
4154
|
+
let response = await fetch(url, {
|
|
4155
|
+
credentials: "include",
|
|
4156
|
+
headers: finalHeaders,
|
|
4157
|
+
...finalOptions
|
|
4158
|
+
});
|
|
4159
|
+
if (response.status === 419) {
|
|
4160
|
+
Cookies.remove("XSRF-TOKEN");
|
|
4161
|
+
await getCsrfToken();
|
|
4162
|
+
const newToken = Cookies.get("XSRF-TOKEN");
|
|
4163
|
+
if (newToken) {
|
|
4164
|
+
finalHeaders.set("X-XSRF-TOKEN", newToken);
|
|
4165
|
+
}
|
|
4166
|
+
response = await fetch(url, {
|
|
4167
|
+
credentials: "include",
|
|
4168
|
+
headers: finalHeaders,
|
|
4169
|
+
...options
|
|
4170
|
+
});
|
|
4171
|
+
if (!response.ok) {
|
|
4172
|
+
Cookies.remove("XSRF-TOKEN");
|
|
4173
|
+
Cookies.remove("yeverClientUser");
|
|
4174
|
+
window.location.href = "/login";
|
|
4175
|
+
return Promise.reject(new Error("CSRF token expirado"));
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
const headers2 = {};
|
|
4179
|
+
response.headers.forEach((value, key) => {
|
|
4180
|
+
headers2[key] = value;
|
|
4181
|
+
});
|
|
4182
|
+
if (!response.ok) {
|
|
4183
|
+
const data2 = await response.json().catch(() => null);
|
|
4184
|
+
const errorMessage = typeof data2 === "object" && data2 !== null && "message" in data2 ? data2.message : "Request failed";
|
|
4185
|
+
const error = new Error(errorMessage);
|
|
4186
|
+
error.status = response.status;
|
|
4187
|
+
error.response = {
|
|
4188
|
+
data: data2,
|
|
4189
|
+
status: response.status
|
|
4190
|
+
};
|
|
4191
|
+
throw error;
|
|
4192
|
+
}
|
|
4193
|
+
let data = null;
|
|
4194
|
+
if (options.responseType === "blob") {
|
|
4195
|
+
data = await response.blob().catch(() => null);
|
|
4196
|
+
} else {
|
|
4197
|
+
data = await response.json().catch(() => null);
|
|
4198
|
+
}
|
|
4199
|
+
return {
|
|
4200
|
+
status: response.status,
|
|
4201
|
+
statusText: response.statusText,
|
|
4202
|
+
data,
|
|
4203
|
+
headers: headers2
|
|
4204
|
+
};
|
|
4205
|
+
}
|
|
4206
|
+
|
|
4207
|
+
// src/utils/parse-parameters-into-url/index.tsx
|
|
4208
|
+
var parseParametersIntoUrl = (url, query, filtersAllowed) => {
|
|
4209
|
+
let urlFiltered = url;
|
|
4210
|
+
for (const key in query) {
|
|
4211
|
+
if (query && Object.keys(query).length > 0) {
|
|
4212
|
+
urlFiltered = urlFiltered.replace(`/${key}/`, `/${query[key]}/`);
|
|
4213
|
+
urlFiltered = urlFiltered.replace(`/${key}`, `/${query[key]}`);
|
|
4214
|
+
if (filtersAllowed && filtersAllowed.includes(key)) {
|
|
4215
|
+
if (urlFiltered.includes("?")) {
|
|
4216
|
+
if (key === "searchNew") {
|
|
4217
|
+
urlFiltered = urlFiltered + `&${key}=${atob(query[key])}`;
|
|
4218
|
+
} else {
|
|
4219
|
+
urlFiltered = urlFiltered + `&${key}=${query[key]}`;
|
|
4220
|
+
}
|
|
4221
|
+
} else {
|
|
4222
|
+
if (key === "searchNew") {
|
|
4223
|
+
urlFiltered = urlFiltered + `?${key}=${atob(query[key])}`;
|
|
4224
|
+
} else {
|
|
4225
|
+
urlFiltered = urlFiltered + `?${key}=${query[key]}`;
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
return urlFiltered;
|
|
4232
|
+
};
|
|
4233
|
+
|
|
4234
|
+
// src/lib/fetch-server-side/index.ts
|
|
4235
|
+
var fetchServerSide = async ({
|
|
4236
|
+
urlRequest,
|
|
4237
|
+
parseData,
|
|
4238
|
+
filtersAllowed,
|
|
4239
|
+
method = "GET",
|
|
4240
|
+
body
|
|
4241
|
+
}) => {
|
|
4242
|
+
"use server";
|
|
4243
|
+
try {
|
|
4244
|
+
const headersObject = Object.fromEntries((await headers()).entries());
|
|
4245
|
+
const searchParams = new URLSearchParams(headersObject.referer ? new URL(headersObject.referer).search : "");
|
|
4246
|
+
const query = Array.from(searchParams.entries()).reduce((acc, [key, value]) => {
|
|
4247
|
+
acc[key] = value;
|
|
4248
|
+
return acc;
|
|
4249
|
+
}, {});
|
|
4250
|
+
const url = parseParametersIntoUrl(urlRequest, query, filtersAllowed);
|
|
4251
|
+
const origin = headersObject.host;
|
|
4252
|
+
const cookie = headersObject.cookie;
|
|
4253
|
+
const xsrfToken = cookie?.match(/XSRF-TOKEN=([^;]+)/)?.[1];
|
|
4254
|
+
const requestHeaders = {
|
|
4255
|
+
Cookie: cookie,
|
|
4256
|
+
origin
|
|
4257
|
+
};
|
|
4258
|
+
if (xsrfToken) {
|
|
4259
|
+
requestHeaders["X-XSRF-TOKEN"] = decodeURIComponent(xsrfToken);
|
|
4260
|
+
}
|
|
4261
|
+
let pagination;
|
|
4262
|
+
const res = await apiFetch({
|
|
4263
|
+
url,
|
|
4264
|
+
method,
|
|
4265
|
+
body,
|
|
4266
|
+
headers: requestHeaders,
|
|
4267
|
+
cache: "no-store"
|
|
4268
|
+
});
|
|
4269
|
+
if (res?.data && typeof res.data === "object" && "paginate" in res.data) {
|
|
4270
|
+
pagination = res.data.paginate;
|
|
4271
|
+
}
|
|
4272
|
+
const parsedData = parseData ? parseData(res) : res;
|
|
4273
|
+
return {
|
|
4274
|
+
props: {
|
|
4275
|
+
pagination,
|
|
4276
|
+
data: parsedData
|
|
4277
|
+
}
|
|
4278
|
+
};
|
|
4279
|
+
} catch (error) {
|
|
4280
|
+
const apiError = error;
|
|
4281
|
+
switch (apiError.response?.status) {
|
|
4282
|
+
case 401:
|
|
4283
|
+
redirect("/login");
|
|
4284
|
+
case 403:
|
|
4285
|
+
return {
|
|
4286
|
+
props: {
|
|
4287
|
+
error: {
|
|
4288
|
+
status: 403,
|
|
4289
|
+
message: "Voc\xEA n\xE3o tem permiss\xE3o para executar essa a\xE7\xE3o",
|
|
4290
|
+
errors: {}
|
|
4291
|
+
},
|
|
4292
|
+
data: null
|
|
4293
|
+
}
|
|
4294
|
+
};
|
|
4295
|
+
case 404:
|
|
4296
|
+
return {
|
|
4297
|
+
props: {
|
|
4298
|
+
error: {
|
|
4299
|
+
status: 404,
|
|
4300
|
+
message: apiError.response.data?.message || "Recurso n\xE3o encontrado",
|
|
4301
|
+
errors: apiError.response?.data?.errors || {}
|
|
4302
|
+
},
|
|
4303
|
+
data: null
|
|
4304
|
+
}
|
|
4305
|
+
};
|
|
4306
|
+
case 422:
|
|
4307
|
+
return {
|
|
4308
|
+
props: {
|
|
4309
|
+
error: {
|
|
4310
|
+
status: 422,
|
|
4311
|
+
message: apiError.response.data?.message || "Erro de valida\xE7\xE3o",
|
|
4312
|
+
errors: apiError.response?.data?.errors
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
};
|
|
4316
|
+
case 500:
|
|
4317
|
+
return {
|
|
4318
|
+
props: {
|
|
4319
|
+
error: {
|
|
4320
|
+
status: 500,
|
|
4321
|
+
message: apiError.response.data?.message || "Ocorreu um erro durante o processamento dessa requisi\xE7\xE3o. A Yever foi notificada e estamos atuando para sanar o problema.",
|
|
4322
|
+
errors: {}
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4325
|
+
};
|
|
4326
|
+
default:
|
|
4327
|
+
if (apiError.response?.data?.errors || apiError.response?.data?.message) {
|
|
4328
|
+
return {
|
|
4329
|
+
props: {
|
|
4330
|
+
error: {
|
|
4331
|
+
status: apiError.response.status,
|
|
4332
|
+
message: apiError.response.data?.message,
|
|
4333
|
+
errors: apiError.response.data?.errors
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
};
|
|
4337
|
+
}
|
|
4338
|
+
redirect("/500");
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
};
|
|
4342
|
+
|
|
4343
|
+
// src/_design-system/delete-modal/_actions/index.ts
|
|
4344
|
+
async function deleteFunc(endpoint, location) {
|
|
4345
|
+
const response = await fetchServerSide({
|
|
4346
|
+
urlRequest: endpoint,
|
|
4347
|
+
method: "DELETE"
|
|
4348
|
+
});
|
|
4349
|
+
revalidatePath(location);
|
|
4350
|
+
return response;
|
|
4351
|
+
}
|
|
4101
4352
|
var DeleteModal = ({
|
|
4102
4353
|
isModalOpen,
|
|
4103
4354
|
setIsModalOpen,
|
|
4104
|
-
|
|
4355
|
+
endpoint,
|
|
4105
4356
|
successMessage,
|
|
4106
4357
|
location,
|
|
4107
4358
|
title,
|
|
@@ -4111,13 +4362,9 @@ var DeleteModal = ({
|
|
|
4111
4362
|
const [loading, setLoading] = useState(false);
|
|
4112
4363
|
const router = useRouter();
|
|
4113
4364
|
const handleSubmit = async () => {
|
|
4114
|
-
if (!onDelete) {
|
|
4115
|
-
console.error("DeleteModal: onDelete function is required");
|
|
4116
|
-
return;
|
|
4117
|
-
}
|
|
4118
4365
|
setLoading(true);
|
|
4119
4366
|
await handleFormSubmission({
|
|
4120
|
-
customAction:
|
|
4367
|
+
customAction: () => deleteFunc(endpoint, location),
|
|
4121
4368
|
successMessages: {
|
|
4122
4369
|
custom: successMessage || "Item deletado com sucesso"
|
|
4123
4370
|
},
|
|
@@ -4125,7 +4372,7 @@ var DeleteModal = ({
|
|
|
4125
4372
|
setIsModalOpen(false);
|
|
4126
4373
|
if (onSuccess) {
|
|
4127
4374
|
onSuccess();
|
|
4128
|
-
} else
|
|
4375
|
+
} else {
|
|
4129
4376
|
router.push(location);
|
|
4130
4377
|
}
|
|
4131
4378
|
}
|
|
@@ -6536,15 +6783,15 @@ var TableContent = ({
|
|
|
6536
6783
|
var Table = (props) => {
|
|
6537
6784
|
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(TableContent, { ...props }) });
|
|
6538
6785
|
};
|
|
6539
|
-
var Tabs = ({ headers, children, noGap, active, alignDiv = "full" }) => {
|
|
6786
|
+
var Tabs = ({ headers: headers2, children, noGap, active, alignDiv = "full" }) => {
|
|
6540
6787
|
const [activeTab, setActiveTab] = useState(active || 0);
|
|
6541
|
-
const flattenHeaders = (
|
|
6542
|
-
if (Array.isArray(
|
|
6543
|
-
return
|
|
6788
|
+
const flattenHeaders = (headers3) => {
|
|
6789
|
+
if (Array.isArray(headers3[0])) {
|
|
6790
|
+
return headers3.flat();
|
|
6544
6791
|
}
|
|
6545
|
-
return
|
|
6792
|
+
return headers3;
|
|
6546
6793
|
};
|
|
6547
|
-
const flattenedHeaders = flattenHeaders(
|
|
6794
|
+
const flattenedHeaders = flattenHeaders(headers2);
|
|
6548
6795
|
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col", noGap ? "" : "gap-4"), children: [
|
|
6549
6796
|
/* @__PURE__ */ jsx("div", { className: "flex gap-4 overflow-x-auto overflow-y-hidden border-b border-gray-300", children: flattenedHeaders.map((header, index) => /* @__PURE__ */ jsx(
|
|
6550
6797
|
"button",
|
|
@@ -8065,138 +8312,6 @@ var PieChart = ({
|
|
|
8065
8312
|
}
|
|
8066
8313
|
);
|
|
8067
8314
|
};
|
|
8068
|
-
async function getCsrfToken() {
|
|
8069
|
-
const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "http://api.yever.local";
|
|
8070
|
-
const response = await fetch(`${baseURL}/sanctum/csrf-cookie`, {
|
|
8071
|
-
credentials: "include",
|
|
8072
|
-
headers: {
|
|
8073
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
8074
|
-
}
|
|
8075
|
-
});
|
|
8076
|
-
if (!response.ok) {
|
|
8077
|
-
throw new Error("Falha ao obter token CSRF");
|
|
8078
|
-
}
|
|
8079
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
8080
|
-
}
|
|
8081
|
-
async function apiFetch(options) {
|
|
8082
|
-
const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "";
|
|
8083
|
-
const isAbsolute = /^https?:\/\//i.test(options.url);
|
|
8084
|
-
const url = isAbsolute ? options.url : `${baseURL}${options.url}`;
|
|
8085
|
-
const method = (options.method ?? "GET").toString().toLowerCase();
|
|
8086
|
-
const needsCSRFToken = ["post", "put", "delete"].includes(method);
|
|
8087
|
-
const hasCSRFCookie = Cookies.get("XSRF-TOKEN");
|
|
8088
|
-
if (needsCSRFToken && !hasCSRFCookie) {
|
|
8089
|
-
await getCsrfToken();
|
|
8090
|
-
}
|
|
8091
|
-
const defaultHeaders = {
|
|
8092
|
-
"X-Requested-With": "XMLHttpRequest",
|
|
8093
|
-
Accept: "application/json"
|
|
8094
|
-
};
|
|
8095
|
-
if (!(options.body instanceof FormData)) {
|
|
8096
|
-
defaultHeaders["Content-Type"] = "application/json";
|
|
8097
|
-
}
|
|
8098
|
-
const finalHeaders = new Headers(defaultHeaders);
|
|
8099
|
-
if (options.headers) {
|
|
8100
|
-
if (options.headers instanceof Headers) {
|
|
8101
|
-
options.headers.forEach((v, k) => finalHeaders.set(k, v));
|
|
8102
|
-
} else {
|
|
8103
|
-
Object.entries(options.headers).forEach(([k, v]) => {
|
|
8104
|
-
if (v !== void 0) finalHeaders.set(k, v);
|
|
8105
|
-
});
|
|
8106
|
-
}
|
|
8107
|
-
}
|
|
8108
|
-
const csrfToken = Cookies.get("XSRF-TOKEN");
|
|
8109
|
-
if (csrfToken) {
|
|
8110
|
-
finalHeaders.set("X-XSRF-TOKEN", csrfToken);
|
|
8111
|
-
}
|
|
8112
|
-
let finalOptions = options;
|
|
8113
|
-
if (options.body) {
|
|
8114
|
-
finalOptions = {
|
|
8115
|
-
...options,
|
|
8116
|
-
body: options.body instanceof FormData ? options.body : JSON.stringify(options.body)
|
|
8117
|
-
};
|
|
8118
|
-
}
|
|
8119
|
-
let response = await fetch(url, {
|
|
8120
|
-
credentials: "include",
|
|
8121
|
-
headers: finalHeaders,
|
|
8122
|
-
...finalOptions
|
|
8123
|
-
});
|
|
8124
|
-
if (response.status === 419) {
|
|
8125
|
-
Cookies.remove("XSRF-TOKEN");
|
|
8126
|
-
await getCsrfToken();
|
|
8127
|
-
const newToken = Cookies.get("XSRF-TOKEN");
|
|
8128
|
-
if (newToken) {
|
|
8129
|
-
finalHeaders.set("X-XSRF-TOKEN", newToken);
|
|
8130
|
-
}
|
|
8131
|
-
response = await fetch(url, {
|
|
8132
|
-
credentials: "include",
|
|
8133
|
-
headers: finalHeaders,
|
|
8134
|
-
...options
|
|
8135
|
-
});
|
|
8136
|
-
if (!response.ok) {
|
|
8137
|
-
Cookies.remove("XSRF-TOKEN");
|
|
8138
|
-
Cookies.remove("yeverClientUser");
|
|
8139
|
-
window.location.href = "/login";
|
|
8140
|
-
return Promise.reject(new Error("CSRF token expirado"));
|
|
8141
|
-
}
|
|
8142
|
-
}
|
|
8143
|
-
const headers = {};
|
|
8144
|
-
response.headers.forEach((value, key) => {
|
|
8145
|
-
headers[key] = value;
|
|
8146
|
-
});
|
|
8147
|
-
if (!response.ok) {
|
|
8148
|
-
const data2 = await response.json().catch(() => null);
|
|
8149
|
-
const errorMessage = typeof data2 === "object" && data2 !== null && "message" in data2 ? data2.message : "Request failed";
|
|
8150
|
-
const error = new Error(errorMessage);
|
|
8151
|
-
error.status = response.status;
|
|
8152
|
-
error.response = {
|
|
8153
|
-
data: data2,
|
|
8154
|
-
status: response.status
|
|
8155
|
-
};
|
|
8156
|
-
throw error;
|
|
8157
|
-
}
|
|
8158
|
-
let data = null;
|
|
8159
|
-
if (options.responseType === "blob") {
|
|
8160
|
-
data = await response.blob().catch(() => null);
|
|
8161
|
-
} else {
|
|
8162
|
-
data = await response.json().catch(() => null);
|
|
8163
|
-
}
|
|
8164
|
-
return {
|
|
8165
|
-
status: response.status,
|
|
8166
|
-
statusText: response.statusText,
|
|
8167
|
-
data,
|
|
8168
|
-
headers
|
|
8169
|
-
};
|
|
8170
|
-
}
|
|
8171
|
-
|
|
8172
|
-
// src/utils/parse-parameters-into-url/index.tsx
|
|
8173
|
-
var parseParametersIntoUrl = (url, query, filtersAllowed) => {
|
|
8174
|
-
let urlFiltered = url;
|
|
8175
|
-
for (const key in query) {
|
|
8176
|
-
if (query && Object.keys(query).length > 0) {
|
|
8177
|
-
urlFiltered = urlFiltered.replace(`/${key}/`, `/${query[key]}/`);
|
|
8178
|
-
urlFiltered = urlFiltered.replace(`/${key}`, `/${query[key]}`);
|
|
8179
|
-
if (filtersAllowed && filtersAllowed.includes(key)) {
|
|
8180
|
-
if (urlFiltered.includes("?")) {
|
|
8181
|
-
if (key === "searchNew") {
|
|
8182
|
-
urlFiltered = urlFiltered + `&${key}=${atob(query[key])}`;
|
|
8183
|
-
} else {
|
|
8184
|
-
urlFiltered = urlFiltered + `&${key}=${query[key]}`;
|
|
8185
|
-
}
|
|
8186
|
-
} else {
|
|
8187
|
-
if (key === "searchNew") {
|
|
8188
|
-
urlFiltered = urlFiltered + `?${key}=${atob(query[key])}`;
|
|
8189
|
-
} else {
|
|
8190
|
-
urlFiltered = urlFiltered + `?${key}=${query[key]}`;
|
|
8191
|
-
}
|
|
8192
|
-
}
|
|
8193
|
-
}
|
|
8194
|
-
}
|
|
8195
|
-
}
|
|
8196
|
-
return urlFiltered;
|
|
8197
|
-
};
|
|
8198
|
-
|
|
8199
|
-
// src/hooks/use-fetch-client-side/index.tsx
|
|
8200
8315
|
var noopLoading = {
|
|
8201
8316
|
loadingActions: {
|
|
8202
8317
|
setLoading: () => {
|
|
@@ -8257,22 +8372,22 @@ function useFetchClientSide({
|
|
|
8257
8372
|
if (body instanceof FormData) {
|
|
8258
8373
|
delete configHeaders["Content-Type"];
|
|
8259
8374
|
}
|
|
8260
|
-
const
|
|
8375
|
+
const headers2 = {
|
|
8261
8376
|
"X-Requested-With": "XMLHttpRequest",
|
|
8262
8377
|
Accept: "application/json",
|
|
8263
8378
|
...configHeaders
|
|
8264
8379
|
};
|
|
8265
8380
|
if (body && !(body instanceof FormData)) {
|
|
8266
|
-
|
|
8381
|
+
headers2["Content-Type"] = "application/json";
|
|
8267
8382
|
}
|
|
8268
8383
|
if (csrfToken) {
|
|
8269
|
-
|
|
8384
|
+
headers2["X-XSRF-TOKEN"] = decodeURIComponent(csrfToken);
|
|
8270
8385
|
}
|
|
8271
8386
|
const response = await apiFetch({
|
|
8272
8387
|
url: customUrl || urlFiltered,
|
|
8273
8388
|
method: customMethod || method,
|
|
8274
8389
|
body,
|
|
8275
|
-
headers,
|
|
8390
|
+
headers: headers2,
|
|
8276
8391
|
credentials: "include",
|
|
8277
8392
|
signal,
|
|
8278
8393
|
responseType: config?.responseType
|