@nerdjs/sales-kit 3.0.7 → 3.0.8

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.
Files changed (45) hide show
  1. package/dist/entities/document/document.d.ts +2 -0
  2. package/dist/entities/goldenExample/goldenExample.d.ts +14 -0
  3. package/dist/entities/goldenExample/goldenExample.js +53 -0
  4. package/dist/entities/goldenExample/goldenExample.js.map +1 -0
  5. package/dist/entities/goldenExample/helper.d.ts +5 -0
  6. package/dist/entities/goldenExample/helper.js +16 -0
  7. package/dist/entities/goldenExample/helper.js.map +1 -0
  8. package/dist/entities/goldenExample/index.d.ts +2 -0
  9. package/dist/entities/goldenExample/index.js +3 -0
  10. package/dist/entities/goldenExample/index.js.map +1 -0
  11. package/dist/hooks/archerIntelligence/archerIntelligence.js +153 -177
  12. package/dist/hooks/archerIntelligence/archerIntelligence.js.map +1 -1
  13. package/dist/redux/api/robinaiApi.d.ts +1 -1
  14. package/dist/redux/api/robinaiApi.js +3 -3
  15. package/dist/redux/api/robinaiApi.js.map +1 -1
  16. package/dist/redux/document/documentEndpoints.d.ts +4 -194
  17. package/dist/redux/document/documentEndpoints.js +1 -19
  18. package/dist/redux/document/documentEndpoints.js.map +1 -1
  19. package/dist/redux/{loadPrompt/loadPromptEndpoints.d.ts → goldenExample/goldenExampleEndpoints.d.ts} +112 -107
  20. package/dist/redux/goldenExample/goldenExampleEndpoints.js +66 -0
  21. package/dist/redux/goldenExample/goldenExampleEndpoints.js.map +1 -0
  22. package/dist/redux/goldenExample/index.d.ts +1 -0
  23. package/dist/redux/goldenExample/index.js +2 -0
  24. package/dist/redux/goldenExample/index.js.map +1 -0
  25. package/dist/redux/processPDF/index.d.ts +1 -0
  26. package/dist/redux/processPDF/index.js +2 -0
  27. package/dist/redux/processPDF/index.js.map +1 -0
  28. package/dist/redux/processPDF/processPDFEndpoints.d.ts +178 -0
  29. package/dist/redux/processPDF/processPDFEndpoints.js +25 -0
  30. package/dist/redux/processPDF/processPDFEndpoints.js.map +1 -0
  31. package/package.json +1 -1
  32. package/dist/entities/loadPrompt/helper.d.ts +0 -5
  33. package/dist/entities/loadPrompt/helper.js +0 -16
  34. package/dist/entities/loadPrompt/helper.js.map +0 -1
  35. package/dist/entities/loadPrompt/index.d.ts +0 -2
  36. package/dist/entities/loadPrompt/index.js +0 -3
  37. package/dist/entities/loadPrompt/index.js.map +0 -1
  38. package/dist/entities/loadPrompt/loadPrompt.d.ts +0 -12
  39. package/dist/entities/loadPrompt/loadPrompt.js +0 -51
  40. package/dist/entities/loadPrompt/loadPrompt.js.map +0 -1
  41. package/dist/redux/loadPrompt/index.d.ts +0 -1
  42. package/dist/redux/loadPrompt/index.js +0 -2
  43. package/dist/redux/loadPrompt/index.js.map +0 -1
  44. package/dist/redux/loadPrompt/loadPromptEndpoints.js +0 -68
  45. package/dist/redux/loadPrompt/loadPromptEndpoints.js.map +0 -1
@@ -1,14 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Alert, Box, Button, Checkbox, Chip, CircularProgress, IconButton, Input, Option, Select, Sheet, Switch, Typography, useColorScheme, } from "@mui/joy";
2
+ import { Alert, Box, Button, Chip, CircularProgress, IconButton, Input, Option, Select, Sheet, Switch, Typography, useColorScheme, } from "@mui/joy";
3
3
  import { Portal } from "@mui/material";
4
4
  import { useGetCurrentUserQuery } from "@nerdjs/account-kit";
5
- import { NerdFileUpload, showNotification, useNerdConfirm, } from "@nerdjs/nerd-ui";
5
+ import { NerdDraggableDialog, NerdFileUpload, showNotification, useNerdConfirm, } from "@nerdjs/nerd-ui";
6
6
  import { DateTime } from "luxon";
7
7
  import { lazy, Suspense, useEffect, useMemo, useRef, useState } from "react";
8
8
  import { useDispatch } from "react-redux";
