Skip to content

Commit

Permalink
Extract ttl selector items getter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstotsky committed Apr 23, 2024
1 parent 8de37df commit 9a6e60b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/ui/TokenTTLSelector/TokenTTLSelector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react'
import React, { useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'

Expand All @@ -7,19 +7,21 @@ import { getAuthTokenTTL } from 'state/auth/selectors'

import Select from 'ui/Select'

const getItems = (t) => [
{ value: 86400, label: t('auth.ttlSelect.1day') },
{ value: 172800, label: t('auth.ttlSelect.2days') },
{ value: 259200, label: t('auth.ttlSelect.3days') },
{ value: 345600, label: t('auth.ttlSelect.4days') },
{ value: 432000, label: t('auth.ttlSelect.5days') },
{ value: 518400, label: t('auth.ttlSelect.6days') },
{ value: 604800, label: t('auth.ttlSelect.7days') },
]

const ExportTypeSelector = () => {
const { t } = useTranslation()
const dispatch = useDispatch()
const authTokenTTL = useSelector(getAuthTokenTTL)
const items = [
{ value: 86400, label: t('auth.ttlSelect.1day') },
{ value: 172800, label: t('auth.ttlSelect.2days') },
{ value: 259200, label: t('auth.ttlSelect.3days') },
{ value: 345600, label: t('auth.ttlSelect.4days') },
{ value: 432000, label: t('auth.ttlSelect.5days') },
{ value: 518400, label: t('auth.ttlSelect.6days') },
{ value: 604800, label: t('auth.ttlSelect.7days') },
]
const items = useMemo(() => getItems(t), [t])

const handleChange = useCallback((value) => {
dispatch(setAuthTokenTTL(value))
Expand Down

0 comments on commit 9a6e60b

Please sign in to comment.