Merge branch 'dev' into alternate_weather_api
This commit is contained in:
@ -97,7 +97,9 @@ const dateStringFormats: Record<string, string> = {
|
||||
de: 'do MMM yyyy',
|
||||
en: 'MMM. do, yyyy',
|
||||
fr: 'd MMM yyyy',
|
||||
it: 'd MMM yyyy',
|
||||
// nb: 'do MMM yyyy',
|
||||
nl: 'd MMM yyyy',
|
||||
}
|
||||
|
||||
export const getDateFormat = (dateFormat: string, language: string): string => {
|
||||
|
@ -9,6 +9,7 @@ import { ISportsState } from '@/store/modules/sports/types'
|
||||
import { IStatisticsState } from '@/store/modules/statistics/types'
|
||||
import { IUsersState } from '@/store/modules/users/types'
|
||||
import { IWorkoutsState } from '@/store/modules/workouts/types'
|
||||
import { IApiErrorMessage } from '@/types/api'
|
||||
|
||||
export const getApiUrl = (): string => {
|
||||
return process.env.NODE_ENV === 'production'
|
||||
@ -33,11 +34,11 @@ export const handleError = (
|
||||
return
|
||||
}
|
||||
|
||||
const errorInfo: IApiErrorMessage | null =
|
||||
error?.response && error.response.data ? error.response.data : null
|
||||
|
||||
// if stored token is blacklisted, disconnect user
|
||||
if (
|
||||
error?.response?.status === 401 &&
|
||||
error.response.data.error === 'invalid_token'
|
||||
) {
|
||||
if (error?.response?.status === 401 && errorInfo?.error === 'invalid_token') {
|
||||
localStorage.removeItem('authToken')
|
||||
context.dispatch(AUTH_USER_STORE.ACTIONS.CHECK_AUTH_USER)
|
||||
return
|
||||
@ -48,8 +49,8 @@ export const handleError = (
|
||||
: error.response
|
||||
? error.response.status === 413
|
||||
? 'file size is greater than the allowed size'
|
||||
: error.response.data.message
|
||||
? error.response.data.message
|
||||
: errorInfo?.message
|
||||
? errorInfo.message
|
||||
: msg
|
||||
: error.message
|
||||
? error.message
|
||||
|
9
fittrackee_client/src/utils/inputs.ts
Normal file
9
fittrackee_client/src/utils/inputs.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import linkifyHtml from 'linkify-html'
|
||||
import sanitizeHtml from 'sanitize-html'
|
||||
|
||||
export const linkifyAndClean = (input: string): string => {
|
||||
return sanitizeHtml(linkifyHtml(input, { target: '_blank' }), {
|
||||
allowedTags: ['a'],
|
||||
disallowedTagsMode: 'escape',
|
||||
})
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable import/no-duplicates */
|
||||
import { Locale } from 'date-fns'
|
||||
import { de, enUS, fr } from 'date-fns/locale'
|
||||
import { de, enUS, fr, it, nl } from 'date-fns/locale'
|
||||
|
||||
import createI18n from '@/i18n'
|
||||
|
||||
@ -8,14 +8,18 @@ export const localeFromLanguage: Record<string, Locale> = {
|
||||
de: de,
|
||||
en: enUS,
|
||||
fr: fr,
|
||||
it: it,
|
||||
// nb: nb, // disabled for now
|
||||
nl: nl,
|
||||
}
|
||||
|
||||
export const languageLabels: Record<string, string> = {
|
||||
de: 'Deutsch',
|
||||
en: 'English',
|
||||
fr: 'Français',
|
||||
it: 'Italiano',
|
||||
// nb: 'Norsk bokmål', // disabled for now
|
||||
nl: 'Nederlands',
|
||||
}
|
||||
|
||||
const { availableLocales } = createI18n.global
|
||||
|
@ -1,31 +1,38 @@
|
||||
import { zxcvbnOptions } from '@zxcvbn-ts/core'
|
||||
|
||||
export const loadLanguagePackage = async (language: string) => {
|
||||
// no package available for norwegian bokmal and dutch (Nederlands)
|
||||
// fallback to english
|
||||
switch (language) {
|
||||
case 'fr':
|
||||
return await import(
|
||||
/* webpackChunkName: "password.fr" */ '@zxcvbn-ts/language-fr'
|
||||
)
|
||||
case 'de':
|
||||
return await import(
|
||||
/* webpackChunkName: "password.de" */ '@zxcvbn-ts/language-de'
|
||||
)
|
||||
case 'it':
|
||||
return await import(
|
||||
/* webpackChunkName: "password.it" */ '@zxcvbn-ts/language-it'
|
||||
)
|
||||
default:
|
||||
return await import(
|
||||
/* webpackChunkName: "password.en" */ '@zxcvbn-ts/language-en'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const setZxcvbnOptions = async (language: string) => {
|
||||
const zxcvbnCommonPackage = await import(
|
||||
/* webpackChunkName: "password" */ '@zxcvbn-ts/language-common'
|
||||
)
|
||||
const zxcvbnEnPackage = await import(
|
||||
/* webpackChunkName: "password" */ '@zxcvbn-ts/language-en'
|
||||
)
|
||||
const zxcvbnFrPackage = await import(
|
||||
/* webpackChunkName: "password" */ '@zxcvbn-ts/language-fr'
|
||||
)
|
||||
const zxcvbnDePackage = await import(
|
||||
/* webpackChunkName: "password" */ '@zxcvbn-ts/language-de'
|
||||
)
|
||||
const zxcvbnLangPackages: Record<string, typeof zxcvbnEnPackage> = {
|
||||
de: zxcvbnDePackage,
|
||||
en: zxcvbnEnPackage,
|
||||
fr: zxcvbnFrPackage,
|
||||
// no package available for norwegian bokmal, fallback on english
|
||||
nb: zxcvbnEnPackage,
|
||||
}
|
||||
const zxcvbnPackage = zxcvbnLangPackages[language]
|
||||
const zxcvbnLanguagePackage = await loadLanguagePackage(language)
|
||||
const options = {
|
||||
graphs: zxcvbnCommonPackage.default.adjacencyGraphs,
|
||||
dictionary: {
|
||||
...zxcvbnCommonPackage.default.dictionary,
|
||||
...zxcvbnPackage.default.dictionary,
|
||||
...zxcvbnLanguagePackage.default.dictionary,
|
||||
},
|
||||
}
|
||||
zxcvbnOptions.setOptions(options)
|
||||
|
@ -8,6 +8,7 @@ export const sportColors: Record<string, string> = {
|
||||
Hiking: '#bb757c',
|
||||
'Mountain Biking': '#d4b371',
|
||||
'Mountain Biking (Electric)': '#fc9d6f',
|
||||
Mountaineering: '#48b3b7',
|
||||
Rowing: '#fcce72',
|
||||
Running: '#835b83',
|
||||
'Skiing (Alpine)': '#67a4bd',
|
||||
|
Reference in New Issue
Block a user