9
- import { salesApi } from "../../redux";
10
- import { useApplyDocaiDocumentMutation, useUploadDocaiDocumentMutation, } from "../../redux/document";
11
- import { useCreateLoadPromptMutation, useDeleteLoadPromptMutation, useGetLoadPromptsQuery, useUpdateLoadPromptMutation, } from "../../redux/loadPrompt/loadPromptEndpoints";
9
+ import { salesApi, useUploadArcherFileMutation } from "../../redux";
10
+ import { useApplyDocaiDocumentMutation } from "../../redux/document";
11
+ import { useCreateGoldenExampleMutation, useDeleteGoldenExampleMutation, useGetGoldenExampleQuery, useGetGoldenExamplesQuery, useUpdateGoldenExampleMutation, } from "../../redux/goldenExample/goldenExampleEndpoints";
12
+ import { useProcessPDFMutation } from "../../redux/processPDF";
12
13
  const CodeMirror = lazy(() => import("@uiw/react-codemirror"));
13
14
  const getJsonLang = async () => {
14
15
  const json = await import("@codemirror/lang-json");
@@ -47,29 +48,32 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
47
48
  const [open, setOpen] = useState(false);
48
49
  const [file, setFile] = useState();
49
50
  const [sessionID, setSessionID] = useState();
50
- const [loadPromptSessionID, setLoadPromptSessionID] = useState("");
51
- const [loadPromptID, setLoadPromptID] = useState();
51
+ const [goldenExampleSessionID, setGoldenExampleSessionID] = useState("");
52
+ const [goldenExampleID, setGoldenExampleID] = useState();
53
+ const { data: goldenExample } = useGetGoldenExampleQuery(parseInt(`${goldenExampleID}`), {
54
+ skip: !goldenExampleID,
55
+ });
52
56
  const [loading, setLoading] = useState(false);
53
57
  const [jsonMode, setJsonMode] = useState(false);
54
- const [expanded, setExpanded] = useState(false);
55
58
  const [checkboxes, setCheckboxes] = useState([]);
56
- const [upload] = useUploadDocaiDocumentMutation();
59
+ const [processPDF] = useProcessPDFMutation();
57
60
  const dispatch = useDispatch();
58
61
  const [json, setJson] = useState("");
59
62
  const [load, setLoad] = useState();
60
- const { data } = useGetLoadPromptsQuery();
63
+ const { data } = useGetGoldenExamplesQuery();
61
64
  const { mode, systemMode } = useColorScheme();
62
65
  const [consoleMode, setConsoleMode] = useState(false);
63
66
  const isDark = mode == "dark" || (mode == "system" && systemMode == "dark");
64
67
  const codeMirrorRef = useRef(null);
65
68
  const [error, setError] = useState("");
66
69
  const [applyToLoad] = useApplyDocaiDocumentMutation();
70
+ const [uploadDocument] = useUploadArcherFileMutation();
67
71
  const [newPrompt, setNewPrompt] = useState(false);
68
72
  const { data: user } = useGetCurrentUserQuery();
69
- const [loadPromptLoading, setLoadPromptLoading] = useState(false);
70
- const [updateLoadPrompt] = useUpdateLoadPromptMutation();
71
- const [deleteLoadPrompt] = useDeleteLoadPromptMutation();
72
- const [createLoadPrompt] = useCreateLoadPromptMutation();
73
+ const [goldenExampleLoading, setGoldenExampleLoading] = useState(false);
74
+ const [updateGoldenExample] = useUpdateGoldenExampleMutation();
75
+ const [deleteGoldenExample] = useDeleteGoldenExampleMutation();
76
+ const [createGoldenExample] = useCreateGoldenExampleMutation();
73
77
  const confirm = useNerdConfirm();
74
78
  // const isAIMAnager = true;
75
79
  const isAIMAnager = user?.groups?.find((g) => g.groupName === "AI Manager") ||
@@ -86,13 +90,10 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
86
90
  }, children: _jsx("object", { data: URL.createObjectURL(file), type: "application/pdf", style: { flexGrow: 1, height: "100%" }, children: _jsxs("p", { children: ["Your browser does not support PDFs. You can download the file", " ", _jsx("a", { href: URL.createObjectURL(file), children: "here" }), "."] }) }) }));
87
91
  }, [file]);
