@vixoniccom/aniversarios 1.2.3-dev.1 → 1.2.3-dev.2

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 (42) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build.zip +0 -0
  3. package/configuration/appearanceGroup/AppearanceInputs.ts +101 -0
  4. package/configuration/appearanceGroup/index.ts +8 -0
  5. package/configuration/dataGroup/DataInputs.ts +52 -0
  6. package/configuration/dataGroup/index.ts +8 -0
  7. package/configuration/index.ts +8 -0
  8. package/configuration/standardGroup/StandardInputs.ts +211 -0
  9. package/configuration/standardGroup/index.ts +8 -0
  10. package/configuration/utils.ts +17 -0
  11. package/configuration.json +186 -207
  12. package/package.json +2 -2
  13. package/src/App.tsx +14 -113
  14. package/src/anniversary-loader.ts +70 -0
  15. package/src/components/AnniversaryItem/components/AnniversaryDate/CircleDate/index.tsx +5 -6
  16. package/src/components/AnniversaryItem/components/AnniversaryDate/FlatDate/index.tsx +5 -6
  17. package/src/components/AnniversaryItem/components/AnniversaryDate/OutlineDate/index.tsx +5 -6
  18. package/src/components/AnniversaryItem/components/AnniversaryDate/TextCalendarDate/index.tsx +4 -5
  19. package/src/components/AnniversaryItem/components/AnniversaryDate/TextDate/index.tsx +4 -5
  20. package/src/components/AnniversaryItem/components/AnniversaryDate/index.tsx +4 -4
  21. package/src/components/AnniversaryItem/components/ClassicItem/index.tsx +8 -8
  22. package/src/components/AnniversaryItem/index.tsx +4 -4
  23. package/src/components/FontLoader/index.tsx +5 -10
  24. package/src/components/ItemsContainer/components/animation.ts +4 -6
  25. package/src/components/ItemsContainer/index.tsx +7 -7
  26. package/src/components/Render/index.tsx +12 -13
  27. package/src/global.d.ts +8 -0
  28. package/src/main.ts +46 -0
  29. package/src/parameters.d.ts +4 -119
  30. package/src/service-parsers.ts +40 -0
  31. package/src/test/parameters.json +3 -2
  32. package/src/test/services.json +158 -0
  33. package/src/context/configureContext/ConfigureContext.tsx +0 -8
  34. package/src/context/configureContext/ConfigureProvider.tsx +0 -72
  35. package/src/context/configureContext/configureReducer.ts +0 -62
  36. package/src/context/dataContext/DataContex.tsx +0 -8
  37. package/src/context/dataContext/DataProvider.tsx +0 -25
  38. package/src/context/dataContext/dataReducer.ts +0 -12
  39. package/src/helpers/filterEmployees.ts +0 -38
  40. package/src/helpers/getEmployees.ts +0 -29
  41. package/src/helpers/utils.ts +0 -46
  42. package/src/main.tsx +0 -43
@@ -1,124 +1,9 @@
1
-
2
-
3
1
  declare type VixonicData = {
4
- parameters: VixonicParameters,
5
- services?: { [key: string]: { data?: any, updatedAt?: number } }
6
2
  downloadsPath: string
3
+ services: { [key: string]: { data?: any, updatedAt?: number } }
4
+ parameters: VixonicParameters
7
5
  }
8
6
 
