@orbe-agro/client-core 5.6.234 → 5.6.236

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 (63) hide show
  1. package/dist/@ecme/assets/styles/app.css +3 -0
  2. package/dist/@ecme/assets/styles/tailwind/index.css +3 -0
  3. package/dist/@ecme/components/template/Footer.js +1 -1
  4. package/dist/@ecme/components/template/Search.js +4 -1
  5. package/dist/@ecme/components/template/Search.js.map +1 -1
  6. package/dist/@ecme/index.js +0 -2
  7. package/dist/@ecme/index.js.map +1 -1
  8. package/dist/@ecme/views/dashboards/FavoritesLanding/FavoritesLanding.js +92 -0
  9. package/dist/@ecme/views/dashboards/FavoritesLanding/FavoritesLanding.js.map +1 -0
  10. package/dist/@ecme/views/dashboards/FavoritesLanding/index.js +5 -0
  11. package/dist/@ecme/views/dashboards/FavoritesLanding/index.js.map +1 -0
  12. package/dist/@ecme/views/dashboards/FavoritesLanding/types.js +2 -0
  13. package/dist/@ecme/views/dashboards/FavoritesLanding/types.js.map +1 -0
  14. package/dist/@ecme/views/dashboards/FavoritesLanding/utils.js +36 -0
  15. package/dist/@ecme/views/dashboards/FavoritesLanding/utils.js.map +1 -0
  16. package/dist/@ecme/views/dashboards/index.js +1 -4
  17. package/dist/@ecme/views/dashboards/index.js.map +1 -1
  18. package/dist/@ecme/views/index.js +0 -2
  19. package/dist/@ecme/views/index.js.map +1 -1
  20. package/dist/@types/@ecme/components/template/Search.d.ts +2 -0
  21. package/dist/@types/@ecme/components/template/Search.d.ts.map +1 -1
  22. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/FavoritesLanding.d.ts +9 -0
  23. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/FavoritesLanding.d.ts.map +1 -0
  24. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/index.d.ts +3 -0
  25. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/index.d.ts.map +1 -0
  26. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/types.d.ts +17 -0
  27. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/types.d.ts.map +1 -0
  28. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/utils.d.ts +5 -0
  29. package/dist/@types/@ecme/views/dashboards/FavoritesLanding/utils.d.ts.map +1 -0
  30. package/dist/@types/@ecme/views/dashboards/index.d.ts +0 -1
  31. package/dist/@types/@ecme/views/dashboards/index.d.ts.map +1 -1
  32. package/dist/@types/@ecme/views/index.d.ts +0 -1
  33. package/dist/@types/@ecme/views/index.d.ts.map +1 -1
  34. package/dist/@types/base/@types/models/performance/ppr.d.ts +4 -0
  35. package/dist/@types/base/@types/models/performance/ppr.d.ts.map +1 -1
  36. package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts +2 -0
  37. package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts.map +1 -1
  38. package/dist/@types/base/configs/endpoints.config/performance/config/ppr.d.ts +2 -0
  39. package/dist/@types/base/configs/endpoints.config/performance/config/ppr.d.ts.map +1 -1
  40. package/dist/@types/base/configs/endpoints.config/performance/performance.d.ts +2 -0
  41. package/dist/@types/base/configs/endpoints.config/performance/performance.d.ts.map +1 -1
  42. package/dist/@types/base/services/modules/performance/PerformanceService.d.ts +3 -1
  43. package/dist/@types/base/services/modules/performance/PerformanceService.d.ts.map +1 -1
  44. package/dist/base/assets/styles/init.css +3 -0
  45. package/dist/base/configs/endpoints.config/performance/config/ppr.js +2 -0
  46. package/dist/base/configs/endpoints.config/performance/config/ppr.js.map +1 -1
  47. package/dist/base/index.js +3 -1
  48. package/dist/base/services/index.js +3 -1
  49. package/dist/base/services/modules/index.js +3 -1
  50. package/dist/base/services/modules/performance/PerformanceService.js +15 -0
  51. package/dist/base/services/modules/performance/PerformanceService.js.map +1 -1
  52. package/dist/base/services/modules/performance/index.js +3 -1
  53. package/lib/@ecme/components/template/Search.tsx +4 -1
  54. package/lib/@ecme/views/dashboards/FavoritesLanding/FavoritesLanding.tsx +124 -0
  55. package/lib/@ecme/views/dashboards/FavoritesLanding/index.ts +3 -0
  56. package/lib/@ecme/views/dashboards/FavoritesLanding/types.ts +17 -0
  57. package/lib/@ecme/views/dashboards/FavoritesLanding/utils.ts +51 -0
  58. package/lib/@ecme/views/dashboards/index.ts +1 -3
  59. package/lib/@ecme/views/index.ts +1 -1
  60. package/lib/base/@types/models/performance/ppr.ts +5 -0
  61. package/lib/base/configs/endpoints.config/performance/config/ppr.ts +3 -0
  62. package/lib/base/services/modules/performance/PerformanceService.ts +16 -0
  63. package/package.json +1 -1