88
92
  useEffect(() => {
89
- if (consoleMode) {
90
- setExpanded(true);
91
- }
92
- else {
93
- setExpanded(false);
93
+ if (goldenExample) {
94
+ setLoad(goldenExample.json_content);
94
95
  }
95
- }, [consoleMode]);
96
+ }, [goldenExample]);
96
97
  useEffect(() => {
97
98
  if (jsonMode) {
98
99
  try {
@@ -116,7 +117,6 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
116
117
  .catch((e) => console.error(e));
117
118
  }, []);
118
119
  const reset = () => {
119
- setLoadPromptID(undefined);
120
120
  setSessionID(undefined);
121
121
  setLoad(undefined);
122
122
  setJsonMode(false);
@@ -126,129 +126,149 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
126
126
  setConsoleMode(false);
127
127
  setCheckboxes([]);
128
128
  setError("");
129
- setLoadPromptID(undefined);
130
- setLoadPromptLoading(false);
129
+ setGoldenExampleID(undefined);
130
+ setGoldenExampleLoading(false);
131
131
  setLoading(false);
132
- setExpanded(false);
133
132
  };
134
133
  const documentTypes = data?.ids
135
134
  .reduce((a, v) => {
136
- if (data.entities[v]?.session_id != null &&
137
- !a.includes(data.entities[v].session_id)) {
138
- a.push(data.entities[v].session_id);
135
+ if (data.entities[v]?.file_type != null &&
136
+ !a.includes(data.entities[v].file_type)) {
137
+ a.push(data.entities[v].file_type);
139
138
  }
140
139
  return a;
141
140
  }, [])
142
141
  .sort();
143
- function purgeLoad(obj, path) {
144
- if (Array.isArray(obj)) {
145
- for (let i = 0; i < obj.length; i++) {
146
- purgeLoad(obj[i], `${path}-${i}`);
147
- }
148
- }
149
- else if (typeof obj === "object" && obj !== null) {
150
- for (const key in obj) {
151
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
152
- if (checkboxes.includes(`${path}-${key}`)) {
153
- delete obj[key];
154
- }
155
- else {
156
- purgeLoad(obj[key], `${path}-${key}`);
157
- }
158
- }
159
- }
160
- }
161
- return obj;
162
- }
163
- const apply = () => {
142
+ // function purgeLoad(obj: any, path: string) {
143
+ // if (Array.isArray(obj)) {
144
+ // for (let i = 0; i < obj.length; i++) {
145
+ // purgeLoad(obj[i], `${path}-${i}`);
146
+ // }
147
+ // } else if (typeof obj === "object" && obj !== null) {
148
+ // for (const key in obj) {
149
+ // if (Object.prototype.hasOwnProperty.call(obj, key)) {
150
+ // if (checkboxes.includes(`${path}-${key}`)) {
151
+ // delete obj[key];
152
+ // } else {
153
+ // purgeLoad(obj[key], `${path}-${key}`);
154
+ // }
155
+ // }
156
+ // }
157
+ // }
158
+ // return obj;
159
+ // }
160
+ const apply = async () => {
164
161
  if (load) {
165
162
  setLoading(true);
166
- applyToLoad({
167
- load: {
168
- ...purgeLoad(JSON.parse(JSON.stringify(load)), ""),
169
- quoteID,
170
- loadID,
171
- },
172
- })
173
- .unwrap()
174
- .then(() => {
175
- setLoading(false);
176
- confirm.setOpen({
177
- content: "Changes have been applied to the load",
178
- title: "Success",
179
- actions: [],
163
+ const archerFile = await uploadDocument({
164
+ modelType: "Load",
165
+ modelID: loadID,
166
+ description: "Rate Confirmation",
167
+ file: file,
168
+ }).unwrap();
169
+ console.log(archerFile);
170
+ debugger;
171
+ if (archerFile?.id) {
172
+ console.log({
173
+ ...load,
174
+ archer_file_id: archerFile.id,
175
+ quote_id: quoteID,
176
+ load_id: loadID,
180
177
  });
181
- reset();
182
- setOpen(false);
183
- dispatch(salesApi.util.invalidateTags(["loads"]));
184
- })
185
- .catch((e) => {
186
- setError(e.data.message);
178
+ debugger;
179
+ applyToLoad({
180
+ load: {
181
+ ...load,
182
+ archer_file_id: archerFile.id,
183
+ quote_id: quoteID,
184
+ load_id: loadID,
185
+ },
186
+ })
187
+ .unwrap()
188
+ .then(() => {
189
+ setLoading(false);
190
+ confirm.setOpen({
191
+ content: "Changes have been applied to the load",
192
+ title: "Success",
193
+ actions: [],
194
+ });
195
+ reset();
196
+ setOpen(false);
197
+ dispatch(salesApi.util.invalidateTags(["loads"]));
198
+ })
199
+ .catch((e) => {
200
+ setError(e.data.message);
201
+ setLoading(false);
202
+ });
203
+ }
204
+ else {
187
205
  setLoading(false);
188
- });
206
+ }
189
207
  }
190
208
  };
191
209
  const deletePrompt = () => {
192
- if (loadPromptID)
210
+ if (goldenExampleID)
193
211
  confirm.setOpen({
194
- content: "Are you sure you want to delete this load prompt?",
212
+ content: "Are you sure you want to delete this Golden Example?",
195
213
  title: "Are you sure?",
196
214
  onConfirm() {
197
- deleteLoadPrompt(loadPromptID);
215
+ deleteGoldenExample(goldenExampleID);
198
216
  setFile(undefined);
199
217
  setLoad(undefined);
200
- setLoadPromptID(undefined);
218
+ setGoldenExampleID(undefined);
201
219
  },
202
220
  });
203
221
  };
204
222
  const savePrompt = () => {
205
- if (loadPromptID) {
206
- const loadPrompt = data?.entities[loadPromptID];
207
- setLoadPromptLoading(true);
208
- updateLoadPrompt({
209
- id: loadPromptID,
223
+ if (goldenExampleID) {
224
+ const goldenExample = data?.entities[goldenExampleID];
225
+ setGoldenExampleLoading(true);
226
+ updateGoldenExample({
227
+ id: goldenExampleID,
210
228
  body: {
211
- ...loadPrompt,
212
- session_id: loadPromptSessionID,
229
+ ...goldenExample,
230
+ file_type: goldenExampleSessionID,
213
231
  load: { ...load },
214
232
  },
215
233
  })
216
234
  .unwrap()
217
235
  .then(() => {
218
- setLoadPromptLoading(false);
236
+ setGoldenExampleLoading(false);
219
237
  confirm.setOpen({
220
- content: "The load prompt has been updated",
238
+ content: "The Golden Example has been updated",
221
239
  title: "Success",
222
240
  actions: [],
223
241
  });
224
242
  })
225
243
  .catch((e) => {
226
244
  setError(e.data.message);
227
- setLoadPromptLoading(false);
245
+ setGoldenExampleLoading(false);
228
246
  });
229
247
  }
230
248
  else if (file) {
231
- createLoadPrompt({
232
- payload: { session_id: loadPromptSessionID, load },
249
+ createGoldenExample({
250
+ payload: load,
251
+ file_type: goldenExampleSessionID,
233
252
  file,
234
253
  })
235
254
  .unwrap()
236
255
  .then(() => {
237
- setLoadPromptLoading(false);
256
+ setGoldenExampleLoading(false);
238
257
  confirm.setOpen({
239
- content: "The load prompt has been created",
258
+ content: "The Golden Example has been created",
240
259
  title: "Success",
241
260
  actions: [],
242
261
  });
243
262
  })
244
263
  .catch((e) => {
245
264
  setError(e.data.message);
246
- setLoadPromptLoading(false);
265
+ setGoldenExampleLoading(false);
247
266
  });
248
267
  }
249
268
  };
250
269
  const errorBox = (_jsx(Alert, { size: "sm", color: "danger", endDecorator: _jsx(IconButton, { size: "sm", onClick: () => setError(""), children: _jsx("i", { className: "fa-solid fa-xmark" }) }), children: error }));
251
- const consoleToolbar = (_jsxs(Box, { sx: {
270
+ const consoleToolbar = (_jsxs(Box, { id: "draggable-area", sx: {
271
+ cursor: "move",
252
272
  position: "sticky",
253
273
  top: 0,
254
274
  borderBottom: "solid 1px #9e9e9e44",
@@ -257,18 +277,17 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
257
277
  justifyContent: "end",
258
278
  width: "100%",
259
279
  alignItems: "center",
260
- zIndex: 2147483001,
261
280
  }, children: [_jsx(Select
262
281
  // disabled={!sessionID}
263
282
  , {
264
283
  // disabled={!sessionID}
265
- value: loadPromptID, onChange: (_e, v) => {
266
- setLoadPromptID(v);
267
- setLoadPromptSessionID(data?.entities[v]?.session_id ?? "");
268
- setSessionID(data?.entities[v]?.session_id ?? "");
269
- setLoad(data?.entities[v]?.load);
270
- setJson(JSON.stringify(data?.entities[v]?.load, null, 4));
271
- fetch(`${window._APP_CONFIG?.api?.endpoint}/v3/robinai/goldenExamples/${data?.entities[v]?.id}/download/${data?.entities[v]?.file.id}`, {
284
+ value: goldenExampleID, onChange: (_e, v) => {
285
+ setGoldenExampleID(v);
286
+ setGoldenExampleSessionID(data?.entities[v]?.file_type ?? "");
287
+ // setSessionID(data?.entities[v!]?.file_type ?? "");
288
+ // setLoad(data?.entities[v!]?.load);
289
+ // setJson(JSON.stringify(data?.entities[v!]?.load, null, 4));
290
+ fetch(`${window._APP_CONFIG?.api?.endpoint}/v3/robinai/goldenExamples/${data?.entities[v]?.id}/pdf`, {
272
291
  credentials: "include",
273
292
  method: "GET",
274
293
  })
@@ -276,21 +295,22 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
276
295
  .then((blob) => {
277
296
  setFile(new File([blob], "document.pdf", { type: blob.type }));
278
297
  });
279
- }, startDecorator: "Load Prompt:", endDecorator: loadPromptID ? (_jsx(IconButton, { variant: "plain", onClick: () => {
280
- setLoadPromptID(null);
298
+ }, startDecorator: "Golden Example:", endDecorator: goldenExampleID ? (_jsx(IconButton, { variant: "plain", onClick: () => {
299
+ setGoldenExampleID(null);
281
300
  setLoad(undefined);
282
301
  setFile(undefined);
283
- }, children: _jsx("i", { className: "fa-solid fa-xmark" }) })) : undefined, variant: loadPromptID ? "soft" : "outlined", size: "sm", children: data?.ids.map((id) => (_jsx(Option, { value: data.entities[id]?.id, children: _jsx(Typography, { level: "body-md", endDecorator: _jsxs(Typography, { level: "body-xs", children: ["#", data.entities[id]?.id] }), children: data.entities[id]?.session_id }) }, id))) }), _jsx(Chip, { onClick: () => {
302
+ }, children: _jsx("i", { className: "fa-solid fa-xmark" }) })) : undefined, variant: goldenExampleID ? "soft" : "outlined", size: "sm", children: data?.ids.map((id) => (_jsx(Option, { value: data.entities[id]?.id, children: _jsx(Typography, { level: "body-md", endDecorator: _jsxs(Typography, { level: "body-xs", children: ["#", data.entities[id]?.id] }), children: data.entities[id]?.file_type }) }, id))) }), _jsx(Chip, { onClick: () => {
284
303
  setNewPrompt(true);
285
304
  setLoad(undefined);
286
305
  setFile(undefined);
287
- setLoadPromptID(null);
306
+ setGoldenExampleID(null);
288
307
  setSessionID("");
289
308
  setJson("");
290
- }, startDecorator: _jsx("i", { className: "fa-solid fa-plus" }), size: "sm", children: "Prompt" }), _jsx(Box, { sx: { flexGrow: 1 } }), loadPromptID ? (_jsx(Chip, { startDecorator: _jsx("i", { className: "fa-solid fa-trash" }), color: "danger", size: "sm", onClick: deletePrompt, children: "Delete" })) : ([]), _jsx(Typography, { component: "label", sx: { cursor: "pointer" }, level: "body-xs", endDecorator: _jsx(Switch, { size: "sm", checked: jsonMode, onChange: (e) => setJsonMode(e.target.checked) }), children: "JSON" }), _jsx(IconButton, { onClick: () => {
309
+ }, startDecorator: _jsx("i", { className: "fa-solid fa-plus" }), size: "sm", children: "Golden Example" }), _jsx(Box, { sx: { flexGrow: 1 } }), goldenExampleID ? (_jsx(Chip, { startDecorator: _jsx("i", { className: "fa-solid fa-trash" }), color: "danger", size: "sm", onClick: deletePrompt, children: "Delete" })) : ([]), _jsx(Typography, { component: "label", sx: { cursor: "pointer" }, level: "body-xs", endDecorator: _jsx(Switch, { size: "sm", checked: jsonMode, onChange: (e) => setJsonMode(e.target.checked) }), children: "JSON" }), _jsx(IconButton, { onClick: () => {
291
310
  reset();
292
311
  }, children: _jsx("i", { className: "fa-solid fa-xmark" }) })] }));
293
- const toolbar = (_jsxs(Box, { sx: {
312
+ const toolbar = (_jsxs(Box, { id: "draggable-area", sx: {
313
+ cursor: "move",
294
314
  position: "sticky",
295
315
  top: 0,
296
316
  borderBottom: "solid 1px #9e9e9e44",
@@ -299,10 +319,9 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
299
319
  justifyContent: "end",
300
320
  width: "100%",
301
321
  alignItems: "center",
302
- zIndex: 2147483001,
303
322
  }, children: [load ? (_jsx(Chip, { onClick: () => {
304
323
  reset();
305
- }, size: "sm", variant: "plain", startDecorator: _jsx("i", { className: "fa-solid fa-rotate-left" }), color: "neutral", children: "Restart" })) : ([]), !consoleMode && isAIMAnager ? (_jsx(Chip, { startDecorator: _jsx("i", { className: "fa-light fa-brain-circuit" }), variant: "plain", size: "sm", onClick: () => setConsoleMode(true), children: "Console" })) : ([]), _jsx(Box, { sx: { flexGrow: 1 } }), _jsx(Typography, { component: "label", sx: { cursor: "pointer" }, level: "body-xs", endDecorator: _jsx(Switch, { size: "sm", checked: jsonMode, onChange: (e) => setJsonMode(e.target.checked) }), children: "JSON" }), _jsx(IconButton, { onClick: () => setExpanded((o) => !o), children: expanded ? (_jsx("i", { className: "fa-solid fa-arrow-down-left-and-arrow-up-right-to-center" })) : (_jsx("i", { className: "fa-solid fa-arrow-up-right-and-arrow-down-left-from-center" })) })] }));
324
+ }, size: "sm", variant: "plain", startDecorator: _jsx("i", { className: "fa-solid fa-rotate-left" }), color: "neutral", children: "Restart" })) : ([]), !consoleMode && isAIMAnager ? (_jsx(Chip, { startDecorator: _jsx("i", { className: "fa-light fa-brain-circuit" }), variant: "plain", size: "sm", onClick: () => setConsoleMode(true), children: "Console" })) : ([]), _jsx(Box, { sx: { flexGrow: 1 } }), _jsx(Typography, { component: "label", sx: { cursor: "pointer" }, level: "body-xs", endDecorator: _jsx(Switch, { size: "sm", checked: jsonMode, onChange: (e) => setJsonMode(e.target.checked) }), children: "JSON" }), _jsx(IconButton, { onClick: () => setOpen(false), children: _jsx("i", { className: "fa-solid fa-xmark" }) })] }));
306
325
  const uploadTemplate = (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: {
307
326
  display: "flex",
308
327
  alignItems: "center",
@@ -336,18 +355,20 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
336
355
  variant: "non-intrusive",
337
356
  })) })) })] }), _jsx(Button, { onClick: () => {
338
357
  setLoading(true);
339
- upload({
358
+ processPDF({
340
359
  file: file,
341
- sessionID: sessionID,
342
- load: { load_id: loadID, quote_id: quoteID },
360
+ file_type: sessionID,
361
+ // load: { load_id: loadID, quote_id: quoteID },
343
362
  })
344
363
  .unwrap()
345
364
  .then((e) => {
365
+ const a = JSON.parse(JSON.stringify(e));
366
+ const stops = JSON.parse(JSON.stringify(a.stops));
367
+ delete a.stops;
368
+ const l = { ...a, stops };
346
369
  setLoading(false);
347
- setExpanded(true);
348
- // setJsonMode(true);
349
- setLoad(e.load);
350
- setJson(JSON.stringify(e.load, null, 4));
370
+ setLoad(l);
371
+ setJson(JSON.stringify(l, null, 4));
351
372
  })
352
373
  .catch(() => {
353
374
  setLoading(false);
@@ -363,7 +384,7 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
363
384
  }, children: _jsx(Suspense, { fallback: _jsx(Box, { display: "flex", justifyContent: "center", width: "100%", children: _jsx(CircularProgress, {}) }), children: !jsonLib ? (_jsx(Box, { display: "flex", justifyContent: "center", width: "100%", children: _jsx(CircularProgress, {}) })) : (_jsx(CodeMirror, { value: json, onChange: (v) => {
364
385
  setJson(v);
365
386
  }, ref: codeMirrorRef, theme: isDark ? "dark" : "light", extensions: [jsonLib] })) }) }), _jsx(Button, { onClick: () => apply(), disabled: !load, size: "lg", fullWidth: true, children: "Apply to Load" })] }));
366
- let consoleTemplate = jsonMode ? (_jsxs(_Fragment, { children: [_jsx(Input, { startDecorator: "SessionID:", size: "lg", variant: "soft", autoFocus: !loadPromptID, value: loadPromptSessionID ?? "", onChange: (e) => setLoadPromptSessionID(e.target.value) }), _jsx(Box, { sx: {
387
+ let consoleTemplate = jsonMode ? (_jsxs(_Fragment, { children: [_jsx(Input, { startDecorator: "File Type:", size: "lg", variant: "soft", autoFocus: !goldenExampleID, value: goldenExampleSessionID ?? "", onChange: (e) => setGoldenExampleSessionID(e.target.value) }), _jsx(Box, { sx: {
367
388
  flex: 1,
368
389
  height: 0,
369
390
  width: "100%",
@@ -372,7 +393,7 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
372
393
  overflow: "auto",
373
394
  }, children: _jsx(Suspense, { fallback: _jsx(Box, { display: "flex", justifyContent: "center", width: "100%", children: _jsx(CircularProgress, {}) }), children: !jsonLib ? (_jsx(Box, { display: "flex", justifyContent: "center", width: "100%", children: _jsx(CircularProgress, {}) })) : (_jsx(CodeMirror, { value: json, onChange: (v) => {
374
395
  setJson(v);
375
- }, ref: codeMirrorRef, theme: isDark ? "dark" : "light", extensions: [jsonLib] })) }) }), _jsx(Button, { size: "lg", fullWidth: true, onClick: savePrompt, children: "Save Prompt" })] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: {
396
+ }, ref: codeMirrorRef, theme: isDark ? "dark" : "light", extensions: [jsonLib] })) }) }), _jsx(Button, { size: "lg", fullWidth: true, onClick: savePrompt, disabled: !goldenExampleSessionID, children: "Save Golden Example" })] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: {
376
397
  flex: 1,
377
398
  width: "100%",
378
399
  height: 0,
@@ -384,7 +405,7 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
384
405
  gap: 1,
385
406
  p: 1,
386
407
  pr: 2,
387
- }, children: [_jsx(Input, { startDecorator: "SessionID:", size: "lg", variant: "soft", autoFocus: !loadPromptID, value: loadPromptSessionID ?? "", onChange: (e) => setLoadPromptSessionID(e.target.value) }), error ? errorBox : [], load
408
+ }, children: [_jsx(Input, { startDecorator: "File Type:", size: "lg", variant: "soft", autoFocus: !goldenExampleID, value: goldenExampleSessionID ?? "", onChange: (e) => setGoldenExampleSessionID(e.target.value) }), error ? errorBox : [], load
388
409
  ? genForm({
389
410
  object: load,
390
411
  onChange: (e) => {
@@ -392,7 +413,7 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
392
413
  },
393
414
  prefix: "",
394
415
  })
395
- : []] }, loadPromptID), _jsx(Button, { loading: loadPromptLoading, onClick: savePrompt, size: "lg", fullWidth: true, children: "Save Prompt" })] }));
416
+ : []] }, goldenExampleID), _jsx(Button, { loading: goldenExampleLoading, onClick: savePrompt, size: "lg", fullWidth: true, children: "Save Prompt" })] }));
396
417
  if (newPrompt && !load)
