@vixoniccom/aniversarios 1.2.1 → 1.2.3-dev.0

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 (57) hide show
  1. package/CHANGELOG.md +28 -8
  2. package/build.zip +0 -0
  3. package/configuration.json +35 -6
  4. package/package.json +7 -9
  5. package/src/App.tsx +59 -73
  6. package/src/components/AnniversaryItem/components/AnniversaryDate/CircleDate/index.tsx +31 -0
  7. package/src/components/AnniversaryItem/components/AnniversaryDate/FlatDate/index.tsx +47 -0
  8. package/src/components/{anniversary-item/shared/anniversary-date/outline/OutlineDate.tsx → AnniversaryItem/components/AnniversaryDate/OutlineDate/index.tsx} +7 -25
  9. package/src/components/{anniversary-item/shared/anniversary-date/text-calendar/TextCalendarDate.tsx → AnniversaryItem/components/AnniversaryDate/TextCalendarDate/index.tsx} +7 -16
  10. package/src/components/{anniversary-item/shared/anniversary-date/text/TextDate.tsx → AnniversaryItem/components/AnniversaryDate/TextDate/index.tsx} +2 -12
  11. package/src/components/{anniversary-item/shared/anniversary-date/AnniversaryDate.tsx → AnniversaryItem/components/AnniversaryDate/index.tsx} +7 -11
  12. package/src/components/AnniversaryItem/components/AnniversaryDate/utils.ts +18 -0
  13. package/src/components/{anniversary-item/shared/AnniversaryImage.tsx → AnniversaryItem/components/AnniversaryImage/index.tsx} +11 -19
  14. package/src/components/AnniversaryItem/components/ClassicItem/index.tsx +109 -0
  15. package/src/components/{anniversary-item/shared/separator → AnniversaryItem/components/Separator}/Separator.tsx +3 -6
  16. package/src/components/AnniversaryItem/components/index.ts +11 -0
  17. package/src/components/AnniversaryItem/components/utils.ts +75 -0
  18. package/src/components/AnniversaryItem/index.tsx +17 -0
  19. package/src/components/{FontLoader.tsx → FontLoader/index.tsx} +11 -12
  20. package/src/components/FormattedText/index.tsx +81 -0
  21. package/src/components/{items-container → ItemsContainer/components}/Item.tsx +2 -10
  22. package/src/components/ItemsContainer/components/animation.ts +130 -0
  23. package/src/components/{items-container/ItemsContainer.tsx → ItemsContainer/index.tsx} +54 -61
  24. package/src/components/{Render.tsx → Render/index.tsx} +9 -11
  25. package/src/components/index.ts +13 -0
  26. package/src/context/configureContext/ConfigureContext.tsx +8 -0
  27. package/src/context/configureContext/ConfigureProvider.tsx +72 -0
  28. package/src/context/configureContext/configureReducer.ts +62 -0
  29. package/src/context/dataContext/DataContex.tsx +8 -0
  30. package/src/context/dataContext/DataProvider.tsx +25 -0
  31. package/src/context/dataContext/dataReducer.ts +12 -0
  32. package/src/helpers/filterEmployees.ts +31 -37
  33. package/src/helpers/getEmployees.ts +18 -22
  34. package/src/helpers/utils.ts +44 -50
  35. package/src/main.ts +0 -0
  36. package/src/main.tsx +2 -2
  37. package/src/test/parameters.json +97 -97
  38. package/tsconfig.json +4 -4
  39. package/src/components/FormattedText.tsx +0 -81
  40. package/src/components/anniversary-item/AnniversaryItem.tsx +0 -22
  41. package/src/components/anniversary-item/clasic/ClasicItem.tsx +0 -220
  42. package/src/components/anniversary-item/shared/anniversary-date/DateUtils.ts +0 -33
  43. package/src/components/anniversary-item/shared/anniversary-date/circle/CircleDate.tsx +0 -39
  44. package/src/components/anniversary-item/shared/anniversary-date/flat/FlatDate.tsx +0 -79
  45. package/src/components/anniversary-item/shared/utils.ts +0 -10
  46. package/src/components/items-container/animation.ts +0 -125
  47. package/src/contex/configureContext/ConfigureContext.tsx +0 -8
  48. package/src/contex/configureContext/ConfigureProvider.tsx +0 -77
  49. package/src/contex/configureContext/configureReducer.ts +0 -67
  50. package/src/contex/dataContext/DataContex.tsx +0 -8
  51. package/src/contex/dataContext/DataProvider.tsx +0 -31
  52. package/src/contex/dataContext/dataReducer.ts +0 -19
  53. package/src/helpers/parseMonthAndDay.ts +0 -38
  54. package/src/helpers/setToken.ts +0 -69
  55. package/src/hooks/useFetch.ts +0 -47
  56. package/src/model/income.ts +0 -129
  57. /package/src/components/{anniversary-item/shared → AnniversaryItem/components}/default-profile.png +0 -0