@@ -0,0 +1,124 @@
1
+ import { useMemo } from 'react'
2
+ import { useNavigate } from 'react-router-dom'
3
+ import { useTranslation } from 'react-i18next'
4
+ import useSWR from 'swr'
5
+ import Card from '@/components/ui/Card'
6
+ import Button from '@/components/ui/Button'
7
+ import Loading from '@/components/shared/Loading'
8
+ import navigationConfig from '@/configs/navigation.config'
9
+ import navigationIcon from '@/configs/navigation-icon.config'
10
+ import { filterNavigationByAuthority } from '@/components/template/Search'
11
+ import { useSessionUser } from '@/store/authStore'
12
+ import { apiFindFavoritosByUsuario } from '@base/services/modules/DadosMestres/FavoritoMenu/FavoritoMenuService'
13
+ import { PiStarDuotone } from 'react-icons/pi'
14
+ import { buildFavoriteNavMap } from './utils'
15
+ import type { FavoriteGroup } from './types'
16
+
17
+ type FavoritesLandingProps = {
18
+ title?: string
19
+ emptyStateMessage?: string
20
+ className?: string
21
+ }
22
+
23
+ export const FavoritesLandingBase = ({
24
+ title = 'Meus favoritos',
25
+ emptyStateMessage = 'Você ainda não adicionou nenhum favorito. Use a busca para marcar páginas com a estrela.',
26
+ className,
27
+ }: FavoritesLandingProps) => {
28
+ const { t } = useTranslation()
29
+ const navigate = useNavigate()
30
+ const userId = useSessionUser((state) => state.user.userId)
31
+ const userAuthority = useSessionUser((state) => state.user.authority)
32
+
33
+ const { data: favorites, isLoading } = useSWR(
34
+ userId ? ['/api/favoritos-menu/usuario', userId] : null,
35
+ () => apiFindFavoritosByUsuario(Number(userId)),
36
+ { revalidateOnFocus: false },
37
+ )
38
+
39
+ const navMap = useMemo(() => {
40
+ const filteredNavigationTree = filterNavigationByAuthority(
41
+ navigationConfig,
42
+ userAuthority || [],
43
+ )
44
+ return buildFavoriteNavMap(filteredNavigationTree)
45
+ }, [userAuthority])
46
+
47
+ const favoriteGroups = useMemo<FavoriteGroup[]>(() => {
48
+ if (!favorites || favorites.length === 0) return []
49
+
50
+ const sorted = [...favorites].sort((a, b) => a.ordem - b.ordem)
51
+ const groups = new Map<string, FavoriteGroup>()
52
+
53
+ sorted.forEach((fav) => {
54
+ const navInfo = navMap.get(fav.menuKey)
55
+ if (!navInfo) return
56
+
57
+ const group = groups.get(navInfo.moduleKey)
58
+ if (group) {
59
+ group.items.push(navInfo)
60
+ } else {
61
+ groups.set(navInfo.moduleKey, {
62
+ moduleKey: navInfo.moduleKey,
63
+ moduleTitle: t(
64
+ navInfo.moduleTranslateKey,
65
+ navInfo.moduleTitle,
66
+ ),
67
+ items: [navInfo],
68
+ })
69
+ }
70
+ })
71
+
72
+ return Array.from(groups.values())
73
+ }, [favorites, navMap, t])
74
+
75
+ return (
76
+ <Loading loading={isLoading}>
77
+ <div className={className}>
78
+ <h3 className="mb-4">{title}</h3>
79
+ {favoriteGroups.length === 0 ? (
80
+ <Card>
81
+ <p className="text-center text-gray-500">
82
+ {emptyStateMessage}
83
+ </p>
84
+ </Card>
85
+ ) : (
86
+ <div className="flex flex-col gap-4">
87
+ {favoriteGroups.map((group) => (
88
+ <Card
89
+ key={group.moduleKey}
90
+ header={{ content: group.moduleTitle }}
91
+ >
92
+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3">
93
+ {group.items.map((item) => (
94
+ <Button
95
+ key={item.key}
96
+ block
97
+ className="!justify-start gap-2 text-left"
98
+ icon={
99
+ navigationIcon[item.icon] ?? (
100
+ <PiStarDuotone />
101
+ )
102
+ }
103
+ onClick={() =>
104
+ navigate(item.path)
105
+ }
106
+ >
107
+ {t(item.translateKey, item.title)}
108
+ </Button>
109
+ ))}
110
+ </div>
111
+ </Card>
112
+ ))}
113
+ </div>
114
+ )}
115
+ </div>
116
+ </Loading>
117
+ )
118
+ }
119
+
120
+ export const FavoritesLanding = () => {
121
+ return <FavoritesLandingBase />
122
+ }
123
+
124
+ export default FavoritesLanding
@@ -0,0 +1,3 @@
1
+ import FavoritesLanding from './FavoritesLanding'
2
+
3
+ export default FavoritesLanding
@@ -0,0 +1,17 @@
1
+ export type FavoriteNavInfo = {
2
+ key: string
3
+ path: string
4
+ title: string
5
+ translateKey: string
6
+ icon: string
7
+ moduleKey: string
8
+ moduleTitle: string
9
+ moduleTranslateKey: string
10
+ moduleIcon: string
11
+ }
12
+
13
+ export type FavoriteGroup = {
14
+ moduleKey: string
15
+ moduleTitle: string
16
+ items: FavoriteNavInfo[]
17
+ }
@@ -0,0 +1,51 @@
1
+ import type { NavigationTree } from '@/@types/navigation'
2
+ import { NAV_ITEM_TYPE_ITEM } from '@/constants/navigation.constant'
3
+ import type { FavoriteNavInfo } from './types'
4
+
5
+ /** Maps every leaf nav item to its top-level ancestor (the "module") for grouping favorites. */
6
+ export const buildFavoriteNavMap = (
7
+ navTree: NavigationTree[],
8
+ ): Map<string, FavoriteNavInfo> => {
9
+ const map = new Map<string, FavoriteNavInfo>()
10
+
11
+ const walk = (
12
+ items: NavigationTree[],
13
+ moduleInfo: {
14
+ key: string
15
+ title: string
16
+ translateKey: string
17
+ icon: string
18
+ } | null,
19
+ ) => {
20
+ items.forEach((item) => {
21
+ const currentModule = moduleInfo ?? {
22
+ key: item.key,
23
+ title: item.title,
24
+ translateKey: item.translateKey,
25
+ icon: item.icon,
26
+ }
27
+
28
+ if (item.type === NAV_ITEM_TYPE_ITEM && item.path) {
29
+ map.set(item.key, {
30
+ key: item.key,
31
+ path: item.path,
32
+ title: item.title,
33
+ translateKey: item.translateKey,
34
+ icon: item.icon,
35
+ moduleKey: currentModule.key,
36
+ moduleTitle: currentModule.title,
37
+ moduleTranslateKey: currentModule.translateKey,
38
+ moduleIcon: currentModule.icon,
39
+ })
40
+ }
41
+
42
+ if (item.subMenu && item.subMenu.length > 0) {
43
+ walk(item.subMenu, currentModule)
44
+ }
45
+ })
46
+ }
47
+
48
+ walk(navTree, null)
49
+
50
+ return map
51
+ }
@@ -1,3 +1 @@
1
- // Dashboard components exports
2
- // Add specific dashboard component exports as needed
3
- export const dashboardsPlaceholder = 'Dashboard components';
1
+
@@ -11,7 +11,7 @@ export * from './auth-demo';
11
11
  export * from './concepts';