397
418
  consoleTemplate = (_jsx(_Fragment, { children: _jsxs(Box, { sx: {
398
419
  display: "flex",
@@ -405,7 +426,7 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
405
426
  WebkitBackgroundClip: "text !important",
406
427
  WebkitTextFillColor: "transparent",
407
428
  background: "linear-gradient(20deg, #0894FF, #C959DD 50%, #FF2E54 68%, #FF9004)",
408
- }, children: "New Load Prompt" }) }), _jsx(Box, { children: file ? (_jsxs(Sheet, { sx: {
429
+ }, children: "New Golden Example" }) }), _jsx(Box, { children: file ? (_jsxs(Sheet, { sx: {
409
430
  display: "flex",
410
431
  p: 1,
411
432
  gap: 1,
@@ -459,7 +480,7 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
459
480
  if (consoleMode) {
460
481
  if (load || newPrompt)
461
482
  return consoleTemplate;
462
- return (_jsx(Typography, { startDecorator: _jsx("i", { className: "fa-solid fa-arrow-up" }), children: "Select a prompt or create a new one" }));
483
+ return (_jsx(Typography, { startDecorator: _jsx("i", { className: "fa-solid fa-arrow-up" }), children: "Select a Golden Example or create a new one" }));
463
484
  }
464
485
  if (jsonMode)
465
486
  return jsonTemplate;
@@ -499,22 +520,15 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
499
520
  onChange({ ...object, [r.key]: _o });
500
521
  }, children: "Add" })] })] }, r.key));
