@orbe-agro/client-core 5.6.336 → 5.6.338

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 (73) hide show
  1. package/dist/@ecme/assets/styles/app.css +13 -0
  2. package/dist/@ecme/assets/styles/tailwind/index.css +13 -0
  3. package/dist/@ecme/components/template/Footer.js +1 -1
  4. package/dist/@ecme/components/view/ChatBox/ChatBox.js +3 -1
  5. package/dist/@ecme/components/view/ChatBox/ChatBox.js.map +1 -1
  6. package/dist/@ecme/components/view/ChatBox/components/ChatInput.js +16 -14
  7. package/dist/@ecme/components/view/ChatBox/components/ChatInput.js.map +1 -1
  8. package/dist/@ecme/index.js +2 -1
  9. package/dist/@ecme/services/AiService.js +13 -1
  10. package/dist/@ecme/services/AiService.js.map +1 -1
  11. package/dist/@ecme/services/index.js +2 -1
  12. package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js +11 -3
  13. package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js.map +1 -1
  14. package/dist/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.js +35 -0
  15. package/dist/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.js.map +1 -0
  16. package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js +14 -11
  17. package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js.map +1 -1
  18. package/dist/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.js +31 -0
  19. package/dist/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.js.map +1 -0
  20. package/dist/@ecme/views/concepts/ai/Chat/imagens.js +57 -0
  21. package/dist/@ecme/views/concepts/ai/Chat/imagens.js.map +1 -0
  22. package/dist/@types/@ecme/components/view/ChatBox/ChatBox.d.ts.map +1 -1
  23. package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts +3 -0
  24. package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts.map +1 -1
  25. package/dist/@types/@ecme/services/AiService.d.ts +12 -2
  26. package/dist/@types/@ecme/services/AiService.d.ts.map +1 -1
  27. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ChatView.d.ts.map +1 -1
  28. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.d.ts +13 -0
  29. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.d.ts.map +1 -0
  30. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts +1 -1
  31. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts.map +1 -1
  32. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.d.ts +16 -0
  33. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.d.ts.map +1 -0
  34. package/dist/@types/@ecme/views/concepts/ai/Chat/imagens.d.ts +27 -0
  35. package/dist/@types/@ecme/views/concepts/ai/Chat/imagens.d.ts.map +1 -0
  36. package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts +38 -0
  37. package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts.map +1 -1
  38. package/dist/@types/base/@types/api/response/transportadora/RelatorioQuebraData.d.ts +13 -0
  39. package/dist/@types/base/@types/api/response/transportadora/RelatorioQuebraData.d.ts.map +1 -0
  40. package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts +4 -0
  41. package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts.map +1 -1
  42. package/dist/@types/base/configs/endpoints.config/transportadora/contratoFrete.d.ts +4 -0
  43. package/dist/@types/base/configs/endpoints.config/transportadora/contratoFrete.d.ts.map +1 -1
  44. package/dist/@types/base/configs/navigation.config/modules.submenu/Transportadora/relatorios.subMenu.navigation.d.ts.map +1 -1
  45. package/dist/@types/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.d.ts +2 -0
  46. package/dist/@types/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.d.ts.map +1 -1
  47. package/dist/base/@types/api/response/transportadora/RelatorioQuebraData.js +2 -0
  48. package/dist/base/@types/api/response/transportadora/RelatorioQuebraData.js.map +1 -0
  49. package/dist/base/assets/styles/init.css +13 -0
  50. package/dist/base/configs/endpoints.config/transportadora/contratoFrete.js +2 -1
  51. package/dist/base/configs/endpoints.config/transportadora/contratoFrete.js.map +1 -1
  52. package/dist/base/configs/navigation.config/modules.submenu/Transportadora/relatorios.subMenu.navigation.js +10 -0
  53. package/dist/base/configs/navigation.config/modules.submenu/Transportadora/relatorios.subMenu.navigation.js.map +1 -1
  54. package/dist/base/index.js +2 -1
  55. package/dist/base/services/index.js +2 -1
  56. package/dist/base/services/modules/index.js +2 -1
  57. package/dist/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.js +8 -0
  58. package/dist/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.js.map +1 -1
  59. package/dist/base/services/modules/transportadora/index.js +2 -1
  60. package/lib/@ecme/components/view/ChatBox/ChatBox.tsx +2 -0
  61. package/lib/@ecme/components/view/ChatBox/components/ChatInput.tsx +20 -14
  62. package/lib/@ecme/services/AiService.ts +27 -2
  63. package/lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx +13 -3
  64. package/lib/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.tsx +54 -0
  65. package/lib/@ecme/views/concepts/ai/Chat/hooks/useChatSend.ts +33 -11
  66. package/lib/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.ts +53 -0
  67. package/lib/@ecme/views/concepts/ai/Chat/imagens.ts +86 -0
  68. package/lib/@ecme/views/concepts/ai/Chat/types.ts +42 -0
  69. package/lib/base/@types/api/response/transportadora/RelatorioQuebraData.ts +12 -0
  70. package/lib/base/configs/endpoints.config/transportadora/contratoFrete.ts +1 -0
  71. package/lib/base/configs/navigation.config/modules.submenu/Transportadora/relatorios.subMenu.navigation.ts +10 -0
  72. package/lib/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.ts +9 -0
  73. package/package.json +1 -1