@@ -1,79 +0,0 @@
1
- import React, { useContext } from "react";
2
- import { ConfigureContext } from "../../../../../contex/configureContext/ConfigureContext";
3
- import { AnniveraryDateUtil } from "../DateUtils";
4
-
5
- interface Props {
6
- month: number;
7
- day: number;
8
- }
9
-
10
- export const FlatDate = ({ month, day }: Props) => {
11
- const { configureState } = useContext(ConfigureContext);
12
- const {
13
- abbreviatedMonths,
14
- dateDayFormat,
15
- dateMonthFormat,
16
- orientation,
17
- datePrimaryColor,
18
- } = configureState.parameters;
19
-
20
- const sizeProp = AnniveraryDateUtil.utils(orientation);
21
- let monthSize = ((dateMonthFormat?.fontSize || 18.5) * 400) / 100;
22
- let daySize = ((dateDayFormat?.fontSize || 57.5) * 400) / 100;
23
- const getFontFamily = (format: any) => {
24
- if (format && format.font && format.font.filename) {
25
- return format.font.filename.replace(".", "-");
26
- }
27
- return "";
28
- };
29
- return (
30
- <svg {...sizeProp} viewBox="0 0 400 400" xmlSpace="preserve">
31
- <g>
32
- <path
33
- fill={datePrimaryColor}
34
- d="M349.5,393.5h-299c-24.3,0-44-19.7-44-44v-299c0-24.3,19.7-44,44-44h299c24.3,0,44,19.7,44,44v299C393.5,373.8,373.8,393.5,349.5,393.5z"
35
- />
36
- <path
37
- fill="#FFFFFF"
38
- d="M349.5,389.5h-299c-22,0-40-18-40-40v-299c0-22,18-40,40-40h299c22,0,40,18,40,40v299C389.5,371.5,371.5,389.5,349.5,389.5z"
39
- />
40
- <path
41
- fill={datePrimaryColor}
42
- d="M9,99.9V50.5c0-22.2,18.1-40.3,40.3-40.3h301.4c22.2,0,40.3,18.1,40.3,40.3v49.4H9z"
43
- />
44
- <text
45
- fontFamily={`"${getFontFamily(dateMonthFormat)}"`}
46
- textAnchor="middle"
47
- alignmentBaseline="central"
48
- x="200"
49
- y="55"
50
- fontSize={monthSize}
51
- preserveAspectRatio="none"
52
- fill={dateMonthFormat?.fontColor || "#fff"}
53
- fontSizeAdjust=""
54
- >
55
- {AnniveraryDateUtil.getMonth(month, abbreviatedMonths)}
56
- </text>
57
- <text
58
- fontFamily={`"${getFontFamily(dateDayFormat)}"`}
59
- textAnchor="middle"
60
- alignmentBaseline="central"
61
- x="200"
62
- y="245"
63
- fontSize={daySize}
64
- preserveAspectRatio="none"
65
- fill={dateDayFormat?.fontColor || "#fff"}
66
- fontSizeAdjust=""
67
- >
68
- {AnniveraryDateUtil.getZeroLeadedText(day)}
69
- </text>
70
- </g>
71
- </svg>
72
- );
73
- };
74
-
75
- FlatDate.defaultProps = {
76
- datePrimaryColor: "#5B5959",
77
- };
78
-
79
- FlatDate.propTypes = AnniveraryDateUtil.commonPropTypes();
@@ -1,10 +0,0 @@
1
- export const utils = (orientation:string, size:number) => {
2
- const sizeAttr = orientation === 'v' ? 'width' : 'height'
3
- const percentage = size
4
- ? `${size}`
5
- : orientation === 'v' ? '40%' : '80%'
6
- return {
7
- [sizeAttr]: percentage
8
- }
9
- }
10
-
@@ -1,125 +0,0 @@
1
- import anime from 'animejs'
2
-
3
-
4
- interface Options {
5
- mode: keyof typeof animationModes
6
- duration: number
7
- speed: number
8
- stagger: number
9
- reverse: boolean
10
- }
11
-
12
- const animationModes = {
13
- fade: {
14
- in: {
15
- opacity: [0, 1],
16
- easing: 'linear',
17
- },
18
- out: {
19
- opacity: [1, 0],
20
- easing: 'linear',
21
- },
22
- init: {
23
- opacity: 0,
24
- },
25
- },
26
- slideRight: {
27
- in: {
28
- translateX: () => {
29
- return [`-100vw`, '0vw']
30
- },
31
- easing: 'easeOutQuad',
32
- },
33
- out: {
34
- translateX: () => {
35
- return ['0vw', `100vw`]
36
- },
37
- easing: 'easeInQuad',
38
- },
39
- init: {
40
- transform: 'translateX(-100vw)',
41
- },
42
- },
43
- slideLeft: {
44
- in: {
45
- translateX: () => {
46
- return [`100vw`, '0vw']
47
- },
48
- easing: 'easeOutQuad',
49
- },
50
- out: {
51
- translateX: () => {
52
- return ['0vw', `-100vw`]
53
- },
54
- easing: 'easeInQuad',
55
- },
56
- init: {
57
- transform: 'translateX(100vw)',
58
- },
59
- },
60
- }
61
-
62
- class Animation {
63
-
64
- public mode: any
65
- public duration: number
66
- public speed: number
67
- public stagger: number
68
- public reverse: boolean
69
-
70
- constructor() {
71
- this.mode = animationModes.fade
72
- this.duration = 5000
73
- this.speed = 1000
74
- this.stagger = 1000 / 4
75
- this.reverse = true
76
- }
77
-
78
- configure(options: Options) {
79
- this.mode = animationModes.hasOwnProperty(options.mode) ? animationModes[options.mode] : animationModes.fade
80
- this.duration = options.duration || 10000
81
- this.speed = 1000 * (options.speed || 1)
82
- this.stagger = this.speed / (options.stagger || 4)
83
- this.reverse = options.reverse
84
- }
85
-
86
- getInitialStyle() {
87
- return this.mode.init
88
- }
89
-
90
- animate(listNodes: any, finished: any) {
91
- let self = this
92
- let els = [].slice.call(listNodes, 0)
93
- if (this.reverse) els = els.reverse()
94
- if (!els || els.length < 1) return
95
- let offset = this.duration - (((els.length - 1) * this.stagger) + this.speed) * 2
96
- offset = offset < 0 ? 0 : offset
97
- let animation = anime.timeline({
98
- autoplay: false
99
- })
100
- animation.add(Object.assign({
101
- targets: els,
102
- duration: this.speed,
103
- delay: function (_el: any, i: any, _l: any) {
104
- return i * self.stagger
105
- }
106
- }, this.mode.in))
107
- animation.add(Object.assign({
108
- targets: els,
109
- duration: this.speed,
110
- delay: function (_el: any, _i: any, _l: any) {
111
- return _i * self.stagger
112
- },
113
- complete: () => {
114
- finished()
115
- },
116
- },
117
- this.mode.out
118
- ),
119
- `+=${offset}`
120
- )
121
- animation.play()
122
- }
123
- }
124
-
125
- module.exports = exports = Animation
@@ -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,77 +0,0 @@
1
- import React, { useReducer } from "react";
2
- import { ConfigureContext } from './ConfigureContext';
3
- import { anniversaryReducer } from "./configureReducer";
4
-
5
-
6
-
7
- const INITIAL_STATE: VixonicData = {
8
- downloadsPath: '',
9
- parameters: {
10
- abbreviatedMonths: false,
11
- animationMode: "",
12
- animationOrder: false,
13
- animationSpeed: 1.5,
14
- animationTime: "",
15
- backgroundImage: { id: "", filename: "", _isAsset: true },
16
- apiDomain: "",
17
- containerColumns: "",
18
- containerRows: "",
19
- containerRowsGap: "",
20
- containerColumnsGap:"",
21
- dataMode: "",
22
- dateAlignment: "center",
23
- dateDayFormat: { font: { filename: '', id: '' ,_isAsset: true }, fontSize: 55, alignment: { horizontal: "center" }, fontColor: "" , },
24
- dateEnabled: true,
25
- dateMonthFormat: { font: { filename: '', id: '',_isAsset: true }, fontSize: 20, alignment: { horizontal: "center" }, fontColor: "" },
26
- datePosition: 1,
27
- datePrimaryColor: "",
28
- dateStyle: "circle",
29
- descriptionEnabled: true,
30
- descriptionFormat: { font: { filename: '', id: '',_isAsset: true }, fontSize: 3.8, alignment: { horizontal: "center" }, fontColor: "" },
31
- optionalEnabled: true,
32
- optionalFormat: { font: { filename: '', id: '',_isAsset: true }, fontSize: 3.8, alignment: { horizontal: "center" }, fontColor: "" },
33
- excludePast: false,
34
- imageAlignment: "center",
35
- imageEnabled: true,
36
- imagePosition: 0,
37
- imageStyle: "normal",
38
- imageSize: 50,
39
- itemMargins: "",
40
- msj0: "",
41
- nameFormat: { font: { filename: '', id: '' ,_isAsset: true}, fontSize: 3.8, alignment: { horizontal: "center" }, fontColor: "" },
42
- orientation: "",
43
- padding: "",
44
- photosMode: "",
45
- photosZip: { id: "0fb559ec-5da3-4b2d-95c4-d9623754c841", filename: "0fb559ec-5da3-4b2d-95c4-d9623754c841.zip", extension: "zip",_isAsset: true },
46
- template: "",
47
- textAlignment: "center",
48
- textPosition: 0,
49
- updateTime: 600000,
50
- urlBaseApi: "",
51
- imageMargin: "",
52
- textMargin: "",
53
- dateMargin: "",
54
- separator: false
55
- }
56
- }
57
-
58
- interface props {
59
- children: JSX.Element | JSX.Element[]
60
- }
61
-
62
- export const AnniversaryProvider = ({ children }: props) => {
63
-
64
- const [configureState, dispatch] = useReducer(anniversaryReducer, INITIAL_STATE)
65
-
66
-
67
- const addConfiguration = (configure: VixonicData) => {
68
- dispatch({ type: "addConfigure", payload: configure })
69
- }
70
-
71
- return (
72
- <ConfigureContext.Provider value={{ configureState, addConfiguration }}>
73
- {children}
74
- </ConfigureContext.Provider>
75
- )
76
- }
77
-
@@ -1,67 +0,0 @@
1
-
2
- type ConfigureAction =
3
- | { type: 'addConfigure', payload: VixonicData }
4
-
5
-
6
- export const anniversaryReducer = (state: VixonicData, action: ConfigureAction) => {
7
-
8
- const { downloadsPath, parameters } = action.payload
9
- switch (action.type) {
10
- case 'addConfigure':
11
- return {
12
- downloadsPath: downloadsPath,
13
- parameters: {
14
- abbreviatedMonths: parameters.abbreviatedMonths,
15
- animationMode: parameters.animationMode,
16
- animationOrder: parameters.animationOrder,
17
- animationSpeed: parameters.animationSpeed,
18
- animationTime: parameters.animationTime,
19
- apiDomain: parameters.apiDomain,
20
- backgroundImage: parameters.backgroundImage,
21
- containerColumns: parameters.containerColumns,
22
- containerColumnsGap:parameters.containerColumnsGap,
23
- containerRows: parameters.containerRows,
24
- containerRowsGap: parameters.containerRowsGap,
25
- dataMode: parameters.dataMode,
26
- dateAlignment: parameters.dateAlignment,
27
- dateDayFormat: parameters.dateDayFormat,
28
- dateEnabled: parameters.dateEnabled,
29
- dateMonthFormat: parameters.dateMonthFormat,
30
- datePosition: parameters.datePosition,
31
- datePrimaryColor: parameters.datePrimaryColor,
32
- dateStyle: parameters.dateStyle,
33
- descriptionEnabled: parameters.descriptionEnabled,
34
- descriptionFormat: parameters.descriptionFormat,
35
- optionalEnabled: parameters.optionalEnabled,
36
- optionalFormat: parameters.optionalFormat,
37
- excludePast: parameters.excludePast,
38
- imageAlignment: parameters.imageAlignment,
39
- imageEnabled: parameters.imageEnabled,
40
- imagePosition: parameters.imagePosition,
41
- imageSize: parameters.imageSize,
42
- imageStyle: parameters.imageStyle,
43
- itemMargins: parameters.itemMargins,
44
- msj0: parameters.msj0,
45
- nameFormat: parameters.nameFormat,
46
- orientation: parameters.orientation,
47
- padding: parameters.padding,
48
- photosMode: parameters.photosMode,
49
- photosZip: parameters.photosZip,
50
- template: parameters.template,
51
- textAlignment: parameters.textAlignment,
52
- textPosition: parameters.textPosition,
53
- updateTime: parameters.updateTime,
54
- urlBaseApi: parameters.urlBaseApi,
55
- imageMargin: parameters.imageMargin,
56
- textMargin: parameters.textMargin,
57
- dateMargin: parameters.dateMargin,
58
- separator: parameters.separator,
59
- nameMaxChar: parameters.nameMaxChar,
60
- descriptionMaxChar: parameters.descriptionMaxChar
61
- }
62
- }
63
- default:
64
- return state;
65
- }
66
-
67
- }
@@ -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,31 +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
-
14
- export const DataProvider = ({ children }: props) => {
15
-
16
- const [dataEmployee, dispatch] = useReducer(dataReducer, INITIAL_STATE)
17
-
18
- const addEmployee = (employee: DataEmployee[]) => {
19
- dispatch({type:'addAnniversary', payload: employee})
20
- }
21
-
22
- return (
23
- <DataContext.Provider value={{
24
- dataEmployee,
25
- addEmployee
26
-
27
- }}>
28
- {children}
29
- </DataContext.Provider>
30
- )
31
- }
@@ -1,19 +0,0 @@
1
-
2
-
3
- type DataAction =
4
- | { type: 'addAnniversary', payload: DataEmployee[] }
5
-
6
-
7
- export const dataReducer = (state: Employees, action: DataAction): Employees => {
8
-
9
-
10
- switch (action.type) {
11
- case 'addAnniversary':
12
- return {
13
- dataEmployee: action.payload
14
- }
15
- default:
16
- return state;
17
- }
18
-
19
- }
@@ -1,38 +0,0 @@
1
- import moment from "moment"
2
-
3
-
4
- const getAnniversaryFromMonth = (apiData: any, month: any) => {
5
- let monthArray = []
6
- for (let i = 0; i < apiData.length; i++) {
7
- let monthA = Number(moment(apiData[i].fechaInic, 'YYYY-MM-DD').format('M')) - 1
8
- if (monthA === month) {
9
- let dayA = Number(moment(apiData[i].fechaInic, 'YYYY-MM-DD').format('D'))
10
- apiData[i].day = dayA
11
- apiData[i].month = month
12
- apiData[i].name = `${apiData[i].nombre} ${apiData[i].apellidoPate}`
13
- apiData[i].position = apiData[i].nombreCargo
14
- apiData[i].image = apiData[i].foto
15
- monthArray.push(apiData[i])
16
- }
17
- }
18
- monthArray.sort((a, b) => {
19
- if (a.day < b.day) return -1
20
- else if (a.day === b.day) return 0
21
- else return 1
22
- })
23
-
24
-
25
- return monthArray
26
- }
27
-
28
- export const parseFromApi = (apiData: any) => {
29
- let monthsArray = []
30
- for (let month = 0; month < 12; month++) {
31
- let monthArray = getAnniversaryFromMonth(apiData, month)
32
- if (monthArray.length > 0) monthsArray.push(...monthArray)
33
- }
34
-
35
-
36
- return monthsArray
37
- }
38
-
@@ -1,69 +0,0 @@
1
- import localforage from 'localforage'
2
- import axios from 'axios'
3
-
4
- const urlCF = 'https://us-central1-vixoniccloudcom.cloudfunctions.net/rexTokenCentralizer'
5
- const tokenCF = 'd2dca806-4f70-41a3-ab70-0fe9bf051d2e'
6
- let updateTimer: any
7
-
8
- function setUpdateTime(milliseconds: any, requestData: any) {
9
- clearTimeout(updateTimer)
10
- if (milliseconds === null) return
11
- updateTimer = setTimeout(requestData, milliseconds)
12
- }
13
-
14
- function getToken(apiDomain: any) {
15
- try {
16
- const config = { 'Authorization': tokenCF }
17
- const response = axios({
18
- method: 'post',
19
- url: urlCF,
20
- headers: config,
21
- data: {
22
- orgDomain: apiDomain // This is the body part
23
- }
24
- })
25
- return response
26
- } catch (error) {
27
- console.error(error);
28
- return error
29
- }
30
- }
31
-
32
- function setTokenLocal(token: any, apiDomain: any) {
33
- localforage.config({ name: `request_${apiDomain}` })
34
- localforage.setItem('rexmas', {
35
- token: token,
36
- apiDomain: apiDomain,
37
- date: Date.now()
38
- }, (err) => { if (err) console.log(err) })
39
- }
40
-
41
-
42
-
43
-
44
- export default function setToken(apiDomain: any, requestData: any) {
45
- let pt: any = getToken(apiDomain)
46
- pt.then(function (response: any) {
47
- console.log('rr...', response)
48
- let token = response.data.token
49
- if (token === '') {
50
- console.log(response.data.msg)
51
- // renderLog(response.data.msg)
52
- setUpdateTime(null, requestData)
53
- } else {
54
- console.log('Access granted to Rex+ API')
55
- setTokenLocal(token, apiDomain)
56
- setUpdateTime(2000, requestData)
57
- }
58
- return
59
- })
60
- .catch(function (error: any) {
61
- console.log(error);
62
- console.log(`Error getting token ${error.response.data && error.response.data.detalle}`)
63
- // setUpdateTime(null)
64
- return
65
- })
66
- }
67
-
68
-
69
-
@@ -1,47 +0,0 @@
1
- import { useEffect, useRef, useState } from "react"
2
-
3
- type State = {
4
- data: string | null
5
- loading: boolean,
6
- error: boolean | null
7
- }
8
-
9
-
10
- export const useFetch = (url: string): State => {
11
-
12
- const isMounted = useRef(true);
13
- const [state, setState] = useState<State>({ data: null, loading: true, error: null })
14
-
15
- useEffect(() => {
16
- return () => {
17
- isMounted.current = false;
18
- }
19
- }, [])
20
-
21
-
22
- useEffect(() => {
23
-
24
- setState({ data: null, loading: true, error: null });
25
-
26
- fetch(url, {
27
- headers: {
28
- 'Authorization': `Token`
29
- }
30
- })
31
- .then(resp => resp.json())
32
- .then(data => {
33
-
34
- if (isMounted.current) {
35
- setState({
36
- loading: false,
37
- error: null,
38
- data
39
- });
40
- }
41
-
42
- });
43
-
44
- }, [url])
45
-
46
- return state;
47
- }