501
522
  const checked = !(checkboxes.includes(`${prefix}-${r.key}`) ?? true);
502
- return (_jsxs(Box, { sx: { display: "flex", gap: 1, alignItems: "center" }, children: [!consoleMode ? (_jsx(Checkbox, { disabled: disabled.includes(r.key) || required.includes(r.key), onChange: (e) => {
503
- if (e.target.checked) {
504
- setCheckboxes((c) => c.filter((e) => e != `${prefix}-${r.key}`));
505
- }
506
- else {
507
- setCheckboxes((c) => [...c, `${prefix}-${r.key}`]);
508
- }
509
- }, size: "sm", checked: checked })) : ([]), getUIElement({
510
- key: r.key,
511
- value: r.value,
512
- onChange: (newValue) => {
513
- onChange({ ...object, [r.key]: newValue });
514
- },
515
- checked,
516
- parentObj: object,
517
- })] }, r.key));
523
+ return (_jsx(Box, { sx: { display: "flex", gap: 1, alignItems: "center" }, children: getUIElement({
524
+ key: r.key,
525
+ value: r.value,
526
+ onChange: (newValue) => {
527
+ onChange({ ...object, [r.key]: newValue });
528
+ },
529
+ checked,
530
+ parentObj: object,
531
+ }) }, r.key));
518
532
  });