9
-
10
7
  declare type VixonicParameters = Partial<{
11
- abbreviatedMonths: boolean
12
- animationMode: string
13
- animationOrder: boolean
14
- animationSpeed: number
15
- animationTime: string
16
- animationStagger:number
17
- apiDomain: string
18
- backgroundImage: GeneralData
19
- containerColumns: string
20
- containerRows: string
21
- containerRowsGap: string
22
- containerColumnsGap:string
23
- dataMode: string
24
- dateAlignment: keyof typeof alignment
25
- dateDayFormat: DateFormat
26
- dateEnabled: boolean
27
- dateMonthFormat: DateFormat
28
- datePosition: number
29
- datePrimaryColor: string
30
- dateStyle: keyof typeof styles
31
- descriptionEnabled: boolean
32
- descriptionFormat: DateFormat
33
- optionalEnabled: boolean
34
- optionalFormat: DateFormat
35
- excludePast: boolean
36
- imageAlignment: keyof typeof alignment
37
- imageEnabled: boolean
38
- imagePosition: number
39
- imageStyle: keyof typeof borderStyles,
40
- imageSize: number
41
- itemMargins: string
42
- msj0: string
43
- nameFormat: DateFormat
44
- orientation: string
45
- padding: string
46
- photosMode: string
47
- photosZip: GeneralData
48
- template: string
49
- textAlignment: keyof typeof alignment
50
- textPosition: number
51
- updateTime: number
52
- urlBaseApi: string,
53
- imageMargin: string,
54
- textMargin: string,
55
- dateMargin: string,
56
- separator: boolean,
57
- separatorWidth: number,
58
- separatorColor: string,
59
- nameMaxChar: number,
60
- descriptionMaxChar: number,
61
- }>
62
-
63
-
64
- declare type DataEmployee = {
65
- apellidoPate: string
66
- area: string
67
- cargo: string
68
- contrato: string
69
- empleado: string
70
- empresa: string
71
- estado: string
72
- fechaInic: string
73
- modalidad_contrato: string
74
- nombre: string
75
- sede: string
76
- situacion: string
77
- tipoCont: string,
78
- nombreCargo: string,
79
- day:number
80
- month:number
81
- name:string
82
- position:string
83
- image:string
84
- optional: string
85
- }
86
-
87
- declare type Employees = {
88
- dataEmployee: DataEmployee[] | any[][]
89
- }
90
-
91
- type GeneralData = {
92
- filename?: string
93
- id?: string,
94
- extension?: string,
95
- _isAsset: boolean
96
- }
97
-
98
- type DateFormat = {
99
- alignment?: { horizontal?: 'left' | 'right' | 'center' },
100
- font?: GeneralData,
101
- fontColor?: string,
102
- fontSize?: number
103
- }
104
-
105
- const alignment = {
106
- start: 'flex-start',
107
- center: 'center',
108
- end: 'flex-end'
109
- }
110
-
111
-
112
- const borderStyles = {
113
- normal: '0',
114
- rounded: '10',
115
- circle: '100'
116
- }
117
-
118
- const styles = {
119
- text: 'text',
120
- calendarFlat: 'calendarFlat',
121
- calendarText: 'calendarText',
122
- circle: 'circle',
123
- outlines: 'outlines'
124
- }
8
+ displayService: 'AnniversaryAppService' | 'RexmasAnniversarieService', documentService: { id: string }, rexmasService: { id: string }, photosZip: {id?: string, filename?: string, extension?: string}, updateTime: 600000 | 1800000 | 3600000 | 21600000 | 43200000 | 86400000 | 604800000, defaultMessage: string, defaultMessageFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, orientation: 'h' | 'v', animationMode: 'fade' | 'slideRight' | 'slideLeft', animationSpeed: 2 | 1.5 | 1, animationOrder: boolean, animationTime: number, containerColumns: number, containerColumnsGap: number, containerRows: number, containerRowsGap: number, backgroundImage: {id?: string, filename?: string, extension?: string}, padding: string, textPosition: 1 | 2 | 3, textAlignment: 'start' | 'center' | 'end', nameFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, nameMaxChar: number, textMargin: string, descriptionEnabled: boolean, descriptionFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, descriptionMaxChar: number, optionalEnabled: boolean, optionalFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, imageEnabled: boolean, imagePosition: 1 | 2 | 3, imageAlignment: 'start' | 'center' | 'end', imageStyle: 'normal' | 'rounded' | 'circle', imageMargin: string, imageSize: number, dateEnabled: boolean, datePosition: 1 | 2 | 3, dateAlignment: 'start' | 'center' | 'end', dateStyle: 'calendarFlat' | 'calendarText' | 'circle' | 'text' | 'outlines', dateDayFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, dateMonthFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, abbreviatedMonths: boolean, datePrimaryColor: string, dateMargin: string, separator: boolean, separatorWidth: number, separatorColor: string, itemMargins: string
9
+ }>
@@ -0,0 +1,40 @@
1
+ export class AnniversaryServiceParsers {
2
+ static readonly AnniversaryAppService = {
3
+ parse: (data: any[]): Anniversary[] => {
4
+ return data.map(item => ({
5
+ month: item.month,
6
+ day: item.day,
7
+ name: item.name,
8
+ image: item.image,
9
+ }))
10
+ }
11
+ }
12
+
13
+ static readonly RexmasAnniversaryService = {
14
+ parse: (data: any[]): Anniversary[] => {
15
+ return data.map(item => ({
16
+ month: item.month,
17
+ day: item.day,
18
+ name: item.name,
19
+ description: undefined,
20
+ image: item.image,
21
+ optional: undefined
22
+ }))
23
+ }
24
+ }
25
+
26
+ static getParser(serviceType: VixonicData['parameters']['displayService']): ServiceParser {
27
+ switch (serviceType) {
28
+ case 'AnniversaryAppService':
29
+ return this.AnniversaryAppService
30
+ case 'RexmasAnniversarieService':
31
+ return this.RexmasAnniversaryService
32
+ default:
33
+ return this.AnniversaryAppService
34
+ }
35
+ }
36
+ }
37
+
38
+ export interface ServiceParser {
39
+ parse: (data: any[]) => Anniversary[]
40
+ }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "parameters": {
3
- "apiDomain": "https://docs.google.com/spreadsheets/d/1nxPf6Y97fPubVE9mWhShrWvcXAlndD4x-qSvdjgoIVk/edit?usp=sharing",
4
- "msj0": "No ingresos",
3
+ "documentService": {"id":"0159f12d-4a7d-24d1-f260-f33908c049e22"},
4
+ "rexmasService": {"id":"12b64ef1-0c66-c4ae-8797-9113e1063c4c"},
5
+ "defaultMessage": "No ingresos",
5
6
  "padding": "365px 25px 80px 40px",
6
7
  "dataMode": "monthly",
7
8
  "template": "standard",
@@ -0,0 +1,158 @@
1
+ {
2
+ "services": {
3
+ "d3e82496-63af-5992-96dc-7d9639d21dd6": {
4
+ "id": "d3e82496-63af-5992-96dc-7d9639d21dd6",
5
+ "data": [
6
+ {
7
+ "day": 14,
8
+ "month": 6,
9
+ "name": "MANUEL SOMOZA",
10
+ "description": "CORPORATIVO",
11
+ "image": "Foto prueba.jpg"
12
+ },
13
+ {
14
+ "day": 14,
15
+ "month": 6,
16
+ "name": "ANTONIO BELLO",
17
+ "description": "CORPORATIVO",
18
+ "image": "Foto prueba.jpg"
19
+ },
20
+ {
21
+ "day": 16,
22
+ "month": 6,
23
+ "name": "MARIA DEL PILAR MARTINEZ",
24
+ "description": "FORD DURANGO",
25
+ "image": "Foto prueba.jpg"
26
+ },
27
+ {
28
+ "day": 17,
29
+ "month": 6,
30
+ "name": "AXEL ZALDIVAR",
31
+ "description": "JAC METEPEC",
32
+ "image": "Foto prueba.jpg"
33
+ },
34
+ {
35
+ "day": 18,
36
+ "month": 6,
37
+ "name": "GUSTAVO MENDEZ",
38
+ "description": "PEUGEOT ARBOLEDAS",
39
+ "image": "Foto prueba.jpg"
40
+ },
41
+ {
42
+ "day": 19,
43
+ "month": 6,
44
+ "name": "CARLOS CAMPOS",
45
+ "description": "JAC METEPEC",
46
+ "image": "Foto prueba.jpg"
47
+ },
48
+ {
49
+ "day": 19,
50
+ "month": 6,
51
+ "name": "CRISTIAN HOLGUIN",
52
+ "description": "CORPORATIVO",
53
+ "image": "Foto prueba.jpg"
54
+ },
55
+ {
56
+ "day": 20,
57
+ "month": 6,
58
+ "name": "MARIA DOMINGUEZ",
59
+ "description": "JAC CUERNAVACA",
60
+ "image": "Foto prueba.jpg"
61
+ },
62
+ {
63
+ "day": 20,
64
+ "month": 6,
65
+ "name": "DANIEL PEREZ",
66
+ "description": "CORPORATIVO",
67
+ "image": "Foto prueba.jpg"
68
+ },
69
+ {
70
+ "day": 21,
71
+ "month": 6,
72
+ "name": "ORLANDO QUIROZ",
73
+ "description": "PEUGEOT ARBOLEDAS",
74
+ "image": "Foto prueba.jpg"
75
+ },
76
+ {
77
+ "day": 26,
78
+ "month": 6,
79
+ "name": "LIZZA GUZMAN",
80
+ "description": "FORD DURANGO",
81
+ "image": "Foto prueba.jpg"
82
+ },
83
+ {
84
+ "day": 26,
85
+ "month": 6,
86
+ "name": "MONTSERRAT TORRES",
87
+ "description": "LEXUS SANTA FE",
88
+ "image": "Foto prueba.jpg"
89
+ },
90
+ {
91
+ "day": 28,
92
+ "month": 6,
93
+ "name": "PAOLA ALEMAN",
94
+ "description": "CORPORATIVO",
95
+ "image": "Foto prueba.jpg"
96
+ },
97
+ {
98
+ "day": 30,
99
+ "month": 6,
100
+ "name": "FANNY ANDRADE",
101
+ "description": "FORD DURANGO",
102
+ "image": "Foto prueba.jpg"
103
+ }
104
+ ],
105
+ "updatedAt": 1749672137077,
106
+ "__typename": "AnniversaryAppService"
107
+ },
108
+ "12b64ef1-0c66-c4ae-8797-9113e1063c4c": {
109
+ "id": "12b64ef1-0c66-c4ae-8797-9113e1063c4c",
110
+ "data": [
111
+ {
112
+ "day": 5,
113
+ "month": 5,
114
+ "name": "Juan Esteban Cárdenas",
115
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/18749054-5.jpg"
116
+ },
117
+ {
118
+ "day": 5,
119
+ "month": 5,
120
+ "name": "CARLA ELENA OYARZÚN",
121
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/12810705-3.png"
122
+ },
123
+ {
124
+ "day": 7,
125
+ "month": 5,
126
+ "name": "César Claudio Llancafil",
127
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/20761855-1.png"
128
+ },
129
+ {
130
+ "day": 16,
131
+ "month": 5,
132
+ "name": "JOSE MIGUEL DUQUE",
133
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/13461287-8.png"
134
+ },
135
+ {
136
+ "day": 17,
137
+ "month": 5,
138
+ "name": "CARLOS EDUARDO RIVERA",
139
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/25455086-8.jpg"
140
+ },
141
+ {
142
+ "day": 22,
143
+ "month": 5,
144
+ "name": "Pablo Baltazar Troncoso",
145
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/18407251-3.jpg"
146
+ },
147
+ {
148
+ "day": 29,
149
+ "month": 5,
150
+ "name": "Elizabeth Marcela Urdaneta",
151
+ "image": "https://s3.us-east-2.amazonaws.com/payroll-prod-chile/media/static/entidades/losnavegantes/25440150-1.png"
152
+ }
153
+ ],
154
+ "updatedAt": 1749670622134,
155
+ "__typename": "RexmasBirthdayService"
156
+ }
157
+ }
158
+ }
@@ -1,8 +0,0 @@
1
- import { createContext } from "react"
2
-
3
- type ConfigureContext = {
4
- configureState: VixonicData
5
- addConfiguration: (configure: VixonicData) => void
6
- }
7
-
8
- export const ConfigureContext = createContext<ConfigureContext>({} as ConfigureContext);
@@ -1,72 +0,0 @@
1
- import React, { useReducer } from "react"
2
- import { ConfigureContext } from './ConfigureContext'
3
- import { anniversaryReducer } from "./configureReducer"
4
-
5
- const INITIAL_STATE: VixonicData = {
6
- downloadsPath: '',
7
- parameters: {
8
- abbreviatedMonths: false,
9
- animationMode: "",
10
- animationOrder: false,
11
- animationSpeed: 1.5,
12
- animationTime: "",
13
- backgroundImage: { id: "", filename: "", _isAsset: true },
14
- apiDomain: "",
15
- containerColumns: "",
16
- containerRows: "",
17
- containerRowsGap: "",
18
- containerColumnsGap: "",
19
- dataMode: "",
20
- dateAlignment: "center",
21
- dateDayFormat: { font: { filename: '', id: '', _isAsset: true }, fontSize: 55, alignment: { horizontal: "center" }, fontColor: "", },
22
- dateEnabled: true,
23
- dateMonthFormat: { font: { filename: '', id: '', _isAsset: true }, fontSize: 20, alignment: { horizontal: "center" }, fontColor: "" },
24
- datePosition: 1,
25
- datePrimaryColor: "",
26
- dateStyle: "circle",
27
- descriptionEnabled: true,
28
- descriptionFormat: { font: { filename: '', id: '', _isAsset: true }, fontSize: 3.8, alignment: { horizontal: "center" }, fontColor: "" },
29
- optionalEnabled: true,
30
- optionalFormat: { font: { filename: '', id: '', _isAsset: true }, fontSize: 3.8, alignment: { horizontal: "center" }, fontColor: "" },
31
- excludePast: false,
32
- imageAlignment: "center",
33
- imageEnabled: true,
34
- imagePosition: 0,
35
- imageStyle: "normal",
36
- imageSize: 50,
37
- itemMargins: "",
38
- msj0: "",
39
- nameFormat: { font: { filename: '', id: '', _isAsset: true }, fontSize: 3.8, alignment: { horizontal: "center" }, fontColor: "" },
40
- orientation: "",
41
- padding: "",
42
- photosMode: "",
43
- photosZip: { id: "0fb559ec-5da3-4b2d-95c4-d9623754c841", filename: "0fb559ec-5da3-4b2d-95c4-d9623754c841.zip", extension: "zip", _isAsset: true },
44
- template: "",
45
- textAlignment: "center",
46
- textPosition: 0,
47
- updateTime: 600000,
48
- urlBaseApi: "",
49
- imageMargin: "",
50
- textMargin: "",
51
- dateMargin: "",
52
- separator: false
53
- }
54
- }
55
-
56
- interface props {
57
- children: JSX.Element | JSX.Element[]
58
- }
59
-
60
- export const AnniversaryProvider = ({ children }: props) => {
61
- const [configureState, dispatch] = useReducer(anniversaryReducer, INITIAL_STATE)
62
-
63
- const addConfiguration = (configure: VixonicData) => {
64
- dispatch({ type: "addConfigure", payload: configure })
65
- }
66
-
67
- return (
68
- <ConfigureContext.Provider value={{ configureState, addConfiguration }}>
69
- {children}
70
- </ConfigureContext.Provider>
71
- )
72
- }
@@ -1,62 +0,0 @@
1
- type ConfigureAction = { type: 'addConfigure', payload: VixonicData }
2
-
3
- export const anniversaryReducer = (state: VixonicData, action: ConfigureAction) => {
4
- const { downloadsPath, parameters } = action.payload
5
- switch (action.type) {
6
- case 'addConfigure':
7
- return {
8
- downloadsPath: downloadsPath,
9
- parameters: {
10
- abbreviatedMonths: parameters.abbreviatedMonths,
11
- animationMode: parameters.animationMode,
12
- animationOrder: parameters.animationOrder,
13
- animationSpeed: parameters.animationSpeed,
14
- animationTime: parameters.animationTime,
15
- apiDomain: parameters.apiDomain,
16
- backgroundImage: parameters.backgroundImage,
17
- containerColumns: parameters.containerColumns,
18
- containerColumnsGap: parameters.containerColumnsGap,
19
- containerRows: parameters.containerRows,
20
- containerRowsGap: parameters.containerRowsGap,
21
- dataMode: parameters.dataMode,
22
- dateAlignment: parameters.dateAlignment,
23
- dateDayFormat: parameters.dateDayFormat,
24
- dateEnabled: parameters.dateEnabled,
25
- dateMonthFormat: parameters.dateMonthFormat,
26
- datePosition: parameters.datePosition,
27
- datePrimaryColor: parameters.datePrimaryColor,
28
- dateStyle: parameters.dateStyle,
29
- descriptionEnabled: parameters.descriptionEnabled,
30
- descriptionFormat: parameters.descriptionFormat,
31
- optionalEnabled: parameters.optionalEnabled,
32
- optionalFormat: parameters.optionalFormat,
33
- excludePast: parameters.excludePast,
34
- imageAlignment: parameters.imageAlignment,
35
- imageEnabled: parameters.imageEnabled,
36
- imagePosition: parameters.imagePosition,
37
- imageSize: parameters.imageSize,
38
- imageStyle: parameters.imageStyle,
39
- itemMargins: parameters.itemMargins,
40
- msj0: parameters.msj0,
41
- nameFormat: parameters.nameFormat,
42
- orientation: parameters.orientation,
43
- padding: parameters.padding,
44
- photosMode: parameters.photosMode,
45
- photosZip: parameters.photosZip,
46
- template: parameters.template,
47
- textAlignment: parameters.textAlignment,
48
- textPosition: parameters.textPosition,
49
- updateTime: parameters.updateTime,
50
- urlBaseApi: parameters.urlBaseApi,
51
- imageMargin: parameters.imageMargin,
52
- textMargin: parameters.textMargin,
53
- dateMargin: parameters.dateMargin,
54
- separator: parameters.separator,
55
- nameMaxChar: parameters.nameMaxChar,
56
- descriptionMaxChar: parameters.descriptionMaxChar
57
- }
58
- }
59
- default:
60
- return state;
61
- }
62
- }
@@ -1,8 +0,0 @@
1
- import { createContext } from 'react'
2
-
3
- type DataContext = {
4
- dataEmployee: any,
5
- addEmployee: (employee: DataEmployee[]) => void
6
- }
7
-
8
- export const DataContext = createContext<DataContext>({} as DataContext)
@@ -1,25 +0,0 @@
1
- import React, { useReducer } from 'react'
2
- import { DataContext } from './DataContex'
3
- import { dataReducer } from './dataReducer'
4
-
5
- const INITIAL_STATE: Employees = {
6
- dataEmployee: []
7
- }
8
-
9
- interface props {
10
- children: JSX.Element | JSX.Element[]
11
- }
12
-
13
- export const DataProvider = ({ children }: props) => {
14
- const [dataEmployee, dispatch] = useReducer(dataReducer, INITIAL_STATE)
15
-
16
- const addEmployee = (employee: DataEmployee[]) => {
17
- dispatch({ type: 'addAnniversary', payload: employee })
18
- }
19
-
20
- return (
21
- <DataContext.Provider value={{ dataEmployee, addEmployee }}>
22
- {children}
23
- </DataContext.Provider>
24
- )
25
- }
@@ -1,12 +0,0 @@
1
- type DataAction = { type: 'addAnniversary', payload: DataEmployee[] }
2
-
3
- export const dataReducer = (state: Employees, action: DataAction): Employees => {
4
- switch (action.type) {
5
- case 'addAnniversary':
6
- return {
7
- dataEmployee: action.payload
8
- }
9
- default:
10
- return state
11
- }
12
- }
@@ -1,38 +0,0 @@
1
- import moment from "moment"
2
-
3
- export const filterEmployees = (values: any, dataMode: string = 'month', excludePast: boolean = false, month: number) => {
4
- const today = moment()
5
- const day = moment().format("D")
6
- const numberMonth = Number(moment().format("M")) - 1
7
- let employees = values.map((val: any, index: number) => {
8
- if (index == 0) return
9
- return {
10
- day: Number(val[0]),
11
- name: val[1],
12
- position: val[2],
13
- image: val[3],
14
- optional: val[4],
15
- month
16
- }
17
- }).filter((val: any) => val !== undefined)
18
-
19
- if (dataMode === "daily")
20
- employees = employees.filter((contract: any) => contract.day == day)
21
- if (dataMode === "weekly") {
22
- employees = employees.filter((contract: any) => {
23
- const bdayDate = moment([today.year(), contract.month, contract.day])
24
- return bdayDate.isoWeek() === today.isoWeek()
25
- })
26
- }
27
-
28
- employees.sort((a: any, b: any) => {
29
- if (a.day < b.day) return -1
30
- else if (a.day === b.day) return 0
31
- else return 1
32
- })
33
-
34
- if (excludePast && (numberMonth >= month))
35
- employees = employees.filter((contract: any) => (contract.day >= day && contract.month >= numberMonth))
36
-
37
- return employees
38
- }
@@ -1,29 +0,0 @@
1
- import axios from "axios"
2
- import { getMonth } from "./utils"
3
-
4
- const API_KEY = 'AIzaSyDQcTlxfd5IyjbeSJooRtNt6OF04DLykqc'
5
-
6
- export const getEmployees = async (apiDomain: string, monthTab: string) => {
7
- const idGoogle = apiDomain.split("/")[5]
8
- const URL = `https://sheets.googleapis.com/v4/spreadsheets/${idGoogle}/values`
9
- try {
10
- const response = await axios({ url: `${URL}/${monthTab}?key=${API_KEY}` })
11
- return response
12
- } catch (error) {
13
- console.error(error)
14
- return error
15
- }
16
- }
17
-
18
- export const getEmployeesYearly = async (apiDomain: string, numberMonth: number) => {
19
- const idGoogle = apiDomain.split("/")[5]
20
- const URL = `https://sheets.googleapis.com/v4/spreadsheets/${idGoogle}/values`
21
- const monthTab = getMonth(numberMonth)
22
- try {
23
- const response = await axios({ url: `${URL}/${monthTab}?key=${API_KEY}` })
24
- return response
25
- } catch (error) {
26
- console.error(error)
27
- return error
28
- }
29
- }
@@ -1,46 +0,0 @@
1
- export const getMonth = (numberMonth: number) => {
2
- let month
3
- switch (numberMonth) {
4
- case 0:
5
- month = 'Enero'
6
- break
7
- case 1:
8
- month = 'Febrero'
9
- break
10
- case 2:
11
- month = 'Marzo'
12
- break
13
- case 3:
14
- month = 'Abril'
15
- break
16
- case 4:
17
- month = 'Mayo'
18
- break
19
- case 5:
20
- month = 'Junio'
21
- break
22
- case 6:
23
- month = 'Julio'
24
- break
25
- case 7:
26
- month = 'Agosto'
27
- break
28
- case 8:
29
- month = 'Septiembre'
30
- break
31
- case 9:
32
- month = 'Octubre'
33
- break
34
- case 10:
35
- month = 'Noviembre'
36
- break
37
- case 11:
38
- month = 'Diciembre'
39
- break
40
- default:
41
- month = 'ENERO'
42
- break
43
- }
44
-
45
- return month
46
- }