12
12
 
13
13
  // Dashboard views
14
- export * from './dashboards';
14
+ // export * from './dashboards';
15
15
 
16
16
  // Guide views
17
17
  export * from './guide';
@@ -241,6 +241,11 @@ export type TEnviarAprovacaoLancamentoResultadoPpr = {
241
241
  periodo: number
242
242
  }
243
243
 
244
+ export type TUsuariosMetaGlobalPpr = {
245
+ responsaveisIds: number[]
246
+ validadoresIds: number[]
247
+ }
248
+
244
249
  export type TCentroCustoElegivel = {
245
250
  parametroCcId: number
246
251
  codigoCentroCusto: string
@@ -6,6 +6,7 @@ const ppr = {
6
6
  updateResponsaveis: '/performance/api/ppr/centros-custos',
7
7
  indicadoresMetaGlobal: '/performance/api/ppr/indicadores/meta-global',
8
8
  indicadoresMetaGlobalFindMonitor: '/performance/api/ppr/indicadores/meta-global/find-monitor',
9
+ indicadoresMetaGlobalUsuariosElegiveis: '/performance/api/ppr/indicadores/meta-global/usuarios-elegiveis',
9
10
  indicadoresMetaSetorialGeral: '/performance/api/ppr/indicadores/meta-setorial-geral',
10
11
  indicadoresMetaSetorialGeralFindMonitor: '/performance/api/ppr/indicadores/meta-setorial-geral/find-monitor',
11
12
  indicadoresMetaSetorialPorCc: '/performance/api/ppr/indicadores/meta-setorial-por-cc',
@@ -14,6 +15,8 @@ const ppr = {
14
15
  lancamentosResultadoEnviarAprovacao: '/performance/api/ppr/lancamentos-resultado/enviar-aprovacao',
15
16
  lancamentosResultadoIndicadoresElegiveis: '/performance/api/ppr/lancamentos-resultado/indicadores-elegiveis',
16
17
  lancamentosResultadoCentrosCustoElegiveis: '/performance/api/ppr/lancamentos-resultado/centros-custo-elegiveis',
18
+ lancamentosResultadoCentrosCustoElegiveisValidacao:
19
+ '/performance/api/ppr/lancamentos-resultado/centros-custo-elegiveis-validacao',
17
20
  lancamentosResultadoIndicadoresElegiveisValidacao: '/performance/api/ppr/lancamentos-resultado/indicadores-elegiveis-validacao',
18
21
  lancamentosResultadoAprovar: '/performance/api/ppr/lancamentos-resultado/aprovar',
19
22
  lancamentosResultadoRecusar: '/performance/api/ppr/lancamentos-resultado/recusar',
@@ -33,6 +33,7 @@ import {
33
33
  TUpdateIndicadorMetaSetorialPorCc,
34
34
  TUpdateParametroCcResponsaveisPpr,
35
35
  TUpdateParametroCcStatusPpr,
36
+ TUsuariosMetaGlobalPpr,
36
37
  } from '@base/@types/models/performance/ppr'
37
38
  import { endpointsConfig } from '@base/configs'
38
39
  import ApiService from '@/services/ApiService'
@@ -388,6 +389,13 @@ export async function apiDeleteIndicadorMetaSetorialPorCc(id: number) {
388
389
  })
389
390
  }
390
391
 
392
+ export async function apiGetUsuariosMetaGlobalPpr() {
393
+ return ApiService.fetchDataWithAxios<TUsuariosMetaGlobalPpr>({
394
+ url: endpointsConfig.performance.ppr.indicadoresMetaGlobalUsuariosElegiveis,
395
+ method: 'get',
396
+ })
397
+ }
398
+
391
399
  export async function apiGetCentrosCustoElegiveisPpr(ano: number) {
392
400
  return ApiService.fetchDataWithAxios<TCentroCustoElegivel[]>({
393
401
  url: endpointsConfig.performance.ppr.lancamentosResultadoCentrosCustoElegiveis,
@@ -396,6 +404,14 @@ export async function apiGetCentrosCustoElegiveisPpr(ano: number) {
396
404
  })
397
405
  }
398
406
 
407
+ export async function apiGetCentrosCustoElegiveisValidacaoPpr(ano: number) {
408
+ return ApiService.fetchDataWithAxios<TCentroCustoElegivel[]>({
409
+ url: endpointsConfig.performance.ppr.lancamentosResultadoCentrosCustoElegiveisValidacao,
410
+ method: 'get',
411
+ params: { ano },
412
+ })
413
+ }
414
+
399
415
  export async function apiGetIndicadoresElegiveisPpr(data: { ano: number; parametroCcId: number | null }) {
400
416
  return ApiService.fetchDataWithAxios<TIndicadorPreenchimentoElegivel[]>({
401
417
  url: endpointsConfig.performance.ppr.lancamentosResultadoIndicadoresElegiveis,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbe-agro/client-core",
3
- "version": "5.6.234",
3
+ "version": "5.6.236",
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",