Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { FC } from 'react'
import { useTranslate } from '@/shared/lib'
import { useRouter } from 'next/router'
import { BackButton } from '@tmk/ui-kit'
import { getFiltersQueryLink } from '@/shared/helpers'
export const AccountingObjectPassportHeader: FC = () => {
const { t } = useTranslate(['accounting-object'])
const router = useRouter()
const isChangeLogPage = router.pathname.includes('change-log')
const isEditPage = router.pathname.includes('edit')
const fromPath = router.query.from
const isFromWarehouse = router.query.fromWarehouse
const getTitleHeaderPage = () => {
if (isEditPage) return t('Edit passport')
if (isChangeLogPage) return t('Changelog')
return t('Object passport')
}
const getBackButtonPathWithFilters = () => {
if (isChangeLogPage) {
const link = `/accounting-objects/pipes/${router.query.pid}`
const query = JSON.parse(JSON.stringify(router.query))
if (query.from) {
delete query.from
}
return getFiltersQueryLink(link, query)
}
if (isFromWarehouse) {
return `/warehouses/${router.query.fromWarehouse}`
}
if (typeof fromPath === 'string' && fromPath.includes('warehouses')) {
return fromPath
}
const link = '/accounting-objects'
const query = JSON.parse(JSON.stringify(router.query))
if (query.pid) {
delete query.pid
}
if (query.from) {
delete query.from
}
if (Object.keys(query).length) {
return `${link}?${Object.keys(query)
.map(key => `${key}=${query[key]}`)
.join('&')}`
}
return link
}
return (
<div className='flex items-center gap-x-2.5'>
<BackButton defaultPath={getBackButtonPathWithFilters()} />
<h1>{getTitleHeaderPage()}</h1>
</div>
)
}
|