519
533
  }
520
534
  function getUIElement({ key, value, onChange, checked, parentObj, }) {
@@ -578,14 +592,9 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
578
592
  opacity: disabled.includes(key) ? 0 : 0.58,
579
593
  }, onClick: !disabled.includes(key) ? () => onChange(null) : undefined, className: "fa-solid fa-xmark" })] }));
580
594
  }
581
- return (_jsxs(_Fragment, { children: [open ? (_jsx(Sheet, { sx: {
582
- ...content,
583
- maxHeight: expanded ? "calc(100% - 104px)" : "704px",
584
- height: expanded
585
- ? "calc(100% - 104px)"
586
- : "min(704px, 100% - 104px)",
587
- width: expanded ? "1080px" : "400px",
588
- }, children: _jsxs(Box, { sx: {
595
+ return (_jsxs(_Fragment, { children: [open ? (_jsx(NerdDraggableDialog, { draggableProps: {
596
+ handle: "#draggable-area",
597
+ }, initialHeight: 1043, initialWidth: 1080, localStorageKeyPrefix: "archer-ai", resizable: true, sheetProps: { sx: { p: 0, overflow: "scroll" } }, children: _jsxs(Box, { sx: {
589
598
  flex: 1,
590
599
  display: "flex",
591
600
  flexDirection: "column",
@@ -608,34 +617,12 @@ export function ArcherIntelligence({ loadID, quoteID, }) {
608
617
  width: "100%",
609
618
  height: "100%",
610
619
  overflow: "auto",
611
- }, children: getContent() }), file && expanded && !loading ? fileRender : []] })] }) })) : ([]), _jsxs(Portal, { children: [_jsx(Sheet, { sx: {
620
+ }, children: getContent() }), file && !loading ? fileRender : []] })] }) })) : ([]), _jsxs(Portal, { children: [_jsx(Sheet, { sx: {
612
621
  ...root,
613
622
  filter: "blur(4px)",
614
623
  background: "linear-gradient(108deg,#0894FF,#C959DD 34%,#FF2E54 68%,#FF9004)",
615
624
  } }), _jsx(Sheet, { sx: root, onClick: () => setOpen((o) => !o), children: open ? (_jsx("i", { className: "fa-solid fa-chevron-down" })) : (_jsx("img", { src: "https://storage.googleapis.com/archer-app/logos/a.png", style: { height: 28 } })) })] })] }));
