ptechcore_ui 1.0.68 → 1.0.70

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.cjs CHANGED
@@ -142,8 +142,10 @@ __export(index_exports, {
142
142
  SelectClient: () => SelectClient,
143
143
  SelectCostCenter: () => SelectCostCenter,
144
144
  SelectCountry: () => SelectCountry,
145
+ SelectDas: () => SelectDas,
145
146
  SelectDepartment: () => SelectDepartment,
146
147
  SelectInput: () => SelectInput,
148
+ SelectLeadNeed: () => SelectLeadNeed,
147
149
  SelectLegalForm: () => SelectLegalForm,
148
150
  SelectUnit: () => SelectUnit,
149
151
  SelectUser: () => SelectUser,
@@ -1117,341 +1119,8 @@ var VendorServices = {
1117
1119
  delete: (id) => FetchApi.delete(`${VENDORS_API_URL}${id}/`)
1118
1120
  };
1119
1121
 
1120
- // node_modules/react-router/dist/index.js
1121
- var React2 = __toESM(require("react"));
1122
-
1123
- // node_modules/@remix-run/router/dist/router.js
1124
- function _extends() {
1125
- _extends = Object.assign ? Object.assign.bind() : function(target) {
1126
- for (var i = 1; i < arguments.length; i++) {
1127
- var source = arguments[i];
1128
- for (var key in source) {
1129
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1130
- target[key] = source[key];
1131
- }
1132
- }
1133
- }
1134
- return target;
1135
- };
1136
- return _extends.apply(this, arguments);
1137
- }
1138
- var Action;
1139
- (function(Action2) {
1140
- Action2["Pop"] = "POP";
1141
- Action2["Push"] = "PUSH";
1142
- Action2["Replace"] = "REPLACE";
1143
- })(Action || (Action = {}));
1144
- function invariant(value, message) {
1145
- if (value === false || value === null || typeof value === "undefined") {
1146
- throw new Error(message);
1147
- }
1148
- }
1149
- function warning(cond, message) {
1150
- if (!cond) {
1151
- if (typeof console !== "undefined") console.warn(message);
1152
- try {
1153
- throw new Error(message);
1154
- } catch (e) {
1155
- }
1156
- }
1157
- }
1158
- function parsePath(path) {
1159
- let parsedPath = {};
1160
- if (path) {
1161
- let hashIndex = path.indexOf("#");
1162
- if (hashIndex >= 0) {
1163
- parsedPath.hash = path.substr(hashIndex);
1164
- path = path.substr(0, hashIndex);
1165
- }
1166
- let searchIndex = path.indexOf("?");
1167
- if (searchIndex >= 0) {
1168
- parsedPath.search = path.substr(searchIndex);
1169
- path = path.substr(0, searchIndex);
1170
- }
1171
- if (path) {
1172
- parsedPath.pathname = path;
1173
- }
1174
- }
1175
- return parsedPath;
1176
- }
1177
- var ResultType;
1178
- (function(ResultType2) {
1179
- ResultType2["data"] = "data";
1180
- ResultType2["deferred"] = "deferred";
1181
- ResultType2["redirect"] = "redirect";
1182
- ResultType2["error"] = "error";
1183
- })(ResultType || (ResultType = {}));
1184
- function resolvePath(to, fromPathname) {
1185
- if (fromPathname === void 0) {
1186
- fromPathname = "/";
1187
- }
1188
- let {
1189
- pathname: toPathname,
1190
- search = "",
1191
- hash = ""
1192
- } = typeof to === "string" ? parsePath(to) : to;
1193
- let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
1194
- return {
1195
- pathname,
1196
- search: normalizeSearch(search),
1197
- hash: normalizeHash(hash)
1198
- };
1199
- }
1200
- function resolvePathname(relativePath, fromPathname) {
1201
- let segments = fromPathname.replace(/\/+$/, "").split("/");
1202
- let relativeSegments = relativePath.split("/");
1203
- relativeSegments.forEach((segment) => {
1204
- if (segment === "..") {
1205
- if (segments.length > 1) segments.pop();
1206
- } else if (segment !== ".") {
1207
- segments.push(segment);
1208
- }
1209
- });
1210
- return segments.length > 1 ? segments.join("/") : "/";
1211
- }
1212
- function getInvalidPathError(char, field, dest, path) {
1213
- return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
1214
- }
1215
- function getPathContributingMatches(matches) {
1216
- return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
1217
- }
1218
- function getResolveToMatches(matches, v7_relativeSplatPath) {
1219
- let pathMatches = getPathContributingMatches(matches);
1220
- if (v7_relativeSplatPath) {
1221
- return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
1222
- }
1223
- return pathMatches.map((match) => match.pathnameBase);
1224
- }
1225
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
1226
- if (isPathRelative === void 0) {
1227
- isPathRelative = false;
1228
- }
1229
- let to;
1230
- if (typeof toArg === "string") {
1231
- to = parsePath(toArg);
1232
- } else {
1233
- to = _extends({}, toArg);
1234
- invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
1235
- invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
1236
- invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
1237
- }
1238
- let isEmptyPath = toArg === "" || to.pathname === "";
1239
- let toPathname = isEmptyPath ? "/" : to.pathname;
1240
- let from;
1241
- if (toPathname == null) {
1242
- from = locationPathname;
1243
- } else {
1244
- let routePathnameIndex = routePathnames.length - 1;
1245
- if (!isPathRelative && toPathname.startsWith("..")) {
1246
- let toSegments = toPathname.split("/");
1247
- while (toSegments[0] === "..") {
1248
- toSegments.shift();
1249
- routePathnameIndex -= 1;
1250
- }
1251
- to.pathname = toSegments.join("/");
1252
- }
1253
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
1254
- }
1255
- let path = resolvePath(to, from);
1256
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
1257
- let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
1258
- if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
1259
- path.pathname += "/";
1260
- }
1261
- return path;
1262
- }
1263
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
1264
- var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
1265
- var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
1266
- var validMutationMethodsArr = ["post", "put", "patch", "delete"];
1267
- var validMutationMethods = new Set(validMutationMethodsArr);
1268
- var validRequestMethodsArr = ["get", ...validMutationMethodsArr];
1269
- var validRequestMethods = new Set(validRequestMethodsArr);
1270
- var UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
1271
-
1272
- // node_modules/react-router/dist/index.js
1273
- function _extends2() {
1274
- _extends2 = Object.assign ? Object.assign.bind() : function(target) {
1275
- for (var i = 1; i < arguments.length; i++) {
1276
- var source = arguments[i];
1277
- for (var key in source) {
1278
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1279
- target[key] = source[key];
1280
- }
1281
- }
1282
- }
1283
- return target;
1284
- };
1285
- return _extends2.apply(this, arguments);
1286
- }
1287
- var DataRouterContext = /* @__PURE__ */ React2.createContext(null);
1288
- if (process.env.NODE_ENV !== "production") {
1289
- DataRouterContext.displayName = "DataRouter";
1290
- }
1291
- var DataRouterStateContext = /* @__PURE__ */ React2.createContext(null);
1292
- if (process.env.NODE_ENV !== "production") {
1293
- DataRouterStateContext.displayName = "DataRouterState";
1294
- }
1295
- var AwaitContext = /* @__PURE__ */ React2.createContext(null);
1296
- if (process.env.NODE_ENV !== "production") {
1297
- AwaitContext.displayName = "Await";
1298
- }
1299
- var NavigationContext = /* @__PURE__ */ React2.createContext(null);
1300
- if (process.env.NODE_ENV !== "production") {
1301
- NavigationContext.displayName = "Navigation";
1302
- }
1303
- var LocationContext = /* @__PURE__ */ React2.createContext(null);
1304
- if (process.env.NODE_ENV !== "production") {
1305
- LocationContext.displayName = "Location";
1306
- }
1307
- var RouteContext = /* @__PURE__ */ React2.createContext({
1308
- outlet: null,
1309
- matches: [],
1310
- isDataRoute: false
1311
- });
1312
- if (process.env.NODE_ENV !== "production") {
1313
- RouteContext.displayName = "Route";
1314
- }
1315
- var RouteErrorContext = /* @__PURE__ */ React2.createContext(null);
1316
- if (process.env.NODE_ENV !== "production") {
1317
- RouteErrorContext.displayName = "RouteError";
1318
- }
1319
- function useInRouterContext() {
1320
- return React2.useContext(LocationContext) != null;
1321
- }
1322
- function useLocation() {
1323
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
1324
- false,
1325
- // TODO: This error is probably because they somehow have 2 versions of the
1326
- // router loaded. We can help them understand how to avoid that.
1327
- "useLocation() may be used only in the context of a <Router> component."
1328
- ) : invariant(false) : void 0;
1329
- return React2.useContext(LocationContext).location;
1330
- }
1331
- var navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
1332
- function useIsomorphicLayoutEffect(cb) {
1333
- let isStatic = React2.useContext(NavigationContext).static;
1334
- if (!isStatic) {
1335
- React2.useLayoutEffect(cb);
1336
- }
1337
- }
1338
- function useNavigate() {
1339
- let {
1340
- isDataRoute
1341
- } = React2.useContext(RouteContext);
1342
- return isDataRoute ? useNavigateStable() : useNavigateUnstable();
1343
- }
1344
- function useNavigateUnstable() {
1345
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
1346
- false,
1347
- // TODO: This error is probably because they somehow have 2 versions of the
1348
- // router loaded. We can help them understand how to avoid that.
1349
- "useNavigate() may be used only in the context of a <Router> component."
1350
- ) : invariant(false) : void 0;
1351
- let dataRouterContext = React2.useContext(DataRouterContext);
1352
- let {
1353
- basename,
1354
- future,
1355
- navigator: navigator2
1356
- } = React2.useContext(NavigationContext);
1357
- let {
1358
- matches
1359
- } = React2.useContext(RouteContext);
1360
- let {
1361
- pathname: locationPathname
1362
- } = useLocation();
1363
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
1364
- let activeRef = React2.useRef(false);
1365
- useIsomorphicLayoutEffect(() => {
1366
- activeRef.current = true;
1367
- });
1368
- let navigate = React2.useCallback(function(to, options) {
1369
- if (options === void 0) {
1370
- options = {};
1371
- }
1372
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
1373
- if (!activeRef.current) return;
1374
- if (typeof to === "number") {
1375
- navigator2.go(to);
1376
- return;
1377
- }
1378
- let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
1379
- if (dataRouterContext == null && basename !== "/") {
1380
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
1381
- }
1382
- (!!options.replace ? navigator2.replace : navigator2.push)(path, options.state, options);
1383
- }, [basename, navigator2, routePathnamesJson, locationPathname, dataRouterContext]);
1384
- return navigate;
1385
- }
1386
- var DataRouterHook = /* @__PURE__ */ (function(DataRouterHook2) {
1387
- DataRouterHook2["UseBlocker"] = "useBlocker";
1388
- DataRouterHook2["UseRevalidator"] = "useRevalidator";
1389
- DataRouterHook2["UseNavigateStable"] = "useNavigate";
1390
- return DataRouterHook2;
1391
- })(DataRouterHook || {});
1392
- var DataRouterStateHook = /* @__PURE__ */ (function(DataRouterStateHook2) {
1393
- DataRouterStateHook2["UseBlocker"] = "useBlocker";
1394
- DataRouterStateHook2["UseLoaderData"] = "useLoaderData";
1395
- DataRouterStateHook2["UseActionData"] = "useActionData";
1396
- DataRouterStateHook2["UseRouteError"] = "useRouteError";
1397
- DataRouterStateHook2["UseNavigation"] = "useNavigation";
1398
- DataRouterStateHook2["UseRouteLoaderData"] = "useRouteLoaderData";
1399
- DataRouterStateHook2["UseMatches"] = "useMatches";
1400
- DataRouterStateHook2["UseRevalidator"] = "useRevalidator";
1401
- DataRouterStateHook2["UseNavigateStable"] = "useNavigate";
1402
- DataRouterStateHook2["UseRouteId"] = "useRouteId";
1403
- return DataRouterStateHook2;
1404
- })(DataRouterStateHook || {});
1405
- function getDataRouterConsoleError(hookName) {
1406
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
1407
- }
1408
- function useDataRouterContext(hookName) {
1409
- let ctx = React2.useContext(DataRouterContext);
1410
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
1411
- return ctx;
1412
- }
1413
- function useRouteContext(hookName) {
1414
- let route = React2.useContext(RouteContext);
1415
- !route ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
1416
- return route;
1417
- }
1418
- function useCurrentRouteId(hookName) {
1419
- let route = useRouteContext(hookName);
1420
- let thisRoute = route.matches[route.matches.length - 1];
1421
- !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
1422
- return thisRoute.route.id;
1423
- }
1424
- function useNavigateStable() {
1425
- let {
1426
- router
1427
- } = useDataRouterContext(DataRouterHook.UseNavigateStable);
1428
- let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
1429
- let activeRef = React2.useRef(false);
1430
- useIsomorphicLayoutEffect(() => {
1431
- activeRef.current = true;
1432
- });
1433
- let navigate = React2.useCallback(function(to, options) {
1434
- if (options === void 0) {
1435
- options = {};
1436
- }
1437
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
1438
- if (!activeRef.current) return;
1439
- if (typeof to === "number") {
1440
- router.navigate(to);
1441
- } else {
1442
- router.navigate(to, _extends2({
1443
- fromRouteId: id
1444
- }, options));
1445
- }
1446
- }, [router, id]);
1447
- return navigate;
1448
- }
1449
- var START_TRANSITION = "startTransition";
1450
- var startTransitionImpl = React2[START_TRANSITION];
1451
- var neverSettledPromise = new Promise(() => {
1452
- });
1453
-
1454
1122
  // src/contexts/SessionContext.tsx
