diff --git a/ui/dev-dist/sw.js b/ui/dev-dist/sw.js index f478dbd1..3f9636fb 100644 --- a/ui/dev-dist/sw.js +++ b/ui/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "/index.html", - "revision": "0.l905521idmg" + "revision": "0.kufulh89m3" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html"), { diff --git a/ui/src/utils/hooks/useCurrentMenuIcon.tsx b/ui/src/utils/hooks/useCurrentMenuIcon.tsx new file mode 100644 index 00000000..b7d191a3 --- /dev/null +++ b/ui/src/utils/hooks/useCurrentMenuIcon.tsx @@ -0,0 +1,24 @@ +import { useStoreState } from '@/store/store' +import { useLocation } from 'react-router-dom' +import { FaUser } from 'react-icons/fa' +import navigationIcon from '@/configs/navigation-icon.config' +import { navigationTreeToFlat } from '@/utils/navigation' + +export function useCurrentMenuIcon(className = 'w-6 h-6'): JSX.Element { + const mainMenu = useStoreState((state) => state.abpConfig.menu.mainMenu) + const location = useLocation() + const menus = navigationTreeToFlat(mainMenu) + + const currentMenu = menus.find((menu) => { + if (!menu.path) return false + + // normalize: /list/ -> /form/ + const formPath = menu.path.replace('/list/', '/form/') + + return location.pathname.startsWith(menu.path) || location.pathname.startsWith(formPath) + }) + + const IconComponent = currentMenu?.icon ? navigationIcon[currentMenu.icon] || FaUser : FaUser + + return +} diff --git a/ui/src/views/form/FormEdit.tsx b/ui/src/views/form/FormEdit.tsx index c9690137..b883cbdb 100644 --- a/ui/src/views/form/FormEdit.tsx +++ b/ui/src/views/form/FormEdit.tsx @@ -7,6 +7,8 @@ import FormDevExpress from './FormDevExpress' import SubForms from './SubForms' import { FormProps } from './types' import { useGridData } from './useGridData' +import { useCurrentMenuIcon } from '@/utils/hooks/useCurrentMenuIcon' +import { Badge } from '@/components/ui' const FormEdit = ( props: FormProps = { @@ -20,8 +22,8 @@ const FormEdit = ( const params = useParams() const listFormCode = props?.listFormCode ?? params?.listFormCode ?? '' const id = props?.id ?? params?.id ?? '' + const MenuIcon = useCurrentMenuIcon('w-5 h-5') - // const refListFormCode = useRef('') //Şimdilik kalsın const { translate } = useLocalization() const { fetchData, @@ -66,10 +68,21 @@ const FormEdit = ( defaultTitle="Sözsoft Kurs Platform" > )} +
- {!isSubForm &&

{translate('::' + gridDto?.gridOptions.title)}

} +
+ {MenuIcon} + {!isSubForm && ( + <> +

+ {translate('::' + gridDto?.gridOptions?.title)} +

+ + + )} +
{permissionResults && ( - {!isSubForm &&

{translate('::' + gridDto?.gridOptions.title)}

} +
+ {MenuIcon} + {!isSubForm && ( + <> +

+ {translate('::' + gridDto?.gridOptions?.title)} +

+ + + )} +
{permissionResults && ( - {!isSubForm &&

{translate('::' + gridDto?.gridOptions.title)}

} +
+ {MenuIcon} + {!isSubForm && ( + <> +

+ {translate('::' + gridDto?.gridOptions?.title)} +

+ + + )} +
{permissionResults && ( { const params = useParams() @@ -23,8 +22,7 @@ const List = () => { const [viewMode, setViewMode] = useState<'grid' | 'card' | 'pivot'>() const mode = useStoreState((state) => state.theme.mode) const [gridDto, setGridDto] = useState() - const mainMenu = useStoreState((state) => state.abpConfig.menu.mainMenu) - const location = useLocation() + const MenuIcon = useCurrentMenuIcon('w-5 h-5') const initializeGridAsync = async () => { const response = await getList({ listFormCode }) @@ -47,17 +45,6 @@ const List = () => { return null } - const getCurrentMenuIcon = (className = 'w-6 h-6'): JSX.Element => { - const menus = navigationTreeToFlat(mainMenu) - const currentMenu = menus.find((menu) => menu.path === location.pathname) - - if (currentMenu?.icon) { - const IconComponent = navigationIcon[currentMenu.icon] || FaUser - return - } - return - } - return ( {!gridDto ? ( @@ -71,7 +58,7 @@ const List = () => { })} >
- {getCurrentMenuIcon('w-5 h-5')} {/* ikon biraz küçüldü */} + {MenuIcon}

{translate('::' + gridDto?.gridOptions?.title)}