@@ -0,0 +1,86 @@
1
+ import type { UploadProps } from '@/components/ui/Upload'
2
+ import type { ImagemDaMensagem, ImagemEnviada, TipoDeImagem } from './types'
3
+
4
+ /**
5
+ * Imagens no chat de IA: o que o seletor aceita, como a imagem vai ao backend
6
+ * e como ela aparece na mensagem.
7
+ *
8
+ * Os limites espelham os do backend (`settings.py`: `chat_max_imagens` e
9
+ * `chat_max_bytes_por_imagem`; `imagem.py`: `TipoDeImagem`). A validacao aqui
10
+ * so evita a viagem: quem decide e o backend, que responde 422 fora deles.
11
+ */
12
+
13
+ export const TIPOS_DE_IMAGEM: ReadonlyArray<TipoDeImagem> = [
14
+ 'image/png',
15
+ 'image/jpeg',
16
+ 'image/webp',
17
+ ]
18
+
19
+ export const MAX_IMAGENS = 3
20
+
21
+ export const MAX_BYTES_POR_IMAGEM = 5 * 1024 * 1024
22
+
23
+ /** Titulo da conversa aberta so com imagem; o mesmo texto do backend. */
24
+ export const TITULO_SO_IMAGEM = 'Imagem enviada'
25
+
26
+ const ehTipoDeImagem = (tipo: string): tipo is TipoDeImagem =>
27
+ TIPOS_DE_IMAGEM.some((aceito) => aceito === tipo)
28
+
29
+ /**
30
+ * Confere as imagens escolhidas antes de entrarem na caixa de mensagem.
31
+ *
32
+ * Assinatura do `beforeUpload` do `Upload`: a string devolvida vira o toast
33
+ * de erro, e o arquivo nao entra.
34
+ */
35
+ const validarImagens: UploadProps['beforeUpload'] = (novas, atuais) => {
36
+ const arquivos = Array.from(novas ?? [])
37
+
38
+ if (arquivos.length + atuais.length > MAX_IMAGENS) {
39
+ return `Envie no máximo ${MAX_IMAGENS} imagens por mensagem.`
40
+ }
41
+ if (arquivos.some((arquivo) => !ehTipoDeImagem(arquivo.type))) {
42
+ return 'Envie imagens PNG, JPEG ou WEBP.'
43
+ }
44
+ if (arquivos.some((arquivo) => arquivo.size > MAX_BYTES_POR_IMAGEM)) {
45
+ return `Cada imagem pode ter até ${MAX_BYTES_POR_IMAGEM / (1024 * 1024)} MB.`
46
+ }
47
+ return true
48
+ }
49
+
50
+ /** Configuracao do seletor de imagens da caixa de mensagem. */
51
+ export const UPLOAD_DE_IMAGENS: Pick<UploadProps, 'accept' | 'beforeUpload'> = {
52
+ accept: TIPOS_DE_IMAGEM.join(','),
53
+ beforeUpload: validarImagens,
54
+ }
55
+
56
+ /** As imagens como a bolha do usuario mostra logo apos o envio. */
57
+ export const paraImagensDaMensagem = (arquivos: File[]): ImagemDaMensagem[] =>
58
+ arquivos.map((arquivo) => ({
59
+ mimeType: arquivo.type,
60
+ url: URL.createObjectURL(arquivo),
61
+ }))
62
+
63
+ /**
64
+ * A imagem como vai no corpo do /ai/chat/stream.
65
+ *
66
+ * O `readAsDataURL` devolve `data:<mime>;base64,<conteudo>`; o backend espera
67
+ * so o conteudo.
68
+ */
69
+ export const paraImagemEnviada = (arquivo: File): Promise<ImagemEnviada> =>
70
+ new Promise((resolve, reject) => {
71
+ if (!ehTipoDeImagem(arquivo.type)) {
72
+ reject(new Error(`Formato de imagem nao aceito: ${arquivo.type}`))
73
+ return
74
+ }
75
+ const mimeType = arquivo.type
76
+ const leitor = new FileReader()
77
+ leitor.onload = () => {
78
+ const dataUrl = String(leitor.result)
79
+ resolve({
80
+ mime_type: mimeType,
81
+ base64: dataUrl.slice(dataUrl.indexOf(',') + 1),
82
+ })
83
+ }
84
+ leitor.onerror = () => reject(leitor.error)
85
+ leitor.readAsDataURL(arquivo)
86
+ })
@@ -51,6 +51,14 @@ export type Conversation = {
51
51
  mediaUrl: string
52
52
  }>