616
625
  }
617
- const content = {
618
- zIndex: 2147483000,
619
- position: "fixed",
620
- bottom: "84px",
621
- left: "20px",
622
- transformOrigin: "right bottom",
623
- height: "min(704px, 100% - 104px)",
624
- minHeight: "80px",
625
- width: "400px",
626
- maxHeight: "704px",
627
- borderRadius: "16px",
628
- overflow: "auto",
629
- boxShadow: "rgba(0, 0, 0, 0.16) 0px 5px 40px",
630
- opacity: 1,
631
- display: "flex",
632
- alignItems: "center",
633
- justifyContent: "center",
634
- p: 1,
635
- gap: 1,
636
- transition: "max-width 200ms, width 200ms, height 200ms, max-height 200ms, transform 300ms cubic-bezier(0, 1.2, 1, 1), opacity 83ms ease-out",
637
- pointerEvents: "all",
638
- };
639
626
  const root = {
640
627
  width: 48,
641
628
  height: 48,
@@ -643,7 +630,6 @@ const root = {
643
630
  userSelect: "none",
644
631
  bottom: 20,
645
632
  left: 20,
646
- zIndex: 2147483000,
647
633
  transition: `transform 167ms cubic-bezier(0.33, 0, 0, 1)`,
648
634
  transformOrigin: `center center`,
649
635
  display: "flex",
@@ -694,15 +680,5 @@ const emptyLoad = {
694
680
  archer_file_id: 0,
695
681
  stops: [emptyStop],
696
682
  };
697
- const required = [
698
- "quote_id",
699
- "reference_number",
700
- "service_level",
701
- "customer",
702
- "load_type",
703
- "feet",
704
- "pallets",
705
- "weight",
706
- "stops",
707
- ];
683
+ const required = ["quote_id", "reference_number"];
708
684
  //# sourceMappingURL=archerIntelligence.js.map