@vixoniccom/aniversarios 1.2.0-dev.1 → 1.2.1-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.
- package/CHANGELOG.md +10 -0
- package/build.zip +0 -0
- package/configuration.json +4 -0
- package/package.json +3 -4
- package/src/App.tsx +59 -73
- package/src/components/AnniversaryItem/components/AnniversaryDate/CircleDate/index.tsx +31 -0
- package/src/components/AnniversaryItem/components/AnniversaryDate/FlatDate/index.tsx +47 -0
- package/src/components/{anniversary-item/shared/anniversary-date/outline/OutlineDate.tsx → AnniversaryItem/components/AnniversaryDate/OutlineDate/index.tsx} +7 -25
- package/src/components/{anniversary-item/shared/anniversary-date/text-calendar/TextCalendarDate.tsx → AnniversaryItem/components/AnniversaryDate/TextCalendarDate/index.tsx} +7 -16
- package/src/components/{anniversary-item/shared/anniversary-date/text/TextDate.tsx → AnniversaryItem/components/AnniversaryDate/TextDate/index.tsx} +2 -12
- package/src/components/{anniversary-item/shared/anniversary-date/AnniversaryDate.tsx → AnniversaryItem/components/AnniversaryDate/index.tsx} +7 -11
- package/src/components/AnniversaryItem/components/AnniversaryDate/utils.ts +18 -0
- package/src/components/{anniversary-item/shared/AnniversaryImage.tsx → AnniversaryItem/components/AnniversaryImage/index.tsx} +11 -19
- package/src/components/AnniversaryItem/components/ClassicItem/index.tsx +109 -0
- package/src/components/{anniversary-item/shared/separator → AnniversaryItem/components/Separator}/Separator.tsx +3 -6
- package/src/components/AnniversaryItem/components/index.ts +11 -0
- package/src/components/AnniversaryItem/components/utils.ts +75 -0
- package/src/components/AnniversaryItem/index.tsx +17 -0
- package/src/components/{FontLoader.tsx → FontLoader/index.tsx} +11 -12
- package/src/components/FormattedText/index.tsx +81 -0
- package/src/components/{items-container → ItemsContainer/components}/Item.tsx +2 -10
- package/src/components/ItemsContainer/components/animation.ts +130 -0
- package/src/components/{items-container/ItemsContainer.tsx → ItemsContainer/index.tsx} +52 -61
- package/src/components/{Render.tsx → Render/index.tsx} +9 -11
- package/src/components/index.ts +13 -0
- package/src/context/configureContext/ConfigureContext.tsx +8 -0
- package/src/context/configureContext/ConfigureProvider.tsx +72 -0
- package/src/context/configureContext/configureReducer.ts +62 -0
- package/src/context/dataContext/DataContex.tsx +8 -0
- package/src/context/dataContext/DataProvider.tsx +25 -0
- package/src/context/dataContext/dataReducer.ts +12 -0
- package/src/helpers/filterEmployees.ts +31 -37
- package/src/helpers/getEmployees.ts +18 -22
- package/src/helpers/utils.ts +44 -50
- package/src/main.tsx +2 -2
- package/src/test/parameters.json +97 -97
- package/src/components/FormattedText.tsx +0 -81
- package/src/components/anniversary-item/AnniversaryItem.tsx +0 -22
- package/src/components/anniversary-item/clasic/ClasicItem.tsx +0 -220
- package/src/components/anniversary-item/shared/anniversary-date/DateUtils.ts +0 -33
- package/src/components/anniversary-item/shared/anniversary-date/circle/CircleDate.tsx +0 -39
- package/src/components/anniversary-item/shared/anniversary-date/flat/FlatDate.tsx +0 -79
- package/src/components/anniversary-item/shared/utils.ts +0 -10
- package/src/components/items-container/animation.ts +0 -125
- package/src/contex/configureContext/ConfigureContext.tsx +0 -8
- package/src/contex/configureContext/ConfigureProvider.tsx +0 -77
- package/src/contex/configureContext/configureReducer.ts +0 -67
- package/src/contex/dataContext/DataContex.tsx +0 -8
- package/src/contex/dataContext/DataProvider.tsx +0 -31
- package/src/contex/dataContext/dataReducer.ts +0 -19
- package/src/helpers/parseMonthAndDay.ts +0 -38
- package/src/helpers/setToken.ts +0 -69
- package/src/hooks/useFetch.ts +0 -47
- package/src/model/income.ts +0 -129
- /package/src/components/{anniversary-item/shared → AnniversaryItem/components}/default-profile.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.2.1-dev.0](https://github.com/Vixonic/store-aniversarios/compare/v1.2.0...v1.2.1-dev.0) (2025-05-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* code refactored ([41cf858](https://github.com/Vixonic/store-aniversarios/commit/41cf85868e516175ee55640434247c5f70d5d579))
|
|
11
|
+
* createItems now works properly ([db2623a](https://github.com/Vixonic/store-aniversarios/commit/db2623ab1156ca93bd5386598dd1c1dc486a46ff))
|
|
12
|
+
|
|
13
|
+
## [1.2.0](https://github.com/Vixonic/store-aniversarios/compare/v1.2.0-dev.1...v1.2.0) (2025-02-27)
|
|
14
|
+
|
|
5
15
|
## [1.2.0-dev.1](https://bitbucket.org/vixonic_dev/aniversarios/compare/v1.2.0-dev.0...v1.2.0-dev.1) (2025-02-13)
|
|
6
16
|
|
|
7
17
|
|
package/build.zip
CHANGED
|
Binary file
|
package/configuration.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/aniversarios",
|
|
3
3
|
"alias": "Aniversarios",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.1-dev.0",
|
|
5
5
|
"description": "Muestra el día que el trabajador está de aniversario en la empresa.",
|
|
6
6
|
"main": "main.js",
|
|
7
7
|
"author": "",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"animejs": "^3.2.2",
|
|
21
21
|
"axios": "^1.6.0",
|
|
22
|
-
"jquery": "^3.6.0",
|
|
23
22
|
"localforage": "^1.10.0",
|
|
24
23
|
"moment": "^2.29.4",
|
|
25
24
|
"prop-types": "^15.8.1",
|
|
@@ -33,8 +32,8 @@
|
|
|
33
32
|
"@types/node": "^12.20.37",
|
|
34
33
|
"@types/react": "^17.0.35",
|
|
35
34
|
"@types/react-dom": "^17.0.11",
|
|
36
|
-
"@vixoniccom/module-packager": "^2.10.1
|
|
37
|
-
"@vixoniccom/modules": "^2.20.0
|
|
35
|
+
"@vixoniccom/module-packager": "^2.10.1",
|
|
36
|
+
"@vixoniccom/modules": "^2.20.0",
|
|
38
37
|
"standard-version": "^9.5.0"
|
|
39
38
|
}
|
|
40
39
|
}
|
package/src/App.tsx
CHANGED
|
@@ -1,97 +1,89 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useState } from "react"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import localforage from "localforage";
|
|
1
|
+
import React, { useContext, useEffect, useState } from "react"
|
|
2
|
+
import { FormattedText, Render } from './components'
|
|
3
|
+
import { ConfigureContext } from "./context/configureContext/ConfigureContext"
|
|
4
|
+
import { DataContext } from "./context/dataContext/DataContex"
|
|
5
|
+
import { getEmployees, getEmployeesYearly } from "./helpers/getEmployees"
|
|
6
|
+
import { filterEmployees } from "./helpers/filterEmployees"
|
|
7
|
+
import moment from "moment"
|
|
8
|
+
import { getMonth } from "./helpers/utils"
|
|
9
|
+
import localforage from "localforage"
|
|
11
10
|
|
|
12
11
|
type Props = {
|
|
13
|
-
data: VixonicData
|
|
14
|
-
start: boolean
|
|
15
|
-
}
|
|
12
|
+
data: VixonicData
|
|
13
|
+
start: boolean
|
|
14
|
+
}
|
|
16
15
|
|
|
17
|
-
type Msj =
|
|
18
|
-
| 'Ningún ingreso que mostrar'
|
|
16
|
+
type Msj = 'Ningún ingreso que mostrar'
|
|
19
17
|
| 'Cargando Empleados...'
|
|
20
18
|
| 'Missing google sheets'
|
|
21
19
|
| ""
|
|
22
|
-
| 'Invalid URL'
|
|
20
|
+
| 'Invalid URL'
|
|
23
21
|
|
|
24
|
-
export const App = ({ data, start }
|
|
25
|
-
const { addConfiguration, configureState } = useContext(ConfigureContext)
|
|
26
|
-
const { addEmployee } = useContext(DataContext)
|
|
22
|
+
export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
23
|
+
const { addConfiguration, configureState } = useContext(ConfigureContext)
|
|
24
|
+
const { addEmployee } = useContext(DataContext)
|
|
27
25
|
const [dataState, setDataState] = useState(data)
|
|
28
|
-
const [msj, setMsj] = useState<Msj>("")
|
|
29
|
-
const { apiDomain, dataMode, excludePast } = configureState.parameters
|
|
30
|
-
let updateTimer
|
|
26
|
+
const [msj, setMsj] = useState<Msj>("")
|
|
27
|
+
const { apiDomain, dataMode, excludePast } = configureState.parameters
|
|
28
|
+
let updateTimer: any
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
useEffect(()=> {
|
|
34
|
-
if(apiDomain){
|
|
35
|
-
localforage.config({
|
|
36
|
-
name: `url_request_${apiDomain}`
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
},[apiDomain])
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
addConfiguration(data);
|
|
43
|
-
setDataState(configureState);
|
|
44
|
-
}, [data]);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const setUpdateTime =(updatedTime: number) => {
|
|
30
|
+
const setUpdateTime = (updatedTime: number) => {
|
|
48
31
|
clearTimeout(updateTimer)
|
|
49
32
|
updateTimer = setTimeout(getData, updatedTime)
|
|
50
33
|
}
|
|
51
34
|
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (apiDomain) localforage.config({ name: `url_request_${apiDomain}` })
|
|
37
|
+
}, [apiDomain])
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
addConfiguration(data)
|
|
41
|
+
setDataState(configureState)
|
|
42
|
+
}, [data])
|
|
43
|
+
|
|
52
44
|
useEffect(() => {
|
|
53
45
|
const { updateTime } = configureState.parameters
|
|
54
46
|
|
|
55
47
|
if (apiDomain && dataMode) {
|
|
56
|
-
localforage.getItem<{ items: any[], date: number, mode: string }>('anniversary-docs').then((data) => {
|
|
57
|
-
if(!data || dataMode !== data.mode
|
|
48
|
+
localforage.getItem<{ items: any[], date: number, mode: string }>('anniversary-docs').then((data) => {
|
|
49
|
+
if (!data || dataMode !== data.mode) {
|
|
58
50
|
getData()
|
|
59
51
|
setUpdateTime(updateTime!)
|
|
60
|
-
return
|
|
52
|
+
return
|
|
61
53
|
}
|
|
62
|
-
|
|
54
|
+
|
|
63
55
|
const now = Date.now()
|
|
64
56
|
const targetDate = data?.date! + updateTime!
|
|
65
57
|
|
|
66
|
-
if(now >= targetDate){
|
|
58
|
+
if (now >= targetDate) {
|
|
67
59
|
getData()
|
|
68
60
|
setUpdateTime(updateTime!)
|
|
69
|
-
}else {
|
|
61
|
+
} else {
|
|
70
62
|
data && addEmployee(data.items)
|
|
71
|
-
setMsj("")
|
|
72
|
-
setUpdateTime(targetDate-now)
|
|
63
|
+
setMsj("")
|
|
64
|
+
setUpdateTime(targetDate - now)
|
|
73
65
|
}
|
|
74
66
|
})
|
|
75
67
|
}
|
|
76
|
-
if (!apiDomain) setMsj("Missing google sheets")
|
|
77
|
-
}, [dataState])
|
|
68
|
+
if (!apiDomain) setMsj("Missing google sheets")
|
|
69
|
+
}, [dataState])
|
|
78
70
|
|
|
79
71
|
const getData = async () => {
|
|
80
|
-
const urlValid = "https://docs.google.com/spreadsheets/d/"
|
|
72
|
+
const urlValid = "https://docs.google.com/spreadsheets/d/"
|
|
81
73
|
let contractEmployees: any
|
|
82
74
|
let employee: any = []
|
|
83
75
|
try {
|
|
84
|
-
if (apiDomain
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
if (apiDomain?.includes(urlValid)) {
|
|
77
|
+
const month = Number(moment().format("M")) - 1
|
|
78
|
+
const nextMonth = (month === 11) ? 0 : (month + 1)
|
|
79
|
+
const monthTab = getMonth(month)
|
|
80
|
+
const nextMonthTab = getMonth(nextMonth)
|
|
89
81
|
if (dataMode !== 'yearly') {
|
|
90
|
-
contractEmployees = await getEmployees(apiDomain,
|
|
82
|
+
contractEmployees = await getEmployees(apiDomain, monthTab)
|
|
91
83
|
const { values } = contractEmployees.data
|
|
92
84
|
employee.push(...filterEmployees(values, dataMode, excludePast, month))
|
|
93
|
-
if(
|
|
94
|
-
contractEmployees = await getEmployees(apiDomain,
|
|
85
|
+
if (dataMode === 'weekly') {
|
|
86
|
+
contractEmployees = await getEmployees(apiDomain, nextMonthTab)
|
|
95
87
|
const { values: valuesnextMonth } = contractEmployees.data
|
|
96
88
|
employee.push(...filterEmployees(valuesnextMonth, dataMode, excludePast, nextMonth))
|
|
97
89
|
}
|
|
@@ -100,40 +92,34 @@ export const App = ({ data, start }: Props) => {
|
|
|
100
92
|
if (dataMode === 'yearly') {
|
|
101
93
|
setMsj('Cargando Empleados...')
|
|
102
94
|
for (let numberMonth: number = 0; numberMonth <= 11; numberMonth++) {
|
|
103
|
-
contractEmployees = await getEmployeesYearly(apiDomain, numberMonth)
|
|
95
|
+
contractEmployees = await getEmployeesYearly(apiDomain, numberMonth)
|
|
104
96
|
const { values } = contractEmployees.data
|
|
105
97
|
employee.push(...filterEmployees(values, dataMode, excludePast, numberMonth))
|
|
106
98
|
}
|
|
107
99
|
}
|
|
108
100
|
|
|
109
101
|
if (contractEmployees) {
|
|
110
|
-
addEmployee(employee)
|
|
111
|
-
setMsj("")
|
|
102
|
+
addEmployee(employee)
|
|
103
|
+
setMsj("")
|
|
112
104
|
localforage.setItem('anniversary-docs', {
|
|
113
105
|
items: employee,
|
|
114
106
|
date: Date.now() + updateTimer,
|
|
115
107
|
mode: dataMode
|
|
116
108
|
})
|
|
117
109
|
} else {
|
|
118
|
-
setMsj("Ningún ingreso que mostrar")
|
|
110
|
+
setMsj("Ningún ingreso que mostrar")
|
|
119
111
|
}
|
|
120
112
|
} else {
|
|
121
|
-
setMsj("Invalid URL")
|
|
113
|
+
setMsj("Invalid URL")
|
|
122
114
|
}
|
|
123
115
|
} catch (error) {
|
|
124
|
-
console.log(error)
|
|
116
|
+
console.log(error)
|
|
125
117
|
}
|
|
126
|
-
}
|
|
118
|
+
}
|
|
127
119
|
|
|
128
120
|
return msj !== "" ? (
|
|
129
|
-
<FormattedText
|
|
130
|
-
text={msj}
|
|
131
|
-
format={
|
|
132
|
-
configureState.parameters.nameFormat ||
|
|
133
|
-
configureState.parameters.descriptionFormat
|
|
134
|
-
}
|
|
135
|
-
/>
|
|
121
|
+
<FormattedText text={msj} format={configureState.parameters.nameFormat || configureState.parameters.descriptionFormat} />
|
|
136
122
|
) : (
|
|
137
123
|
<Render start={start} />
|
|
138
|
-
)
|
|
139
|
-
}
|
|
124
|
+
)
|
|
125
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useContext } from 'react'
|
|
2
|
+
import { AnniveraryDateUtils } from '../utils'
|
|
3
|
+
import { FormattedText } from '../../../../FormattedText'
|
|
4
|
+
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
day: number,
|
|
8
|
+
month: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const CircleDate: React.FunctionComponent<Props> = ({ day, month }) => {
|
|
12
|
+
const { configureState } = useContext(ConfigureContext)
|
|
13
|
+
const { orientation, dateMonthFormat, datePrimaryColor, dateDayFormat } = configureState.parameters
|
|
14
|
+
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
15
|
+
const daySize = (dateDayFormat?.fontSize || 100) * 400 / 100
|
|
16
|
+
const monthSize = (dateMonthFormat?.fontSize || 100) * 400 / 100
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<svg {...sizeProp} viewBox='0 0 400 400' xmlSpace='preserve'>
|
|
20
|
+
<g>
|
|
21
|
+
<circle fill={datePrimaryColor} cx='200' cy='200' r='200' />
|
|
22
|
+
<foreignObject width='400' height='400'>
|
|
23
|
+
<div style={{ height: 400, width: 400, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
|
24
|
+
<FormattedText text={AnniveraryDateUtils.getMonth(month, true)} format={Object.assign({}, dateMonthFormat, { fontSize: monthSize })} unit='px' />
|
|
25
|
+
<FormattedText text={AnniveraryDateUtils.getZeroLeadedText(day)} format={Object.assign({}, dateDayFormat, { fontSize: daySize })} unit='px' />
|
|
26
|
+
</div>
|
|
27
|
+
</foreignObject>
|
|
28
|
+
</g>
|
|
29
|
+
</svg>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useContext } from "react"
|
|
2
|
+
import { ConfigureContext } from "../../../../../context/configureContext/ConfigureContext"
|
|
3
|
+
import { AnniveraryDateUtils } from "../utils"
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
month: number
|
|
7
|
+
day: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const FlatDate: React.FunctionComponent<Props> = ({ month, day }: Props) => {
|
|
11
|
+
const { configureState } = useContext(ConfigureContext)
|
|
12
|
+
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = configureState.parameters
|
|
13
|
+
|
|
14
|
+
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
15
|
+
const monthSize = ((dateMonthFormat?.fontSize || 18.5) * 400) / 100
|
|
16
|
+
const daySize = ((dateDayFormat?.fontSize || 57.5) * 400) / 100
|
|
17
|
+
|
|
18
|
+
const getFontFamily = (format: any) => {
|
|
19
|
+
if (format?.font?.filename) return format.font.filename.replace('.', '-')
|
|
20
|
+
return ''
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<svg {...sizeProp} viewBox='0 0 400 400' xmlSpace='preserve'>
|
|
25
|
+
<g>
|
|
26
|
+
<path fill={datePrimaryColor} 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' />
|
|
27
|
+
<path fill='#FFFFFF' 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' />
|
|
28
|
+
<path fill={datePrimaryColor} 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' />
|
|
29
|
+
<text fontFamily={`"${getFontFamily(dateMonthFormat)}"`}
|
|
30
|
+
textAnchor='middle'
|
|
31
|
+
alignmentBaseline='central' x='200' y='55'
|
|
32
|
+
fontSize={monthSize} preserveAspectRatio='none'
|
|
33
|
+
fill={dateMonthFormat?.fontColor || '#fff'} fontSizeAdjust=''>
|
|
34
|
+
{AnniveraryDateUtils.getMonth(month, abbreviatedMonths)}
|
|
35
|
+
</text>
|
|
36
|
+
|
|
37
|
+
<text fontFamily={`"${getFontFamily(dateDayFormat)}"`}
|
|
38
|
+
textAnchor='middle'
|
|
39
|
+
alignmentBaseline='central' x='200' y='245'
|
|
40
|
+
fontSize={daySize} preserveAspectRatio='none'
|
|
41
|
+
fill={dateDayFormat?.fontColor || '#fff'} fontSizeAdjust=''>
|
|
42
|
+
{AnniveraryDateUtils.getZeroLeadedText(day)}
|
|
43
|
+
</text>
|
|
44
|
+
</g>
|
|
45
|
+
</svg>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useContext,
|
|
2
|
-
import { ConfigureContext } from '../../../../../
|
|
1
|
+
import React, { useContext, useState } from 'react'
|
|
2
|
+
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
3
3
|
import { FormattedText } from '../../../../FormattedText'
|
|
4
|
-
import {
|
|
4
|
+
import { AnniveraryDateUtils } from '../utils'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
@@ -9,15 +9,10 @@ interface Props {
|
|
|
9
9
|
month: number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const OutlineDate = ({ day, month }: Props) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export const OutlineDate: React.FunctionComponent<Props> = ({ day, month }: Props) => {
|
|
16
13
|
const { configureState } = useContext(ConfigureContext)
|
|
17
14
|
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = configureState.parameters
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const sizeProp = AnniveraryDateUtil.utils(orientation)
|
|
15
|
+
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
21
16
|
|
|
22
17
|
const parseFormat = (format: any, defaultSize: any) => {
|
|
23
18
|
return Object.assign(
|
|
@@ -27,21 +22,15 @@ export const OutlineDate = ({ day, month }: Props) => {
|
|
|
27
22
|
)
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [])
|
|
34
|
-
|
|
35
25
|
const [monthFormatState,] = useState(parseFormat(dateMonthFormat, 20))
|
|
36
26
|
const [dayFormatState,] = useState(parseFormat(dateDayFormat, 50))
|
|
37
27
|
|
|
38
|
-
|
|
39
28
|
return (
|
|
40
29
|
<svg {...sizeProp} viewBox='0 0 100 100'>
|
|
41
30
|
<foreignObject x='20' y='35' width='60' height='50'>
|
|
42
31
|
<div style={{ display: 'flex', alignItems: 'center', flexDirection: 'column', justifyContent: 'center', height: '100%' }}>
|
|
43
|
-
<FormattedText text={
|
|
44
|
-
<FormattedText text={
|
|
32
|
+
<FormattedText text={AnniveraryDateUtils.getMonth(month, abbreviatedMonths)} format={monthFormatState} unit='px' />
|
|
33
|
+
<FormattedText text={AnniveraryDateUtils.getZeroLeadedText(day)} format={dayFormatState} unit='px' />
|
|
45
34
|
</div>
|
|
46
35
|
</foreignObject>
|
|
47
36
|
<svg viewBox='0 0 300 300'>
|
|
@@ -51,10 +40,3 @@ export const OutlineDate = ({ day, month }: Props) => {
|
|
|
51
40
|
</svg>
|
|
52
41
|
)
|
|
53
42
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
OutlineDate.defaultProps = {
|
|
57
|
-
primaryColor: '#5B5959'
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
OutlineDate.propTypes = AnniveraryDateUtil.commonPropTypes()
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react'
|
|
2
|
-
import { ConfigureContext } from '../../../../../
|
|
2
|
+
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
3
3
|
import { FormattedText } from '../../../../FormattedText'
|
|
4
|
-
import {
|
|
4
|
+
import { AnniveraryDateUtils } from '../utils'
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
day: number
|
|
8
8
|
month: number
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const TextCalendarDate = ({ day, month }: Props) => {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export const TextCalendarDate: React.FunctionComponent<Props> = ({ day, month }: Props) => {
|
|
14
12
|
const { configureState } = useContext(ConfigureContext)
|
|
15
|
-
const { dateMonthFormat, dateDayFormat, abbreviatedMonths,orientation
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const sizeProp = AnniveraryDateUtil.utils(orientation, '100%')
|
|
19
|
-
|
|
13
|
+
const { dateMonthFormat, dateDayFormat, abbreviatedMonths, orientation } = configureState.parameters
|
|
14
|
+
const sizeProp = AnniveraryDateUtils.utils(orientation, '100%')
|
|
20
15
|
|
|
21
16
|
const parseFormat = (format: any, defaultSize: any) => {
|
|
22
17
|
return Object.assign(
|
|
@@ -33,14 +28,10 @@ export const TextCalendarDate = ({ day, month }: Props) => {
|
|
|
33
28
|
<svg {...sizeProp} viewBox='0 0 100 100'>
|
|
34
29
|
<foreignObject width='100' height='100'>
|
|
35
30
|
<div style={{ display: 'flex', alignItems: 'center', flexDirection: 'column', justifyContent: 'center', height: '100%' }}>
|
|
36
|
-
<FormattedText text={
|
|
37
|
-
<FormattedText text={
|
|
31
|
+
<FormattedText text={AnniveraryDateUtils.getMonth(month, abbreviatedMonths)} format={monthFormatState} unit='px' />
|
|
32
|
+
<FormattedText text={AnniveraryDateUtils.getZeroLeadedText(day)} format={dayFormatState} unit='px' />
|
|
38
33
|
</div>
|
|
39
34
|
</foreignObject>
|
|
40
35
|
</svg>
|
|
41
36
|
)
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
TextCalendarDate.propTypes = AnniveraryDateUtil.commonPropTypes()
|
|
46
|
-
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
2
|
import { FormattedText } from '../../../../FormattedText'
|
|
4
|
-
import { ConfigureContext } from '../../../../../
|
|
3
|
+
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
5
4
|
|
|
6
5
|
interface Props {
|
|
7
6
|
day: number
|
|
8
7
|
month: number
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export const TextDate = ({ day, month }: Props) => {
|
|
12
|
-
|
|
10
|
+
export const TextDate: React.FunctionComponent<Props> = ({ day, month }: Props) => {
|
|
13
11
|
const { configureState } = useContext(ConfigureContext)
|
|
14
12
|
const { dateMonthFormat, dateDayFormat } = configureState.parameters
|
|
15
13
|
|
|
@@ -20,11 +18,3 @@ export const TextDate = ({ day, month }: Props) => {
|
|
|
20
18
|
</div>
|
|
21
19
|
)
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
TextDate.propTypes = {
|
|
25
|
-
day: PropTypes.number.isRequired,
|
|
26
|
-
dayFormat: PropTypes.object,
|
|
27
|
-
month: PropTypes.number.isRequired,
|
|
28
|
-
monthFormat: PropTypes.object
|
|
29
|
-
}
|
|
30
|
-
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { CircleDate } from './
|
|
3
|
-
import { FlatDate } from './
|
|
4
|
-
import { TextCalendarDate } from './
|
|
5
|
-
import { TextDate } from './
|
|
6
|
-
import { OutlineDate } from './
|
|
2
|
+
import { CircleDate } from './CircleDate'
|
|
3
|
+
import { FlatDate } from './FlatDate'
|
|
4
|
+
import { TextCalendarDate } from './TextCalendarDate'
|
|
5
|
+
import { TextDate } from './TextDate'
|
|
6
|
+
import { OutlineDate } from './OutlineDate'
|
|
7
7
|
|
|
8
8
|
const itemStyles = {
|
|
9
9
|
calendarFlat: FlatDate,
|
|
@@ -28,12 +28,8 @@ interface Props {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export const AnniversaryDate = ({ style, day, month }: Props) => {
|
|
31
|
-
|
|
32
|
-
let StyledItem = itemStyles.hasOwnProperty(style) ? itemStyles[style] : itemStyles.text
|
|
31
|
+
const StyledItem = itemStyles.hasOwnProperty(style) ? itemStyles[style] : itemStyles.text
|
|
33
32
|
return (
|
|
34
|
-
<StyledItem
|
|
35
|
-
day={day}
|
|
36
|
-
month={month} />
|
|
33
|
+
<StyledItem day={day} month={month} />
|
|
37
34
|
)
|
|
38
35
|
}
|
|
39
|
-
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { utils } from '../utils'
|
|
2
|
+
|
|
3
|
+
const Months = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']
|
|
4
|
+
|
|
5
|
+
export class AnniveraryDateUtils {
|
|
6
|
+
static getZeroLeadedText(text: any) {
|
|
7
|
+
return `0${text}`.slice(-2)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static getMonth(index: any, abbreviated: any) {
|
|
11
|
+
if (!abbreviated) return Months[index]
|
|
12
|
+
return Months[index].substring(0, 3).toUpperCase()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static utils(orientation: any, size: any = undefined) {
|
|
16
|
+
return utils(orientation, size)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
import React, { useRef, useState
|
|
2
|
-
import {
|
|
3
|
-
const defaultImg = require('./default-profile.png')
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { AnniveraryDateUtils } from '../AnniversaryDate/utils'
|
|
4
3
|
|
|
4
|
+
const defaultImg = require('../default-profile.png')
|
|
5
5
|
const borderStyles = {
|
|
6
6
|
normal: '0',
|
|
7
7
|
rounded: '10',
|
|
8
8
|
circle: '100'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
url: any
|
|
13
|
-
size:
|
|
14
|
-
borderStyle: keyof typeof borderStyles
|
|
11
|
+
interface Props {
|
|
12
|
+
url: any
|
|
13
|
+
size: number
|
|
14
|
+
borderStyle: keyof typeof borderStyles
|
|
15
15
|
orientation: any
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const AnniversaryImage = ({ url, size, borderStyle, orientation }
|
|
19
|
-
|
|
18
|
+
export const AnniversaryImage: React.FunctionComponent<Props> = ({ url, size, borderStyle, orientation }) => {
|
|
20
19
|
const [urlState, setUrlState] = useState(url || defaultImg)
|
|
21
20
|
const input = useRef<SVGImageElement>(null)
|
|
22
|
-
|
|
23
21
|
const maskId = `${Math.random() * 10}${Math.random() * 10}${Math.random() * 10}`
|
|
24
|
-
|
|
25
|
-
|
|
26
22
|
const imageExist = (url: any) => {
|
|
27
23
|
const isValidImage = url.substr(-3).toLowerCase() === 'png' || url.substr(-3).toLowerCase() === 'jpg' || url.substr(-4).toLowerCase() === 'jpeg'
|
|
28
24
|
return isValidImage ? url : defaultImg
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
useEffect(() => {
|
|
32
|
-
|
|
28
|
+
const urlImage = url && imageExist(url) || defaultImg
|
|
33
29
|
setUrlState(urlImage)
|
|
34
30
|
if (input.current !== null) {
|
|
35
31
|
input.current.addEventListener('error', onError.bind(this))
|
|
36
32
|
}
|
|
37
33
|
}, [url])
|
|
38
34
|
|
|
39
|
-
|
|
40
35
|
const onError = () => {
|
|
41
36
|
console.log('Invalid image')
|
|
42
37
|
setUrlState(defaultImg)
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
|
|
46
40
|
return (
|
|
47
|
-
<svg viewBox='0 0 100 100' {...utils(orientation, size)}>
|
|
41
|
+
<svg viewBox='0 0 100 100' {...AnniveraryDateUtils.utils(orientation, size)}>
|
|
48
42
|
<defs>
|
|
49
43
|
<mask id={maskId} fill='#fff'>
|
|
50
44
|
<rect width='100' height='100'
|
|
@@ -57,6 +51,4 @@ export const AnniversaryImage = ({ url, size, borderStyle, orientation }: Props)
|
|
|
57
51
|
}} href={urlState} mask={`url(#${maskId})`} />
|
|
58
52
|
</svg>
|
|
59
53
|
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
}
|