1123
+ var import_react_router = require("react-router");
1455
1124
  var import_jsx_runtime5 = require("react/jsx-runtime");
1456
1125
  var SessionContext = (0, import_react2.createContext)(void 0);
1457
1126
  var useSession = () => {
@@ -1468,7 +1137,7 @@ var SessionProvider = ({ children }) => {
1468
1137
  const saved_center_id = localStorage.getItem("active_center_id") || "";
1469
1138
  const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
1470
1139
  const [showAuthModal, setShowAuthModal] = (0, import_react2.useState)(false);
1471
- const navigate = useNavigate();
1140
+ const navigate = (0, import_react_router.useNavigate)();
1472
1141
  (0, import_react2.useEffect)(() => {
1473
1142
  const initializeSession = async () => {
1474
1143
  const params = new URLSearchParams(window.location.search);
@@ -1699,7 +1368,7 @@ var ToastProvider = ({ children }) => {
1699
1368
  const error = (0, import_react3.useCallback)((message, duration) => {
1700
1369
  addToast({ message, type: "error", duration });
1701
1370
  }, [addToast]);
1702
- const warning2 = (0, import_react3.useCallback)((message, duration) => {
1371
+ const warning = (0, import_react3.useCallback)((message, duration) => {
1703
1372
  addToast({ message, type: "warning", duration });
1704
1373
  }, [addToast]);
1705
1374
  const info = (0, import_react3.useCallback)((message, duration) => {
@@ -1731,7 +1400,7 @@ var ToastProvider = ({ children }) => {
1731
1400
  removeToast,
1732
1401
  success,
1733
1402
  error,
1734
- warning: warning2,
1403
+ warning,
1735
1404
  info,
1736
1405
  confirm: confirm2
1737
1406
  };
@@ -1835,12 +1504,12 @@ var ApprovalServices = {
1835
1504
  /**
1836
1505
  * Obtenir les détails d'un cas d'approbation par process et object_id
1837
1506
  */
1838
- getDetails: (process2, object_id, token) => FetchApi.get(`${APPROVAL_API_URL}details/?process=${process2}&object_id=${object_id}`, token),
1507
+ getDetails: (process, object_id, token) => FetchApi.get(`${APPROVAL_API_URL}details/?process=${process}&object_id=${object_id}`, token),
1839
1508
  getAnswerDetails: (link_token) => FetchApi.get(`${APPROVAL_API_URL}answers/?link_token=${link_token}`),
1840
1509
  /**
1841
1510
  * Obtenir l'historique des versions d'un cas d'approbation
1842
1511
  */
1843
- getHistory: (process2, object_id, token) => FetchApi.get(`${APPROVAL_API_URL}history/?process=${process2}&object_id=${object_id}`, token),
1512
+ getHistory: (process, object_id, token) => FetchApi.get(`${APPROVAL_API_URL}history/?process=${process}&object_id=${object_id}`, token),
1844
1513
  /**
1845
1514
  * Mettre à jour un cas d'approbation
1846
1515
  */
@@ -5685,6 +5354,26 @@ var CostServices = {
5685
5354
  };
5686
5355
  var PROFIT_URI = `${API_URL}/accounting/profit-center/`;
5687
5356
 
5357
+ // src/services/CrmServices.ts
5358
+ var TARGET_RETAILER_URI = `${API_URL}/crm/target-retailers/`;
5359
+ var DAS_URI = `${API_URL}/crm/das/`;
5360
+ var DasServices = {
5361
+ create: (data) => FetchApi.post(`${DAS_URI}`, data),
5362
+ get: (id) => FetchApi.get(`${DAS_URI}${id}/`),
5363
+ list: (params) => FetchApi.get(`${DAS_URI}?${new URLSearchParams(params).toString()}`),
5364
+ update: (id, data) => FetchApi.put(`${DAS_URI}${id}/`, data),
5365
+ delete: (id) => FetchApi.delete(`${DAS_URI}${id}/`)
5366
+ };
5367
+ var OTHER_COST_URI = `${API_URL}/crm/other-costs/`;
5368
+ var LEAD_NEED_URI = `${API_URL}/crm/lead-needs/`;
5369
+ var LeadNeedServices = {
5370
+ create: (data) => FetchApi.post(`${LEAD_NEED_URI}`, data),
5371
+ get: (id) => FetchApi.get(`${LEAD_NEED_URI}${id}/`),
5372
+ list: (params) => FetchApi.get(`${LEAD_NEED_URI}?${new URLSearchParams(params).toString()}`),
5373
+ update: (id, data) => FetchApi.put(`${LEAD_NEED_URI}${id}/`, data),
5374
+ delete: (id) => FetchApi.delete(`${LEAD_NEED_URI}${id}/`)
5375
+ };
5376
+
5688
5377
  // src/components/common/CommonSelect.tsx
5689
5378
  var import_jsx_runtime16 = require("react/jsx-runtime");
5690
5379
  var SelectVendor = ({
@@ -6673,6 +6362,148 @@ var SelectClient = ({
6673
6362
  loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-gray-500 mt-2", children: "Chargement des clients..." })
6674
6363
  ] });
6675
6364
  };
6365
+ var SelectDas = ({
6366
+ value,
6367
+ onSelect,
6368
+ allowClear,
6369
+ onRemove,
6370
+ label = "S\xE9lectionner un DAS"
6371
+ }) => {
6372
+ const { token, activeBusinessEntity } = useSession();
6373
+ const [dasList, setDasList] = (0, import_react10.useState)(() => {
6374
+ const cacheKey = `das_cache_${activeBusinessEntity?.id || "default"}`;
6375
+ const cached = sessionStorage.getItem(cacheKey);
6376
+ return cached ? JSON.parse(cached) : [];
6377
+ });
6378
+ const [loading, setLoading] = (0, import_react10.useState)(false);
6379
+ (0, import_react10.useEffect)(() => {
6380
+ const cacheKey = `das_cache_${activeBusinessEntity?.id || "default"}`;
6381
+ const cached = sessionStorage.getItem(cacheKey);
6382
+ if (!cached) {
6383
+ loadDas();
6384
+ } else {
6385
+ setDasList(JSON.parse(cached));
6386
+ }
6387
+ }, [activeBusinessEntity?.id]);
6388
+ const getDasOptions = () => {
6389
+ return dasList.filter((das) => das.id !== void 0).map((das) => ({
6390
+ value: das.id,
6391
+ label: `${das.code_das ? `[${das.code_das}] ` : ""}${das.name || "Sans nom"}`,
6392
+ object: das
6393
+ }));
6394
+ };
6395
+ const loadDas = async () => {
6396
+ if (!token) return;
6397
+ try {
6398
+ setLoading(true);
6399
+ const result = await DasServices.list({ business_entity_id: activeBusinessEntity?.id });
6400
+ if (result.data) {
6401
+ setDasList(result.data);
6402
+ const cacheKey = `das_cache_${activeBusinessEntity?.id || "default"}`;
6403
+ sessionStorage.setItem(cacheKey, JSON.stringify(result.data));
6404
+ }
6405
+ } catch (error) {
6406
+ console.error(error);
6407
+ } finally {
6408
+ setLoading(false);
6409
+ }
6410
+ };
6411
+ const handleRefresh = () => {
6412
+ const cacheKey = `das_cache_${activeBusinessEntity?.id || "default"}`;
6413
+ sessionStorage.removeItem(cacheKey);
6414
+ loadDas();
6415
+ };
6416
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
6417
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex justify-between", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: label }) }),
6418
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
6419
+ SearchableSelect,
6420
+ {
6421
+ value,
6422
+ options: getDasOptions(),
6423
+ placeholder: "S\xE9lectionner un DAS...",
6424
+ searchPlaceholder: "Rechercher...",
6425
+ onSelect,
6426
+ disabled: loading,
6427
+ refresh: handleRefresh,
6428
+ allowClear,
6429
+ onRemove
6430
+ },
6431
+ "das" + value
6432
+ ),
6433
+ loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-gray-500 mt-2", children: "Chargement des DAS..." })
6434
+ ] });
6435
+ };
6436
+ var SelectLeadNeed = ({
6437
+ value,
6438
+ onSelect,
6439
+ allowClear,
6440
+ onRemove,
6441
+ label = "S\xE9lectionner un besoin"
6442
+ }) => {
6443
+ const { token, activeBusinessEntity } = useSession();
6444
+ const [leadNeeds, setLeadNeeds] = (0, import_react10.useState)(() => {
6445
+ const cacheKey = `lead_needs_cache_${activeBusinessEntity?.id || "default"}`;
6446
+ const cached = sessionStorage.getItem(cacheKey);
6447
+ return cached ? JSON.parse(cached) : [];
6448
+ });
6449
+ const [loading, setLoading] = (0, import_react10.useState)(false);
6450
+ (0, import_react10.useEffect)(() => {
6451
+ const cacheKey = `lead_needs_cache_${activeBusinessEntity?.id || "default"}`;
6452
+ const cached = sessionStorage.getItem(cacheKey);
6453
+ if (!cached) {
6454
+ loadLeadNeeds();
6455
+ } else {
6456
+ setLeadNeeds(JSON.parse(cached));
6457
+ }
6458
+ }, [activeBusinessEntity?.id]);
6459
+ const getLeadNeedOptions = () => {
6460
+ return leadNeeds.filter((leadNeed) => leadNeed.id !== void 0).map((leadNeed) => ({
6461
+ value: leadNeed.id,
6462
+ label: `${leadNeed.name || "Sans nom"}${leadNeed.type ? ` (${leadNeed.type})` : ""}`,
6463
+ object: leadNeed
6464
+ }));
6465
+ };
6466
+ const loadLeadNeeds = async () => {
6467
+ if (!token) return;
6468
+ try {
6469
+ setLoading(true);
6470
+ const result = await LeadNeedServices.list({ business_entity_id: activeBusinessEntity?.id });
6471
+ if (result.data) {
6472
+ setLeadNeeds(result.data);
6473
+ const cacheKey = `lead_needs_cache_${activeBusinessEntity?.id || "default"}`;
6474
+ sessionStorage.setItem(cacheKey, JSON.stringify(result.data));
6475
+ }
6476
+ } catch (error) {
6477
+ console.error(error);
6478
+ } finally {
6479
+ setLoading(false);
6480
+ }
6481
+ };
6482
+ const handleRefresh = () => {
6483
+ const cacheKey = `lead_needs_cache_${activeBusinessEntity?.id || "default"}`;
6484
+ sessionStorage.removeItem(cacheKey);
6485
+ loadLeadNeeds();
6486
+ };
6487
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
6488
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex justify-between", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: label }) }),
6489
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
6490
+ SearchableSelect,
6491
+ {
6492
+ value,
6493
+ options: getLeadNeedOptions(),
6494
+ placeholder: "S\xE9lectionner un besoin...",
6495
+ searchPlaceholder: "Rechercher...",
6496
+ onSelect,
6497
+ disabled: loading,
6498
+ refresh: handleRefresh,
6499
+ allowClear,
6500
+ onRemove
6501
+ },
6502
+ "leadneed" + value
6503
+ ),
6504
+ loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-gray-500 mt-2", children: "Chargement des besoins..." })
6505
+ ] });
6506
+ };
6676
6507
 
6677
6508
  // src/components/common/FileManager/FileManager.tsx
6678
6509
  var import_react17 = require("react");
@@ -10708,7 +10539,7 @@ var import_react25 = require("react");
10708
10539
  var import_lucide_react21 = require("lucide-react");
10709
10540
  var import_jsx_runtime31 = require("react/jsx-runtime");
10710
10541
  var ApprovalWorkflow = ({
10711
- process: process2,
10542
+ process,
10712
10543
  object_id,
10713
10544
  title = "Validation t\xE2che",
10714
10545
  readOnly = false,
@@ -10746,7 +10577,7 @@ var ApprovalWorkflow = ({
10746
10577
  } else {
10747
10578
  loadData();
10748
10579
  }
10749
- }, [process2, object_id, isOpen]);
10580
+ }, [process, object_id, isOpen]);
10750
10581
  const loadData = async () => {
10751
10582
  if (!token) {
10752
10583
  showError("Vous devez \xEAtre connect\xE9");
@@ -10777,7 +10608,7 @@ var ApprovalWorkflow = ({
10777
10608
  const loadCase = async () => {
10778
10609
  if (!token) return;
10779
10610
  try {
10780
- const response = await ApprovalServices.getDetails(process2, object_id, token);
10611
+ const response = await ApprovalServices.getDetails(process, object_id, token);
10781
10612
  if (response.success && response.data) {
10782
10613
  const caseInfo = response.data;
10783
10614
  setCaseData(caseInfo);
@@ -10837,7 +10668,7 @@ var ApprovalWorkflow = ({
10837
10668
  try {
10838
10669
  const payload = {
10839
10670
  title: formData.title,
10840
- process: process2,
10671
+ process,
10841
10672
  object_id,
10842
10673
  requested_by: loggedUser.id,
10843
10674
  description: formData.description,
@@ -10944,7 +10775,7 @@ var ApprovalWorkflow = ({
10944
10775
  if (!token) return;
10945
10776
  setLoadingHistory(true);
10946
10777
  try {
10947
- const response = await ApprovalServices.getHistory(process2, object_id, token);
10778
+ const response = await ApprovalServices.getHistory(process, object_id, token);
10948
10779
  if (response.success && response.data) {
10949
10780
  setHistory(response.data);
10950
10781
  }
@@ -19586,6 +19417,7 @@ var PurchaseRequestsPage = () => {
19586
19417
 
19587
19418
  // src/App.tsx
19588
19419
  var import_react_router_dom22 = require("react-router-dom");
19420
+ var import_react_query2 = require("@tanstack/react-query");
19589
19421
 
19590
19422
  // src/pages/Home.tsx
19591
19423
  var import_react42 = require("react");
@@ -19762,14 +19594,6 @@ var import_jsx_runtime84 = require("react/jsx-runtime");
19762
19594
  // src/pages/parameters/CrmParametersPage.tsx
19763
19595
  var import_react66 = require("react");
19764
19596
  var import_lucide_react62 = require("lucide-react");
19765
-
19766
- // src/services/CrmServices.ts
19767
- var TARGET_RETAILER_URI = `${API_URL}/crm/target-retailers/`;
19768
- var DAS_URI = `${API_URL}/crm/das/`;
19769
- var OTHER_COST_URI = `${API_URL}/crm/other-costs/`;
19770
- var LEAD_NEED_URI = `${API_URL}/crm/lead-needs/`;
19771
-
19772
- // src/pages/parameters/CrmParametersPage.tsx
19773
19597
  var import_jsx_runtime85 = require("react/jsx-runtime");
19774
19598
 
19775
19599
  // src/pages/parameters/email-template-editor/EmailTemplateEditorPage.tsx
@@ -25238,7 +25062,8 @@ var WorkSpaceRoutes = ({ module_name = "Rewise", module_id = "core", module_desc
25238
25062
  { id: "car", label: "CAR", path: "budget/car", icon: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_lucide_react73.Eye, { className: "w-4 h-4" }) }
25239
25063
  ]
25240
25064
  };
25241
- return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ModernDoubleSidebarLayout_default, { module_name, module_description, primaryMenuItems, secondaryMenuItems, children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_react_router_dom22.Routes, { children: [
25065
+ const queryClient = new import_react_query2.QueryClient();
25066
+ return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ModernDoubleSidebarLayout_default, { module_name, module_description, primaryMenuItems, secondaryMenuItems, children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_query2.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_react_router_dom22.Routes, { children: [
25242
25067
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_router_dom22.Route, { path: "", element: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(WorkSpace_default, { module: module_id }) }),
25243
25068
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_router_dom22.Route, { path: "task-pilot", element: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TaskPilot_default, {}) }),
25244
25069
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_router_dom22.Route, { path: "proculink", element: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(PurchaseRequestsPage, {}) }),
@@ -25249,7 +25074,7 @@ var WorkSpaceRoutes = ({ module_name = "Rewise", module_id = "core", module_desc
25249
25074
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_router_dom22.Route, { path: "actifs", element: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ActifsPage_default, {}) }),
25250
25075
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_router_dom22.Route, { path: "planning", element: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(PlanningPage_default, {}) }),
25251
25076
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react_router_dom22.Route, { path: "fix-it-now", element: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(FixitNow, {}) })
25252
- ] }) });
25077
+ ] }) }) });
25253
25078
  };
25254
25079
 
25255
25080
  // src/components/contracts/ContractsPage.tsx
@@ -31611,18 +31436,18 @@ var BulkSLAEvaluationModal = ({
31611
31436
  };
31612
31437
  const stats = (0, import_react86.useMemo)(() => {
31613
31438
  let achieved = 0;
31614
- let warning2 = 0;
31439
+ let warning = 0;
31615
31440
  let failed = 0;
31616
31441
  let total = 0;
31617
31442
  evaluations.forEach((e) => {
31618
31443
  if (e.value !== "" && e.status) {
31619
31444
  total++;
31620
31445
  if (e.status === "achieved") achieved++;
31621
- else if (e.status === "warning") warning2++;
31446
+ else if (e.status === "warning") warning++;
31622
31447
  else failed++;
31623
31448
  }
31624
31449
  });
31625
- return { achieved, warning: warning2, failed, total, evaluated: total };
31450
+ return { achieved, warning, failed, total, evaluated: total };
31626
31451
  }, [evaluations]);
31627
31452
  const handleSubmit = async () => {
31628
31453
  const validEvaluations = evaluations.filter((e) => e.value !== "" && !isNaN(parseFloat(e.value)));
@@ -32347,7 +32172,7 @@ var SLAManagementModal = ({
32347
32172
  const slaStats = (0, import_react87.useMemo)(() => {
32348
32173
  const indicators = contract.sla_indicators || [];
32349
32174
  const achieved = indicators.filter((i) => i.status === "achieved").length;
32350
- const warning2 = indicators.filter((i) => i.status === "warning").length;
32175
+ const warning = indicators.filter((i) => i.status === "warning").length;
32351
32176
  const failed = indicators.filter((i) => i.status === "failed").length;
32352
32177
  const total = indicators.length;
32353
32178
  const overallPerformance = total > 0 ? Math.round(indicators.reduce((sum, i) => {
@@ -32367,7 +32192,7 @@ var SLAManagementModal = ({
32367
32192
  return {
32368
32193
  total,
32369
32194
  achieved,
32370
- warning: warning2,
32195
+ warning,
32371
32196
  failed,
32372
32197
  overallPerformance,
32373
32198
  totalPenalties,
@@ -34208,8 +34033,10 @@ var PriceScheduleServices = {
34208
34033
  SelectClient,
34209
34034
  SelectCostCenter,
34210
34035
  SelectCountry,
34036
+ SelectDas,
34211
34037
  SelectDepartment,
34212
34038
  SelectInput,
34039
+ SelectLeadNeed,
34213
34040
  SelectLegalForm,
34214
34041
  SelectUnit,
34215
34042
  SelectUser,
@@ -34268,29 +34095,3 @@ var PriceScheduleServices = {
34268
34095
  useTheme,
34269
34096
  useToast
34270
34097
  });
34271
- /*! Bundled license information:
34272
-
34273
- @remix-run/router/dist/router.js:
34274
- (**
34275
- * @remix-run/router v1.23.0
34276
- *
34277
- * Copyright (c) Remix Software Inc.
34278
- *
34279
- * This source code is licensed under the MIT license found in the
34280
- * LICENSE.md file in the root directory of this source tree.
34281
- *
34282
- * @license MIT
34283
- *)
34284
-
34285
- react-router/dist/index.js:
34286
- (**
34287
- * React Router v6.30.1
34288
- *
34289
- * Copyright (c) Remix Software Inc.
34290
- *
34291
- * This source code is licensed under the MIT license found in the
34292
- * LICENSE.md file in the root directory of this source tree.
34293
- *
34294
- * @license MIT
34295
- *)
34296
- */