@devix-tecnologia/timeline-vue 1.0.1 → 1.1.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 (34) hide show
  1. package/README.md +138 -11
  2. package/dist/style.css +1 -1
  3. package/dist/timeline-vue.es.js +293 -256
  4. package/dist/types/components/timeline/atomos/AvatarTimeline.vue.d.ts +0 -1
  5. package/dist/types/components/timeline/atomos/BoxData.vue.d.ts +0 -1
  6. package/dist/types/components/timeline/atomos/Destaque.vue.d.ts +0 -1
  7. package/dist/types/components/timeline/atomos/Hora.vue.d.ts +0 -2
  8. package/dist/types/components/timeline/atomos/IconeCategoria.vue.d.ts +2 -3
  9. package/dist/types/components/timeline/atomos/IconeStatus.vue.d.ts +0 -1
  10. package/dist/types/components/timeline/atomos/SubtituloEvento.vue.d.ts +0 -1
  11. package/dist/types/components/timeline/atomos/TituloEvento.vue.d.ts +0 -1
  12. package/dist/types/components/timeline/moleculas/DescricaoEvento.vue.d.ts +0 -1
  13. package/dist/types/components/timeline/moleculas/EventoTimeline.vue.d.ts +84 -5
  14. package/dist/types/components/timeline/moleculas/HoraEvento.vue.d.ts +5 -3
  15. package/dist/types/components/timeline/moleculas/PerfilTimeline.vue.d.ts +0 -2
  16. package/dist/types/components/timeline/moleculas/SeparadorPeriodo.vue.d.ts +3 -7
  17. package/dist/types/components/timeline/moleculas/Topo.vue.d.ts +0 -1
  18. package/dist/types/components/timeline/organismos/Timeline.vue.d.ts +2 -5
  19. package/dist/types/components/timeline/type.d.ts +10 -7
  20. package/package.json +2 -2
  21. package/src/components/timeline/atomos/Destaque.vue +3 -3
  22. package/src/components/timeline/atomos/Hora.vue +7 -10
  23. package/src/components/timeline/atomos/IconeCategoria.vue +6 -6
  24. package/src/components/timeline/atomos/IconeStatus.vue +17 -16
  25. package/src/components/timeline/moleculas/DescricaoEvento.vue +5 -5
  26. package/src/components/timeline/moleculas/EventoTimeline.stories.ts +49 -49
  27. package/src/components/timeline/moleculas/EventoTimeline.vue +82 -26
  28. package/src/components/timeline/moleculas/HoraEvento.vue +5 -4
  29. package/src/components/timeline/moleculas/PerfilTimeline.vue +2 -3
  30. package/src/components/timeline/moleculas/SeparadorPeriodo.vue +26 -27
  31. package/src/components/timeline/organismos/Timeline.mock.ts +87 -57
  32. package/src/components/timeline/organismos/Timeline.stories.ts +22 -5
  33. package/src/components/timeline/organismos/Timeline.vue +97 -73
  34. package/src/components/timeline/type.ts +11 -7
@@ -14,7 +14,7 @@ export const dadosEventos: Evento[] = [
14
14
  previsto: new Date("2023-04-26T19:00Z"),
15
15
  realizado: new Date("2023-04-26T19:30Z"),
16
16
  duracao: null,
17
- tolerancia: null,
17
+ tolerancia: 10,
18
18
  titulo: "Vacina da Covid",
19
19
  subtitulo: "Posto de saúde do bairro",
20
20
  destaque: "",
@@ -24,7 +24,9 @@ export const dadosEventos: Evento[] = [
24
24
  },
25
25
  status: "realizado",
26
26
  criticidade: "media",
27
- acao: false,
27
+
28
+ atual: false,
29
+ scroll: false,
28
30
  },