53
53
  isMyMessage?: boolean
54
+ /**
55
+ * Imagens enviadas pelo usuario nesta mensagem.
56
+ *
57
+ * Campo proprio do chat de IA, e nao o `attachments` do template: aquele
58
+ * exige o `File`, e a mensagem vinda do historico so tem a referencia no
59
+ * object storage.
60
+ */
61
+ imagens?: ImagemDaMensagem[]
54
62
  /**
55
63
  * Liga a animacao de maquina de escrever do ChatCustomContent.
56
64
  *
@@ -187,6 +195,40 @@ export type HistoryChat = Omit<ChatHistory, 'conversation'> & {
187
195
  */
188
196
  export type Esforco = 'minimal' | 'medium' | 'high' | 'max'
189
197
 
198
+ /**
199
+ * Formatos de imagem aceitos no chat.
200
+ *
201
+ * O mesmo conjunto do backend (enum `TipoDeImagem`, em `imagem.py`): qualquer
202
+ * outro volta 422.
203
+ */
204
+ export type TipoDeImagem = 'image/png' | 'image/jpeg' | 'image/webp'
205
+
206
+ /** Imagem como vai no corpo do /ai/chat/stream: base64 sem o prefixo `data:`. */
207
+ export type ImagemEnviada = {
208
+ mime_type: TipoDeImagem
209
+ base64: string
210
+ }
211
+
212
+ /**
213
+ * Imagem exibida numa mensagem do usuario.
214
+ *
215
+ * Logo apos o envio ela vem do proprio arquivo (`url`, um blob local). No
216
+ * historico vem so a referencia no object storage (`objectName`), baixada
217
+ * quando a mensagem aparece.
218
+ */
219
+ export type ImagemDaMensagem = {
220
+ mimeType: string
221
+ url?: string
222
+ objectName?: string
223
+ }
224
+
225
+ /** Arquivo como o object storage devolve no download: `bytes` em base64. */
226
+ export type ArquivoDoStorage = {
227
+ contentType: string
228
+ bytes: string
229
+ fileName: string
230
+ }
231
+
190
232
  /** Resumo de uma conversa, como vem do GET /ai/chat/conversations. */
