Skip to content

Commit

Permalink
Add jsdoc to LangHelper.ts and customHooks.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Sep 24, 2023
1 parent b16c93f commit a393ade
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/src/common/LangHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { LocalizedStrings } from 'react-localization'
import Env from '../config/env.config'
import * as UserService from '../services/UserService'

/**
* Get current language.
*
* @returns {string}
*/
export const getLanguage = () => {
let language = UserService.getQueryLanguage() ?? ''

Expand All @@ -12,6 +17,12 @@ export const getLanguage = () => {
return language
}

/**
* Set LocalizedStrings language.
*
* @param {LocalizedStrings<any>} strings
* @param {?string} [language]
*/
export const setLanguage = (strings: LocalizedStrings<any>, language?: string) => {
const lang = language || getLanguage()
strings.setLanguage(lang)
Expand Down
7 changes: 7 additions & 0 deletions backend/src/common/customHooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { useState, useEffect } from 'react'

/**
* Custom initialization hook.
*
* @param {*} callback
* @param {...*} args
* @returns {{}}
*/
export const useInit = (callback: any, ...args: any) => {
const [mounted, setMounted] = useState(false)

Expand Down
11 changes: 11 additions & 0 deletions frontend/src/common/LangHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { LocalizedStrings } from 'react-localization'
import Env from '../config/env.config'
import * as UserService from '../services/UserService'

/**
* Get current language.
*
* @returns {string}
*/
export const getLanguage = () => {
let language = UserService.getQueryLanguage() ?? ''

Expand All @@ -12,6 +17,12 @@ export const getLanguage = () => {
return language
}

/**
* Set LocalizedStrings language.
*
* @param {LocalizedStrings<any>} strings
* @param {?string} [language]
*/
export const setLanguage = (strings: LocalizedStrings<any>, language?: string) => {
const lang = language || getLanguage()
strings.setLanguage(lang)
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/common/customHooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { useState, useEffect } from 'react'

/**
* Custom initialization hook.
*
* @param {*} callback
* @param {...*} args
* @returns {{}}
*/
export const useInit = (callback: any, ...args: any) => {
const [mounted, setMounted] = useState(false)

Expand Down

0 comments on commit a393ade

Please sign in to comment.