29
31
  {
30
32
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f2",
@@ -32,7 +34,7 @@ export const dadosEventos: Evento[] = [
32
34
  previsto: new Date("2023-04-26T18:10Z"),
33
35
  realizado: new Date("2023-04-26T18:15Z"),
34
36
  duracao: null,
35
- tolerancia: null,
37
+ tolerancia: 10,
36
38
  titulo: "Vacina da gripe",
37
39
  subtitulo: "Posto de saúde do bairro",
38
40
  destaque: "",
@@ -42,15 +44,17 @@ export const dadosEventos: Evento[] = [
42
44
  },
43
45
  status: "cancelado",
44
46
  criticidade: "baixa",
45
- acao: false,
47
+
48
+ atual: false,
49
+ scroll: false,
46
50
  },
47
51
  {
48
52
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f3",
49
- data: new Date("2023-05-03T09:00Z"),
50
- previsto: new Date("2023-05-03T09:00Z"),
51
- realizado: new Date("2023-05-03T09:00Z"),
53
+ data: new Date("2023-05-03T11:00Z"),
54
+ previsto: new Date("2023-05-03T11:00Z"),
55
+ realizado: null,
52
56
  duracao: null,
53
- tolerancia: null,
57
+ tolerancia: 10,
54
58
  titulo: "Ligar para médica",
55
59
  subtitulo: "",
56
60
  destaque: "",
@@ -60,15 +64,17 @@ export const dadosEventos: Evento[] = [
60
64
  },
61
65
  status: "planejado",
62
66
  criticidade: "baixa",
63
- acao: true,
67
+
68
+ atual: false,
69
+ scroll: false,
64
70
  },
65
71
  {
66
72
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f4",
67
- data: new Date("2023-05-03T10:00Z"),
68
- previsto: new Date("2023-05-03T10:00Z"),
73
+ data: new Date("2023-05-03T15:00Z"),
74
+ previsto: new Date("2023-05-03T15:00Z"),
69
75
  realizado: null,
70
76
  duracao: null,
71
- tolerancia: null,
77
+ tolerancia: 10,
72
78
  titulo: "Passeio no parque",
73
79
  subtitulo: "",
74
80
  destaque: "",
@@ -78,15 +84,17 @@ export const dadosEventos: Evento[] = [
78
84
  },
79
85
  status: "planejado",
80
86
  criticidade: "baixa",
81
- acao: false,
87
+
88
+ atual: false,
89
+ scroll: false,
82
90
  },
83
91
  {
84
92
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f5",
85
- data: new Date("2023-05-03T11:00Z"),
86
- previsto: new Date("2023-05-03T11:00Z"),
93
+ data: new Date("2023-05-03T20:00Z"),
94
+ previsto: new Date("2023-05-03T20:00Z"),
87
95
  realizado: null,
88
96
  duracao: null,
89
- tolerancia: null,
97
+ tolerancia: 10,
90
98
  titulo: "Exames do coração",
91
99
  subtitulo: "Hospital do Coração",
92
100
  destaque: "",
@@ -96,15 +104,17 @@ export const dadosEventos: Evento[] = [
96
104
  },
97
105
  status: "planejado",
98
106
  criticidade: "media",
99
- acao: true,
107
+
108
+ atual: false,
109
+ scroll: false,
100
110
  },
101
111
  {
102
112
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f6",
103
- data: new Date("2023-05-01T12:00Z"),
104
- previsto: new Date("2023-05-01T12:00Z"),
113
+ data: new Date("2023-04-01T12:00Z"),
114
+ previsto: new Date("2023-04-01T12:00Z"),
105
115
  realizado: null,
106
116
  duracao: null,
107
- tolerancia: null,
117
+ tolerancia: 10,
108
118
  titulo: "Consulta",
109
119
  subtitulo: "Posto de saúde",
110
120
  destaque: "Remarcado",
@@ -114,15 +124,17 @@ export const dadosEventos: Evento[] = [
114
124
  },
115
125
  status: "adiado",
116
126
  criticidade: "baixa",
117
- acao: false,
127
+
128
+ atual: false,
129
+ scroll: false,
118
130
  },
119
131
  {
120
132
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f7",
121
- data: new Date("2023-05-01T13:00Z"),
122
- previsto: new Date("2023-05-01T13:00Z"),
133
+ data: new Date("2023-04-01T13:00Z"),
134
+ previsto: new Date("2023-04-01T13:00Z"),
123
135
  realizado: null,
124
136
  duracao: null,
125
- tolerancia: null,
137
+ tolerancia: 10,
126
138
  titulo: "Consulta cardiologista",
127
139
  subtitulo: "Posto de saúde do bairro",
128
140
  destaque: "",
@@ -132,15 +144,17 @@ export const dadosEventos: Evento[] = [
132
144
  },
133
145
  status: "realizado",
134
146
  criticidade: "alta",
135
- acao: true,
147
+
148
+ atual: false,
149
+ scroll: false,
136
150
  },
137
151
  {
138
152
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f8",
139
- data: new Date("2023-05-03T12:30Z"),
140
- previsto: new Date("2023-05-03T12:30Z"),
153
+ data: new Date("2023-05-03T12:00Z"),
154
+ previsto: new Date("2023-05-03T12:00Z"),
141
155
  realizado: null,
142
156
  duracao: null,
143
- tolerancia: null,
157
+ tolerancia: 10,
144
158
  titulo: "Dentista",
145
159
  subtitulo: "Reta da Penha",
146
160
  destaque: "",
@@ -150,15 +164,17 @@ export const dadosEventos: Evento[] = [
150
164
  },
151
165
  status: "planejado",
152
166
  criticidade: "baixa",
153
- acao: false,
167
+
168
+ atual: false,
169
+ scroll: false,
154
170
  },
155
171
  {
156
172
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f9",
157
- data: new Date("2023-05-03T14:30Z"),
158
- previsto: new Date("2023-05-03T14:30Z"),
173
+ data: new Date("2023-05-03T13:00Z"),
174
+ previsto: new Date("2023-05-03T13:00Z"),
159
175
  realizado: null,
160
176
  duracao: null,
161
- tolerancia: null,
177
+ tolerancia: 10,
162
178
  titulo: "Consulta",
163
179
  subtitulo: "Hospital central",
164
180
  destaque: "",
@@ -168,15 +184,17 @@ export const dadosEventos: Evento[] = [
168
184
  },
169
185
  status: "planejado",
170
186
  criticidade: "alta",
171
- acao: true,
187
+
188
+ atual: false,
189
+ scroll: false,
172
190
  },
173
191
  {
174
192
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f10",
175
- data: new Date("2023-05-03T15:30Z"),
176
- previsto: new Date("2023-05-03T15:30Z"),
193
+ data: new Date("2023-05-03T14:27Z"),
194
+ previsto: new Date("2023-05-03T14:27Z"),
177
195
  realizado: null,
178
196
  duracao: null,
179
- tolerancia: null,
197
+ tolerancia: 10,
180
198
  titulo: "Remédio de pressão",
181
199
  subtitulo: "Aferir a pressão",
182
200
  destaque: "",
@@ -186,15 +204,17 @@ export const dadosEventos: Evento[] = [
186
204
  },
187
205
  status: "planejado",
188
206
  criticidade: "alta",
189
- acao: false,
207
+
208
+ atual: false,
209
+ scroll: false,
190
210
  },
191
211
  {
192
212
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f11",
193
- data: new Date("2023-05-03T16:00Z"),
194
- previsto: new Date("2023-05-03T16:00Z"),
213
+ data: new Date("2023-05-03T15:00Z"),
214
+ previsto: new Date("2023-05-03T15:00Z"),
195
215
  realizado: null,
196
216
  duracao: null,
197
- tolerancia: null,
217
+ tolerancia: 10,
198
218
  titulo: "Checar temperatura",
199
219
  subtitulo: "",
200
220
  destaque: "",
@@ -204,15 +224,17 @@ export const dadosEventos: Evento[] = [
204
224
  },
205
225
  status: "planejado",
206
226
  criticidade: "baixa",
207
- acao: true,
227
+
228
+ atual: false,
229
+ scroll: false,
208
230
  },
209
231
  {
210
232
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f12",
211
- data: new Date("2023-05-03T17:30Z"),
212
- previsto: new Date("2023-05-03T17:30Z"),
233
+ data: new Date("2023-05-08T16:00Z"),
234
+ previsto: new Date("2023-05-08T16:00Z"),
213
235
  realizado: null,
214
236
  duracao: null,
215
- tolerancia: null,
237
+ tolerancia: 10,
216
238
  titulo: "Avaliação Física",
217
239
  subtitulo: "",
218
240
  destaque: "IMC: 28,4",
@@ -222,15 +244,17 @@ export const dadosEventos: Evento[] = [
222
244
  },
223
245
  status: "planejado",
224
246
  criticidade: "baixa",
225
- acao: false,
247
+
248
+ atual: false,
249
+ scroll: false,
226
250
  },
227
251
  {
228
252
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f13",
229
- data: new Date("2023-05-03T18:00Z"),
230
- previsto: new Date("2023-05-03T18:00Z"),
253
+ data: new Date("2023-05-09T19:00Z"),
254
+ previsto: new Date("2023-05-09T19:00Z"),
231
255
  realizado: null,
232
256
  duracao: null,
233
- tolerancia: null,
257
+ tolerancia: 10,
234
258
  titulo: "Vacina da gripe",
235
259
  subtitulo: "Posto de saúde do bairro",
236
260
  destaque: "",
@@ -240,15 +264,17 @@ export const dadosEventos: Evento[] = [
240
264
  },
241
265
  status: "planejado",
242
266
  criticidade: "baixa",
243
- acao: true,
267
+
268
+ atual: false,
269
+ scroll: false,
244
270
  },
245
271
  {
246
272
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f14",
247
- data: new Date("2023-05-03T19:00Z"),
248
- previsto: new Date("2023-05-03T19:00Z"),
273
+ data: new Date("2023-05-09T17:00Z"),
274
+ previsto: new Date("2023-05-09T17:00Z"),
249
275
  realizado: null,
250
276
  duracao: null,
251
- tolerancia: null,
277
+ tolerancia: 10,
252
278
  titulo: "Vitamina D",
253
279
  subtitulo: "2 comprimidos",
254
280
  destaque: "",
@@ -258,15 +284,17 @@ export const dadosEventos: Evento[] = [
258
284
  },
259
285
  status: "planejado",
260
286
  criticidade: "baixa",
261
- acao: false,
287
+ aoCLicar: () => alert("Olá, mundo!"),
288
+ atual: false,
289
+ scroll: false,
262
290
  },
263
291
  {
264
292
  id: "15ea7863-2402-4b84-8a8d-10a00ba07e2f15",
265
- data: new Date("2023-05-03T20:00Z"),
266
- previsto: new Date("2023-05-03T20:00Z"),
293
+ data: new Date("2023-05-09T18:01Z"),
294
+ previsto: new Date("2023-05-09T18:00Z"),
267
295
  realizado: null,
268
296
  duracao: null,
269
- tolerancia: null,
297
+ tolerancia: 10,
270
298
  titulo: "Fisioterapia",
271
299
  subtitulo: "",
272
300
  destaque: "",
@@ -276,6 +304,8 @@ export const dadosEventos: Evento[] = [
276
304
  },
277
305
  status: "planejado",
278
306
  criticidade: "baixa",
279
- acao: true,
307
+
308
+ atual: false,
309
+ scroll: false,
280
310
  },
281
311
  ];
