Skip to content

Commit 687b62d

Browse files
refactor: move sharable types
1 parent e70eaac commit 687b62d

3 files changed

Lines changed: 26 additions & 24 deletions

File tree

app/components/Package/TrendsChart.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
DailyDataPoint,
1111
DateRangeFields,
1212
EvolutionData,
13+
EvolutionOptions,
1314
MonthlyDataPoint,
1415
WeeklyDataPoint,
1516
YearlyDataPoint,

app/composables/useCharts.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import type { MaybeRefOrGetter } from 'vue'
22
import { toValue } from 'vue'
33
import type {
44
DailyDataPoint,
5-
EvolutionOptionsBase,
5+
DailyRawPoint,
6+
EvolutionOptions,
67
MonthlyDataPoint,
78
WeeklyDataPoint,
89
YearlyDataPoint,
@@ -13,29 +14,6 @@ export type PackumentLikeForTime = {
1314
time?: Record<string, string>
1415
}
1516

16-
export type EvolutionOptionsDay = EvolutionOptionsBase & {
17-
granularity: 'day'
18-
}
19-
export type EvolutionOptionsWeek = EvolutionOptionsBase & {
20-
granularity: 'week'
21-
weeks?: number
22-
}
23-
export type EvolutionOptionsMonth = EvolutionOptionsBase & {
24-
granularity: 'month'
25-
months?: number
26-
}
27-
export type EvolutionOptionsYear = EvolutionOptionsBase & {
28-
granularity: 'year'
29-
}
30-
31-
export type EvolutionOptions =
32-
| EvolutionOptionsDay
33-
| EvolutionOptionsWeek
34-
| EvolutionOptionsMonth
35-
| EvolutionOptionsYear
36-
37-
type DailyRawPoint = { day: string; value: number }
38-
3917
function toIsoDateString(date: Date): string {
4018
return date.toISOString().slice(0, 10)
4119
}

app/types/chart.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,26 @@ export type EvolutionOptionsBase = {
2727
startDate?: string
2828
endDate?: string
2929
}
30+
31+
export type EvolutionOptionsDay = EvolutionOptionsBase & {
32+
granularity: 'day'
33+
}
34+
export type EvolutionOptionsWeek = EvolutionOptionsBase & {
35+
granularity: 'week'
36+
weeks?: number
37+
}
38+
export type EvolutionOptionsMonth = EvolutionOptionsBase & {
39+
granularity: 'month'
40+
months?: number
41+
}
42+
export type EvolutionOptionsYear = EvolutionOptionsBase & {
43+
granularity: 'year'
44+
}
45+
46+
export type EvolutionOptions =
47+
| EvolutionOptionsDay
48+
| EvolutionOptionsWeek
49+
| EvolutionOptionsMonth
50+
| EvolutionOptionsYear
51+
52+
export type DailyRawPoint = { day: string; value: number }

0 commit comments

Comments
 (0)