Client - minor refactor
This commit is contained in:
		@@ -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: {
 | 
			
		||||
 
 | 
			
		||||
@@ -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({
 | 
			
		||||
							
								
								
									
										5
									
								
								fittrackee_client/src/types/chart.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								fittrackee_client/src/types/chart.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
export interface IChartDataset {
 | 
			
		||||
  label: string
 | 
			
		||||
  backgroundColor: string[]
 | 
			
		||||
  data: number[]
 | 
			
		||||
}
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
export type genericObject = {
 | 
			
		||||
  [key: string]: string
 | 
			
		||||
}
 | 
			
		||||
@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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],
 | 
			
		||||
 
 | 
			
		||||
@@ -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'
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import { assert, expect } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { sports } from './constants'
 | 
			
		||||
import { sports } from './fixtures'
 | 
			
		||||
 | 
			
		||||
import { formatRecord, getRecordsBySports } from '@/utils/records'
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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'
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { sports } from './constants'
 | 
			
		||||
import { sports } from './fixtures'
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  IStatisticsChartData,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user