@@ -1,12 +1,13 @@
1
- import Timeline from './Timeline.vue';
2
- import { Meta, StoryFn } from '@storybook/vue3';
3
- import { dadosEventos, dadosPerfil } from './Timeline.mock';
1
+ import Timeline from "./Timeline.vue";
2
+ import { Meta, StoryFn } from "@storybook/vue3";
3
+ import { dadosEventos, dadosPerfil } from "./Timeline.mock";
4
+ import { Evento } from "../type";
4
5
 
5
6
  export default {
6
- title: 'Devix/Timeline/Organismos/Timeline',
7
+ title: "Devix/Timeline/Organismos/Timeline",
7
8
  component: Timeline,
8
9
  parameters: {
9
- componentSubtitle: 'Linha do tempo padrão com identidade da Devix',
10
+ componentSubtitle: "Linha do tempo padrão com identidade da Devix",
10
11
  },
11
12
  argTypes: {},
12
13
  } as Meta<typeof Timeline>;
@@ -15,6 +16,22 @@ const perfilMock = dadosPerfil;
15
16
 
16
17
  const eventosPorDataMock = dadosEventos;
17
18
 
19
+ function atualizarDatas(eventos: Evento[]) {
20
+ const agora = new Date();
21
+ const mesAtual = agora.getMonth() + 1;
22
+
23
+ for (let i = 0; i < eventos.length; i++) {
24
+ const evento = eventos[i];
25
+ const mesEvento = evento.data.getMonth() + 1;
26
+
27
+ if (mesEvento >= mesAtual) {
28
+ evento.data.setMonth(agora.getMonth(), agora.getDate());
29
+ evento.previsto.setMonth(agora.getMonth(), agora.getDate());
30
+ }
31
+ }
32
+ }
33
+ atualizarDatas(dadosEventos);
34
+
18
35
  const Template: StoryFn<typeof Timeline> = (args) => ({
19
36
  components: { Timeline: Timeline },
20
37
  setup() {
@@ -1,30 +1,34 @@
1
1
  <template>
2
- <div>
3
- <div>
4
- <PerfilTimeline
5
- v-if="perfilTimeline !== null"
6
- :nomePerfil="perfilTimeline.nome"
7
- :imagemPerfil="perfilTimeline.imagem"
8
- :iconePerfil="perfilTimeline.icone"
9
- />
10
- </div>
11
-
12
- <div
13
- v-for="evento in eventosPorTipo"
14
- :key="evento.key"
15
- class="areaTimeline"
16
- >
2
+ <div class="areaTimeline">
3
+ <PerfilTimeline
4
+ v-if="perfilTimeline !== null"
5
+ :nomePerfil="perfilTimeline.nome"
6
+ :imagemPerfil="perfilTimeline.imagem"
7
+ :iconePerfil="perfilTimeline.icone"
8
+ />
9
+ <section class="timeline">
17
10
  <!-- SEPARADOR -->
18
- <div v-if="evento.tipo === 'dia'">
19
- <SeparadorPeriodo :dataSeparador="evento.valor.toDateString()" />
11
+ <div v-for="evento in eventosPorTipo" :key="evento.key">
12
+ <SeparadorPeriodo
13
+ v-if="evento.tipo === 'dia'"
14
+ :dataSeparador="evento.valor"
15
+ />
16
+ <!--loop-->
17
+ <EventoTimeline
18
+ v-if="evento.tipo === 'evento'"
19
+ :status="evento.valor.status"
20
+ :criticidade="evento.valor.criticidade"
21
+ :previsto="evento.valor.previsto"
22
+ :realizado="evento.valor.realizado"
23
+ :categoria="evento.valor.categoria"
24
+ :titulo="evento.valor.titulo"
25
+ :subtitulo="evento.valor.subtitulo"
26
+ :destaque="evento.valor.destaque"
27
+ :ehAtual="evento.valor.atual"
28
+ :aoCLicar="evento.valor.aoCLicar"
29
+ />
20
30
  </div>
21
- <div v-if="evento.tipo === 'evento'">
22
- <section class="timeline">
23
- <!--loop-->
24
- <EventoTimeline :dadosEvento="evento" />
25
- </section>
26
- </div>
27
- </div>
31
+ </section>
28
32
  </div>
29
33
  </template>
30
34
 
@@ -37,11 +41,9 @@ import { Evento } from "../type";
37
41
 
38
42
  type TipoEventoTimeline =
39
43
  | { tipo: "dia"; valor: Date; key: number }
40
- | { tipo: "evento"; valor: Evento; key: number; atual: boolean }
44
+ | { tipo: "evento"; valor: Evento; key: number }
41
45
  | { tipo: "eventos"; valor: Evento[]; key: number };
42
46
 
43
- // type Ordem = 'ascendente' | 'descendente';
44
-
45
47
  export default defineComponent({
46
48
  props: {
47
49
  perfilTimeline: {
@@ -52,10 +54,6 @@ export default defineComponent({
52
54
  required: true,
53
55
  type: Object,
54
56
  },
55
- // ordem: {
56
- // required: false,
57
- // type: Ordem,
58
- // },
59
57
  },
60
58
  components: {
61
59
  PerfilTimeline,
@@ -66,12 +64,29 @@ export default defineComponent({
66
64
  const dadosEventosTimeline: Evento[] = reactive(
67
65
  props.eventosTimeline as Array<Evento>
68
66
  );
67
+ let dadosEventosTimelineClone: Evento[] = reactive(dadosEventosTimeline);
68
+
69
+ function carregarListaEventos() {
70
+ dadosEventosTimelineClone = dadosEventosTimeline;
71
+ const resultado: Evento[] = filtraEventoAtual(dadosEventosTimelineClone);
72
+ dadosEventosTimelineClone.map((resp) => {
73
+ if (resultado[0].id === resp.id) {
74
+ resp.atual = true;
75
+ resp.scroll = true;
76
+ void scrollParaItemAtual();
77
+ } else {
78
+ resp.atual = false;
79
+ resp.scroll = false;
80
+ }
81
+ return {
82
+ evento: resp,
83
+ };
84
+ });
85
+ }
69
86
 
70
- const eventosOrdenados = dadosEventosTimeline.sort(
71
- (a: Evento, b: Evento) => {
72
- return a.data.getTime() - b.data.getTime();
73
- }
74
- );
87
+ const atualizarEventoAtual = () => {
88
+ setInterval(carregarListaEventos, 60000);
89
+ };
75
90
 
76
91
  const verifica_mesmo_dia = (a: Date, b: Date) => {
77
92
  const mesmo_dia = a.getDay() === b.getDay();
@@ -81,85 +96,94 @@ export default defineComponent({
81
96
  };
82
97
 
83
98
  //verifica qual evento está mais próximo da hora atual e coloca ele numa nova lista na primeira posição
84
- function filtraEventoAtual(eventos: Evento[]) {
99
+ const filtraEventoAtual = (eventos: Evento[]) => {
85
100
  if (eventos) {
86
101
  const agora = Date.now();
87
- let minDiff = null;
102
+ let minDiff: number | null = null;
88
103
  let listaEventos = [];
89
104
  for (const e of eventos) {
90
105
  const t = e.data.getTime();
91
- const diff = Math.abs(agora - t);
92
- if (minDiff === null || diff < minDiff) {
93
- minDiff = diff;
94
- listaEventos.length = 0;
95
- }
96
- //se o evento já estiver marcado como realizado, cancelado ou adiado, ele pula para o próximo da lista.
97
106
  if (e.status === "planejado" || e.status === "atrasado") {
107
+ const diff: number = Math.abs(agora - e.data.getTime());
108
+ if (minDiff === null || (diff < minDiff && t <= agora)) {
109
+ minDiff = diff;
110
+ listaEventos.length = 0;
111
+ } else if (diff > minDiff) {
112
+ continue;
113
+ }
98
114
  listaEventos.push(e);
99
115
  }
100
116
  }
101
117
  return listaEventos;
102
118
  } else {
103
- console.log("vazio.. ", []);
104
119
  return [];
105
120
  }
106
- }
107
- const eventosFiltrados: Evento[] = filtraEventoAtual(eventosOrdenados);
108
- const eventoAtual = eventosFiltrados[0]
109
- ? (eventosFiltrados[0] as Evento)
110
- : null;
111
-
112
- //lista de eventos
113
- const eventosPorTipo = computed(() => {
114
- if (dadosEventosTimeline) {
115
- let result: Array<TipoEventoTimeline> = [];
121
+ };
122
+
123
+ // lista de eventos por tipo
124
+ const eventosTimeline = computed(() => {
125
+ void atualizarEventoAtual();
126
+
127
+ const eventosOrdenados = dadosEventosTimelineClone.sort(
128
+ (a: Evento, b: Evento) => {
129
+ return a.data.getTime() - b.data.getTime();
130
+ }
131
+ );
132
+ if (eventosOrdenados) {
133
+ let resultado: Array<TipoEventoTimeline> = [];
116
134
  let dataAtual: Date | null = null;
117
135
  let idx = 0;
136
+ let statusEvento;
118
137
 
119
138
  for (const evento of eventosOrdenados) {
139
+ const agora = new Date();
120
140
  const dataEvento = evento.data;
121
-
141
+ statusEvento = evento.status;
142
+ const toleranciaEvento = evento.tolerancia * 60 * 1000;
143
+
144
+ //altera status para atrasado
145
+ if (
146
+ statusEvento === "planejado" &&
147
+ dataEvento.getTime() + toleranciaEvento < agora.getTime()
148
+ ) {
149
+ evento.status = "atrasado";
150
+ }
122
151
  if (!dataAtual || !verifica_mesmo_dia(dataAtual, dataEvento)) {
123
152
  dataAtual = dataEvento;
124
- result.push({
153
+ resultado.push({
125
154
  tipo: "dia",
126
155
  valor: evento.data,
127
156
  key: ++idx,
128
157
  });
129
158
  }
130
-
131
- result.push({
159
+ resultado.push({
132
160
  tipo: "evento",
133
161
  valor: evento,
134
162
  key: ++idx,
135
- atual:
136
- eventoAtual === null
137
- ? false
138
- : evento.id === eventoAtual.id
139
- ? true
140
- : false,
141
163
  });
142
164
  }
143
- return result;
165
+ return resultado;
144
166
  } else {
145
167
  return [];
146
168
  }
147
169
  });
148
170
 
149
- return {
150
- eventosPorTipo,
151
- };
152
- },
153
- methods: {
154
- scrollParaItemAtual() {
171
+ const scrollParaItemAtual = () => {
155
172
  const itemAtual = document.querySelector(".atual");
156
173
  itemAtual?.scrollIntoView({
157
174
  behavior: "smooth",
158
175
  block: "center",
159
176
  });
160
- },
177
+ };
178
+
179
+ carregarListaEventos();
180
+ return {
181
+ eventosPorTipo: eventosTimeline,
182
+ scrollParaItemAtual,
183
+ };
161
184
  },
162
185
  mounted() {
186
+ // Aguardando a renderização para fazer scroll
163
187
  this.scrollParaItemAtual();
164
188
  },
165
189
  });
@@ -4,20 +4,22 @@ export type Perfil = {
4
4
  icone: string | null;
5
5
  };
6
6
 
7
+ export type Categoria = {
8
+ nome: string;
9
+ icone: string;
10
+ };
11
+
7
12
  export type Evento = {
8
13
  id: string;
9
14
  data: Date;
10
15
  previsto: Date;
11
16
  duracao: number | null;
12
17
  realizado: Date | null;
13
- tolerancia: number | null;
18
+ tolerancia: number;
14
19
  titulo: string;
15
20
  subtitulo: string;
16
21
  destaque: string;
17
- categoria: {
18
- nome: string;
19
- icone: string;
20
- };
22
+ categoria: Categoria;
21
23
  status:
22
24
  | "atrasado"
23
25
  | "adiantado"
@@ -25,6 +27,8 @@ export type Evento = {
25
27
  | "realizado"
26
28
  | "planejado"
27
29
  | "cancelado";
28
- criticidade: string;
29
- acao: boolean;
30
+ criticidade: "baixa" | "media" | "alta";
31
+ aoCLicar?: VoidFunction;
32
+ atual: boolean;
33
+ scroll: boolean;
30
34
  };