Client - minor refactor

This commit is contained in:
Sam 2021-09-25 11:28:40 +02:00
parent 060c5d42d9
commit 146899c269
12 changed files with 19 additions and 21 deletions

View File

@ -17,7 +17,8 @@
import { BarChart, useBarChart } from 'vue-chart-3' import { BarChart, useBarChart } from 'vue-chart-3'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { IStatisticsChartDataset, TDatasetKeys } from '@/types/statistics' import { IChartDataset } from '@/types/chart'
import { TDatasetKeys } from '@/types/statistics'
import { formatTooltipValue } from '@/utils/tooltip' import { formatTooltipValue } from '@/utils/tooltip'
Chart.register(...registerables) Chart.register(...registerables)
@ -30,7 +31,7 @@
}, },
props: { props: {
datasets: { datasets: {
type: Object as PropType<IStatisticsChartDataset[]>, type: Object as PropType<IChartDataset[]>,
required: true, required: true,
}, },
labels: { labels: {

View File

@ -27,7 +27,7 @@
import { ComputedRef, PropType, defineComponent, computed } from 'vue' import { ComputedRef, PropType, defineComponent, computed } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import UserStatCard from '@/components/Dashboard/UserStartsCards/UserStatCard.vue' import UserStatCard from '@/components/Dashboard/UserStatsCards/UserStatCard.vue'
import { IAuthUserProfile } from '@/types/user' import { IAuthUserProfile } from '@/types/user'
export default defineComponent({ export default defineComponent({

View File

@ -0,0 +1,5 @@
export interface IChartDataset {
label: string
backgroundColor: string[]
data: number[]
}

View File

@ -1,3 +0,0 @@
export type genericObject = {
[key: string]: string
}

View File

@ -1,3 +1,5 @@
import { IChartDataset } from '@/types/chart'
export interface IStatisticsParams { export interface IStatisticsParams {
from: string from: string
to: string to: string
@ -30,14 +32,8 @@ export type TStatisticsFromApi = {
[key in string]: TSportStatistics [key in string]: TSportStatistics
} }
export interface IStatisticsChartDataset {
label: string
backgroundColor: string[]
data: number[]
}
export type TStatisticsDatasets = { export type TStatisticsDatasets = {
[key in TDatasetKeys]: IStatisticsChartDataset[] [key in TDatasetKeys]: IChartDataset[]
} }
export interface IStatisticsChartData { export interface IStatisticsChartData {

View File

@ -1,10 +1,9 @@
import { format } from 'date-fns' import { format } from 'date-fns'
import { genericObject } from '@/types/generic' import { IChartDataset } from '@/types/chart'
import { ISport } from '@/types/sports' import { ISport } from '@/types/sports'
import { import {
IStatisticsChartData, IStatisticsChartData,
IStatisticsChartDataset,
IStatisticsDateParams, IStatisticsDateParams,
TDatasetKeys, TDatasetKeys,
TStatisticsDatasets, TStatisticsDatasets,
@ -14,7 +13,7 @@ import { incrementDate, startDate } from '@/utils/dates'
import { sportColors } from '@/utils/sports' import { sportColors } from '@/utils/sports'
// date format from api // date format from api
const dateFormats: genericObject = { const dateFormats: Record<string, string> = {
week: 'yyyy-MM-dd', week: 'yyyy-MM-dd',
month: 'yyyy-MM', month: 'yyyy-MM',
year: 'yyyy', year: 'yyyy',
@ -44,7 +43,7 @@ export const getDateKeys = (
const getStatisticsChartDataset = ( const getStatisticsChartDataset = (
sportLabel: string, sportLabel: string,
color: string color: string
): IStatisticsChartDataset => { ): IChartDataset => {
return { return {
label: sportLabel, label: sportLabel,
backgroundColor: [color], backgroundColor: [color],

View File

@ -23,7 +23,7 @@
import UserCalendar from '@/components/Dashboard/UserCalendar/index.vue' import UserCalendar from '@/components/Dashboard/UserCalendar/index.vue'
import UserMonthStats from '@/components/Dashboard/UserMonthStats.vue' import UserMonthStats from '@/components/Dashboard/UserMonthStats.vue'
import UserRecords from '@/components/Dashboard/UserRecords/index.vue' import UserRecords from '@/components/Dashboard/UserRecords/index.vue'
import UserStatsCards from '@/components/Dashboard/UserStartsCards/index.vue' import UserStatsCards from '@/components/Dashboard/UserStatsCards/index.vue'
import { USER_STORE } from '@/store/constants' import { USER_STORE } from '@/store/constants'
import { IAuthUserProfile } from '@/types/user' import { IAuthUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore' import { useStore } from '@/use/useStore'

View File

@ -1,6 +1,6 @@
import { assert, expect } from 'chai' import { assert, expect } from 'chai'
import { sports } from './constants' import { sports } from './fixtures'
import { formatRecord, getRecordsBySports } from '@/utils/records' import { formatRecord, getRecordsBySports } from '@/utils/records'

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import { sports } from './constants' import { sports } from './fixtures'
import createI18n from '@/i18n' import createI18n from '@/i18n'
import { translateSports } from '@/utils/sports' import { translateSports } from '@/utils/sports'

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import { sports } from './constants' import { sports } from './fixtures'
import { import {
IStatisticsChartData, IStatisticsChartData,