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 { 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'
Chart.register(...registerables)
@ -30,7 +31,7 @@
},
props: {
datasets: {
type: Object as PropType<IStatisticsChartDataset[]>,
type: Object as PropType<IChartDataset[]>,
required: true,
},
labels: {

View File

@ -27,7 +27,7 @@
import { ComputedRef, PropType, defineComponent, computed } from 'vue'
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'
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 {
from: string
to: string
@ -30,14 +32,8 @@ export type TStatisticsFromApi = {
[key in string]: TSportStatistics
}
export interface IStatisticsChartDataset {
label: string
backgroundColor: string[]
data: number[]
}
export type TStatisticsDatasets = {
[key in TDatasetKeys]: IStatisticsChartDataset[]
[key in TDatasetKeys]: IChartDataset[]
}
export interface IStatisticsChartData {

View File

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

View File

@ -23,7 +23,7 @@
import UserCalendar from '@/components/Dashboard/UserCalendar/index.vue'
import UserMonthStats from '@/components/Dashboard/UserMonthStats.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 { IAuthUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'

View File

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

View File

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

View File

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