jornada-ui 0.4.16 → 0.4.18
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/lib/commonjs/components/modal-type-activities/index.js +7 -6
- package/lib/commonjs/components/modal-type-activities/index.js.map +1 -1
- package/lib/commonjs/components/modal-type-activities/mock/index.js +34 -3
- package/lib/commonjs/components/modal-type-activities/mock/index.js.map +1 -1
- package/lib/commonjs/components/modals/modal-change-activitie-history/helpers/index.js +35 -0
- package/lib/commonjs/components/modals/modal-change-activitie-history/helpers/index.js.map +1 -0
- package/lib/commonjs/components/modals/modal-change-activitie-history/index.js +203 -0
- package/lib/commonjs/components/modals/modal-change-activitie-history/index.js.map +1 -0
- package/lib/commonjs/components/modals/modal-change-activitie-history/interface.js +6 -0
- package/lib/commonjs/components/modals/modal-change-activitie-history/interface.js.map +1 -0
- package/lib/commonjs/components/step-indicator/index.js +131 -68
- package/lib/commonjs/components/step-indicator/index.js.map +1 -1
- package/lib/module/components/modal-type-activities/index.js +8 -7
- package/lib/module/components/modal-type-activities/index.js.map +1 -1
- package/lib/module/components/modal-type-activities/mock/index.js +33 -2
- package/lib/module/components/modal-type-activities/mock/index.js.map +1 -1
- package/lib/module/components/modals/modal-change-activitie-history/helpers/index.js +32 -0
- package/lib/module/components/modals/modal-change-activitie-history/helpers/index.js.map +1 -0
- package/lib/module/components/modals/modal-change-activitie-history/index.js +196 -0
- package/lib/module/components/modals/modal-change-activitie-history/index.js.map +1 -0
- package/lib/module/components/modals/modal-change-activitie-history/interface.js +4 -0
- package/lib/module/components/modals/modal-change-activitie-history/interface.js.map +1 -0
- package/lib/module/components/step-indicator/index.js +129 -65
- package/lib/module/components/step-indicator/index.js.map +1 -1
- package/lib/typescript/commonjs/src/components/modal-type-activities/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/modal-type-activities/interface.d.ts +1 -0
- package/lib/typescript/commonjs/src/components/modal-type-activities/interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/modal-type-activities/mock/index.d.ts +17 -0
- package/lib/typescript/commonjs/src/components/modal-type-activities/mock/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/modals/modal-change-activitie-history/helpers/index.d.ts +13 -0
- package/lib/typescript/commonjs/src/components/modals/modal-change-activitie-history/helpers/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/modals/modal-change-activitie-history/index.d.ts +10 -0
- package/lib/typescript/commonjs/src/components/modals/modal-change-activitie-history/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/modals/modal-change-activitie-history/interface.d.ts +18 -0
- package/lib/typescript/commonjs/src/components/modals/modal-change-activitie-history/interface.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/step-indicator/index.d.ts +3 -9
- package/lib/typescript/commonjs/src/components/step-indicator/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/modal-type-activities/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/modal-type-activities/interface.d.ts +1 -0
- package/lib/typescript/module/src/components/modal-type-activities/interface.d.ts.map +1 -1
- package/lib/typescript/module/src/components/modal-type-activities/mock/index.d.ts +17 -0
- package/lib/typescript/module/src/components/modal-type-activities/mock/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/modals/modal-change-activitie-history/helpers/index.d.ts +13 -0
- package/lib/typescript/module/src/components/modals/modal-change-activitie-history/helpers/index.d.ts.map +1 -0
- package/lib/typescript/module/src/components/modals/modal-change-activitie-history/index.d.ts +10 -0
- package/lib/typescript/module/src/components/modals/modal-change-activitie-history/index.d.ts.map +1 -0
- package/lib/typescript/module/src/components/modals/modal-change-activitie-history/interface.d.ts +18 -0
- package/lib/typescript/module/src/components/modals/modal-change-activitie-history/interface.d.ts.map +1 -0
- package/lib/typescript/module/src/components/step-indicator/index.d.ts +3 -9
- package/lib/typescript/module/src/components/step-indicator/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/modal-type-activities/index.tsx +173 -169
- package/src/components/modal-type-activities/interface.ts +36 -34
- package/src/components/modal-type-activities/mock/index.ts +103 -65
- package/src/components/modals/modal-change-activitie-history/helpers/index.ts +15 -0
- package/src/components/modals/modal-change-activitie-history/index.tsx +189 -0
- package/src/components/modals/modal-change-activitie-history/interface.ts +16 -0
- package/src/components/step-indicator/index.tsx +226 -155
- package/src/components/step-indicator/interface.d.ts +3 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
1
|
+
import React, { useState, forwardRef, useImperativeHandle, useRef } from "react";
|
|
2
|
+
import { View, Text, TouchableOpacity, FlatList, FlatList as FlatListType } from "react-native";
|
|
3
|
+
|
|
4
|
+
// components
|
|
5
|
+
import { ModalChangeActivity } from "../modals/modal-change-activitie-history";
|
|
6
6
|
|
|
7
7
|
// commons / svg
|
|
8
8
|
import { Icons } from "../../common/icons-svg";
|
|
@@ -10,182 +10,253 @@ import { Icons } from "../../common/icons-svg";
|
|
|
10
10
|
// helpers
|
|
11
11
|
import { getIconKeyByValue } from "./helpers/get-icon-by-status";
|
|
12
12
|
|
|
13
|
-
// utils
|
|
14
|
-
import { formHoursMinute } from "../../utils/format-date";
|
|
15
|
-
|
|
16
13
|
// typings
|
|
17
14
|
import type { IStepIndicator } from "./interface";
|
|
18
15
|
|
|
16
|
+
// utils
|
|
17
|
+
import { formHoursMinute } from "../../utils/format-date";
|
|
18
|
+
|
|
19
19
|
// styles
|
|
20
20
|
import { styles } from "./styles";
|
|
21
21
|
import { theme } from "../../styles/theme/theme";
|
|
22
|
+
import { asBaseComponent } from "../../@types/as-base-component";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Componente StepIndicator para a interação da ui.
|
|
25
26
|
*/
|
|
27
|
+
const StepIndicator = forwardRef<any, IStepIndicator>(
|
|
28
|
+
(
|
|
29
|
+
{ data = [], type, textColorDescription, titleColor, titleNumberColor, onChangeActivity },
|
|
30
|
+
ref
|
|
31
|
+
) => {
|
|
32
|
+
const StepDefault = () => {
|
|
33
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
34
|
+
const [currentStepIndex, setCurrentStepIndex] = useState<number | null>(null);
|
|
35
|
+
const [stepData, setStepData] = useState(data);
|
|
26
36
|
|
|
27
|
-
const
|
|
28
|
-
data = [],
|
|
29
|
-
type,
|
|
30
|
-
textColorDescription,
|
|
31
|
-
titleColor,
|
|
32
|
-
titleNumberColor,
|
|
33
|
-
handleOnPressActivitie,
|
|
34
|
-
}) => {
|
|
35
|
-
const StepDefault = () => {
|
|
36
|
-
return (
|
|
37
|
-
<>
|
|
38
|
-
{data!.length > 0 &&
|
|
39
|
-
data!.map((history, index) => {
|
|
40
|
-
// pegando primeira atividade pelo index
|
|
41
|
-
const isFirst = index === 0;
|
|
42
|
-
//pegando o tipo de atividade
|
|
43
|
-
const isEditableType = history.tipo === "descanso";
|
|
44
|
-
|
|
45
|
-
// pegando o valor para saber se atividade ta ou não sincronizada
|
|
46
|
-
const isSynced = history?.sincronizado === true;
|
|
47
|
-
|
|
48
|
-
const canEdit = isFirst && isEditableType && isSynced;
|
|
37
|
+
const flatListRef = useRef<FlatListType<any>>(null);
|
|
49
38
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
activeOpacity={0.7}
|
|
54
|
-
key={history.id}
|
|
55
|
-
style={styles({}).containerIndicator}
|
|
56
|
-
disabled={!canEdit}
|
|
57
|
-
onPress={() => handleOnPressActivitie(history as any)}
|
|
58
|
-
>
|
|
59
|
-
<View style={styles({ sincronizado: history.sincronizado }).containerBall}>
|
|
60
|
-
{data!?.length > 1 && index < data!?.length - 1 && (
|
|
61
|
-
<View
|
|
62
|
-
style={{
|
|
63
|
-
width: 2,
|
|
64
|
-
height: 84,
|
|
65
|
-
marginTop: 116,
|
|
66
|
-
position: "relative",
|
|
67
|
-
backgroundColor: history.sincronizado
|
|
68
|
-
? theme.colors.blue[500]
|
|
69
|
-
: theme.colors.orange[150],
|
|
70
|
-
}}
|
|
71
|
-
/>
|
|
72
|
-
)}
|
|
73
|
-
<Text style={styles({ titleNumberColor }).titleNumber}>
|
|
74
|
-
{data!?.length - index}
|
|
75
|
-
</Text>
|
|
76
|
-
</View>
|
|
39
|
+
const handleOnPressActivitie = (stepItem: any, index: number) => {
|
|
40
|
+
const desc = stepItem?.descricao?.toLowerCase?.();
|
|
41
|
+
if (!desc) return;
|
|
77
42
|
|
|
78
|
-
|
|
79
|
-
|
|
43
|
+
const isDescanso = ["descanso", "refeição", "repouso_noturno", "repouso_semanal"].includes(
|
|
44
|
+
desc.replace(/\s+/g, "_")
|
|
45
|
+
);
|
|
80
46
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
47
|
+
if (isDescanso && stepItem?.sincronizado === true) {
|
|
48
|
+
setCurrentStepIndex(index);
|
|
49
|
+
setIsModalVisible(true);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
86
52
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
>
|
|
53
|
+
const handleConfirmModal = (newData: { label: string; value: string; key: number }) => {
|
|
54
|
+
if (currentStepIndex !== null) {
|
|
55
|
+
const updatedStep = {
|
|
56
|
+
...stepData[currentStepIndex],
|
|
57
|
+
descricao: newData.label,
|
|
58
|
+
referencia: newData.value,
|
|
59
|
+
jr_tipo_atividade_id: newData.key,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const newSteps = stepData.map((item, index) =>
|
|
63
|
+
index === currentStepIndex ? updatedStep : item
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
setStepData(newSteps as any);
|
|
67
|
+
|
|
68
|
+
if (onChangeActivity) {
|
|
69
|
+
onChangeActivity(updatedStep);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setIsModalVisible(false);
|
|
74
|
+
setCurrentStepIndex(null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// render item padrão do step indicator
|
|
78
|
+
const renderItem = ({ item: history, index }: { item: any; index: number }) => {
|
|
79
|
+
const isFirst = index === 0;
|
|
80
|
+
const isEditableType = history.tipo === "descanso";
|
|
81
|
+
const isSynced = history?.sincronizado === true;
|
|
82
|
+
const canEdit = isFirst && isEditableType && isSynced;
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<TouchableOpacity
|
|
86
|
+
testID="step-indicator"
|
|
87
|
+
activeOpacity={0.7}
|
|
88
|
+
style={styles({}).containerIndicator}
|
|
89
|
+
disabled={!canEdit}
|
|
90
|
+
onPress={() => handleOnPressActivitie(history, index)}
|
|
91
|
+
>
|
|
92
|
+
<View style={styles({ sincronizado: history.sincronizado }).containerBall}>
|
|
93
|
+
{stepData.length > 1 && index < stepData.length - 1 && (
|
|
94
|
+
<View
|
|
95
|
+
style={{
|
|
96
|
+
width: 2,
|
|
97
|
+
height: 84,
|
|
98
|
+
marginTop: 116,
|
|
99
|
+
position: "relative",
|
|
100
|
+
backgroundColor: history.sincronizado
|
|
101
|
+
? theme.colors.blue[500]
|
|
102
|
+
: theme.colors.orange[150],
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
<Text style={styles({ titleNumberColor }).titleNumber}>
|
|
107
|
+
{stepData.length - index}
|
|
108
|
+
</Text>
|
|
109
|
+
</View>
|
|
110
|
+
|
|
111
|
+
<View style={styles({}).containerMain}>
|
|
112
|
+
<Text style={styles({ titleColor }).title}>{history?.descricao}</Text>
|
|
113
|
+
|
|
114
|
+
{history?.data_inicio && (
|
|
115
|
+
<Text style={styles({ textColorDescription }).titleDescription}>
|
|
116
|
+
{`Inicio: ${history.data_inicio} ás ${history.data_fim}`}
|
|
117
|
+
</Text>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
{history.duracao_segundos && (
|
|
121
|
+
<Text style={styles({ textColorDescription }).titleDescription}>
|
|
122
|
+
Duração: {formHoursMinute(history?.duracao_segundos as string)}
|
|
123
|
+
</Text>
|
|
124
|
+
)}
|
|
125
|
+
</View>
|
|
126
|
+
</TouchableOpacity>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Expor funções para o pai via forwardRef
|
|
131
|
+
useImperativeHandle(ref, () => ({
|
|
132
|
+
scrollToIndex: (index: number) => {
|
|
133
|
+
flatListRef.current?.scrollToIndex({ index, animated: true });
|
|
134
|
+
},
|
|
135
|
+
openModalAt: (index: number) => {
|
|
136
|
+
if (stepData[index]) {
|
|
137
|
+
setCurrentStepIndex(index);
|
|
138
|
+
setIsModalVisible(true);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
resetSteps: (newData: any[]) => {
|
|
142
|
+
setStepData(newData);
|
|
143
|
+
},
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<>
|
|
148
|
+
<FlatList
|
|
149
|
+
ref={flatListRef}
|
|
150
|
+
data={stepData}
|
|
151
|
+
renderItem={renderItem}
|
|
152
|
+
keyExtractor={(item, index) => String(item?.id ?? String(index))}
|
|
153
|
+
showsVerticalScrollIndicator={false}
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
{isModalVisible && (
|
|
157
|
+
<ModalChangeActivity
|
|
158
|
+
visible={isModalVisible}
|
|
159
|
+
modalConfirm={handleConfirmModal}
|
|
160
|
+
descricao=""
|
|
161
|
+
onClose={() => setIsModalVisible(false)}
|
|
162
|
+
/>
|
|
163
|
+
)}
|
|
164
|
+
</>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const StepCustom = () => {
|
|
169
|
+
return (
|
|
170
|
+
<View
|
|
171
|
+
style={{
|
|
172
|
+
width: "100%",
|
|
173
|
+
height: 84,
|
|
174
|
+
paddingHorizontal: 24,
|
|
175
|
+
display: "flex",
|
|
176
|
+
flexDirection: "row",
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{data.map((step, indexCustom) => {
|
|
180
|
+
const descricao = getIconKeyByValue(step.descricao);
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<React.Fragment key={`step-${indexCustom}`}>
|
|
128
184
|
<View
|
|
129
185
|
style={{
|
|
130
186
|
width: 45,
|
|
131
187
|
height: 45,
|
|
132
|
-
backgroundColor: "transparent",
|
|
188
|
+
backgroundColor: indexCustom <= 3 ? "orange" : "transparent",
|
|
133
189
|
borderRadius: 50,
|
|
134
190
|
alignItems: "center",
|
|
135
191
|
justifyContent: "center",
|
|
192
|
+
borderWidth: 1,
|
|
193
|
+
borderColor: "#fff",
|
|
136
194
|
}}
|
|
137
195
|
>
|
|
138
|
-
|
|
196
|
+
<View
|
|
197
|
+
style={{
|
|
198
|
+
width: 45,
|
|
199
|
+
height: 45,
|
|
200
|
+
backgroundColor: "transparent",
|
|
201
|
+
borderRadius: 50,
|
|
202
|
+
alignItems: "center",
|
|
203
|
+
justifyContent: "center",
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
{descricao && <Icons icon={descricao} />}
|
|
207
|
+
</View>
|
|
208
|
+
<Text
|
|
209
|
+
style={{
|
|
210
|
+
position: "absolute",
|
|
211
|
+
top: 56,
|
|
212
|
+
fontWeight: "600",
|
|
213
|
+
fontSize: 10,
|
|
214
|
+
lineHeight: 14,
|
|
215
|
+
textAlign: "center",
|
|
216
|
+
color: "#fff",
|
|
217
|
+
width: 75,
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
{step.descricao}
|
|
221
|
+
</Text>
|
|
139
222
|
</View>
|
|
140
|
-
<Text
|
|
141
|
-
style={{
|
|
142
|
-
position: "absolute",
|
|
143
|
-
top: 56,
|
|
144
|
-
fontWeight: "600",
|
|
145
|
-
fontSize: 10,
|
|
146
|
-
lineHeight: 14,
|
|
147
|
-
textAlign: "center",
|
|
148
|
-
color: "#fff",
|
|
149
|
-
width: 75,
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
{step.descricao}
|
|
153
|
-
</Text>
|
|
154
|
-
</View>
|
|
155
223
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
224
|
+
{data?.length > 1 && indexCustom < data?.length - 1 && (
|
|
225
|
+
<View
|
|
226
|
+
style={{
|
|
227
|
+
width: 35,
|
|
228
|
+
height: 2,
|
|
229
|
+
marginTop: 24,
|
|
230
|
+
position: "relative",
|
|
231
|
+
backgroundColor: "orange",
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
)}
|
|
235
|
+
</React.Fragment>
|
|
236
|
+
);
|
|
237
|
+
})}
|
|
238
|
+
</View>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const handleRenderComponent = (stepType: "default" | "custom") => {
|
|
243
|
+
switch (stepType) {
|
|
244
|
+
case "default":
|
|
245
|
+
return <StepDefault />;
|
|
246
|
+
case "custom":
|
|
247
|
+
return <StepCustom />;
|
|
248
|
+
default:
|
|
249
|
+
return <View />;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return <>{handleRenderComponent(type!)}</>;
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
StepIndicator.displayName = "StepIndicator";
|
|
187
258
|
|
|
188
259
|
/**
|
|
189
|
-
*
|
|
260
|
+
* Componente StepIndicator para a interação da ui.
|
|
190
261
|
*/
|
|
191
|
-
export default StepIndicator;
|
|
262
|
+
export default asBaseComponent(StepIndicator);
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
type IData = {
|
|
7
|
-
id
|
|
7
|
+
id?: number | string;
|
|
8
|
+
jr_tipo_atividade_id?: number;
|
|
8
9
|
duracao_segundos: string | number;
|
|
9
10
|
data_inicio: string;
|
|
10
11
|
data_fim: string;
|
|
@@ -38,7 +39,7 @@ interface IStepIndicator {
|
|
|
38
39
|
textColorDescription?: string;
|
|
39
40
|
|
|
40
41
|
/**params para lidar com selecionamento de atividade única */
|
|
41
|
-
|
|
42
|
+
onChangeActivity?: (activity: any) => void;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* EXPORTS
|