191
233
  export type ConversationSummary = {
192
234
  id: string
@@ -0,0 +1,12 @@
1
+ export type RelatorioQuebraData = {
2
+ contratoId: number,
3
+ viagemId: string,
4
+ dtCadastro: string,
5
+ motorista: string,
6
+ placa: string,
7
+ pesoNota: number,
8
+ pesoTicket: number,
9
+ valorQuebra: number,
10
+ difPorcentagem: number,
11
+ limiteQuebra: boolean,
12
+ }
@@ -21,6 +21,7 @@ const contratoFrete = {
21
21
  pagamentoPedagio: {endpoint: `${CONTRATO_FRETE_URL}/pagamento-pedagio`, method: 'put'},
22
22
  findRelatorioIcmsFrete: {endpoint: `${CONTRATO_FRETE_URL}/relatorio-icms-frete`, method: 'post'},
23
23
  atualizarPamcard: {endpoint: `${CONTRATO_FRETE_URL}/atualizar-pamcard/`, method: 'get'},
24
+ findRelatorioQuebra: {endpoint: `${CONTRATO_FRETE_URL}/relatorio-quebra`, method: 'post'},
24
25
  }
25
26
  export default contratoFrete
26
27
 
@@ -52,6 +52,16 @@ const subMenuRelatorios: NavigationTree[] = [
52
52
  authority: [ADMIN],
53
53
  subMenu: [],
54
54
  },
55
+ {
56
+ key: 'transportadora.relatorio.quebra',
57
+ path: '/transportadora/relatorio/quebra',
58
+ title: 'Relatório Quebra de Peso',
59
+ translateKey: 'nav.modules.transportadora.relatorios.relatorioQuebra',
60
+ icon: '',
61
+ type: NAV_ITEM_TYPE_ITEM,
62
+ authority: [ADMIN],
63
+ subMenu: [],
64
+ },
55
65
  ]
56
66
 
57
67
  export default subMenuRelatorios
@@ -8,6 +8,7 @@ import { TPageCalculoFreteRequest, TCalculoFreteResponse } from '@base/@types/ap
8
8
  import { TContratoPorDocumentoFilter } from '@base/@types/models/transportadora/contratoPorDocumento';
9
9
  import { TContratoPorDocumentoResponse } from '@base/@types/api/response/transportadora/TContratoPorDocumentoResponse';
10
10
  import { TControleEmbarque } from '@base/@types/models/transportadora/controleEmbarque';
11
+ import { RelatorioQuebraData } from '@base/@types/api/response/transportadora/RelatorioQuebraData';
11
12
 
12
13
  const CONTRATO_FRETE_PROJECT_ENDPOINT = endpointConfig.contratoFrete;
13
14
 
@@ -156,4 +157,12 @@ export async function apiAtualizarPamcardContratoFrete(viagemId: string | number
156
157
  url: CONTRATO_FRETE_PROJECT_ENDPOINT.atualizarPamcard.endpoint + viagemId,
157
158
  method: CONTRATO_FRETE_PROJECT_ENDPOINT.atualizarPamcard.method,
158
159
  })
160
+ }
161
+
162
+ export async function apiFindRelatorioQuebra(body?: Record<string, unknown>) {
163
+ return ApiService.fetchDataWithAxios<TQueryResponse<RelatorioQuebraData>>({
164
+ url: CONTRATO_FRETE_PROJECT_ENDPOINT.findRelatorioQuebra.endpoint,
165
+ method: CONTRATO_FRETE_PROJECT_ENDPOINT.findRelatorioQuebra.method,
166
+ data: body,
167
+ })
159
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbe-agro/client-core",
3
- "version": "5.6.336",
3
+ "version": "5.6.338",
4
4
  "description": "Biblioteca principal de componentes e utilidades para os microfrontends do Orbe Agro.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",