Intranet Dashboard
This commit is contained in:
parent
abd72064f1
commit
61b9868126
1 changed files with 16 additions and 1 deletions
|
|
@ -43,6 +43,7 @@ import ShuttleRoute from './widgets/ShuttleRoute'
|
||||||
import { useLocalization } from '@/utils/hooks/useLocalization'
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
||||||
import useLocale from '@/utils/hooks/useLocale'
|
import useLocale from '@/utils/hooks/useLocale'
|
||||||
import { currentLocalDate } from '@/utils/dateUtils'
|
import { currentLocalDate } from '@/utils/dateUtils'
|
||||||
|
import { useStoreState } from '@/store/store'
|
||||||
|
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
dayjs.extend(isBetween)
|
dayjs.extend(isBetween)
|
||||||
|
|
@ -72,8 +73,10 @@ const IntranetDashboard: React.FC = () => {
|
||||||
|
|
||||||
const fetchIntranetDashboard = async () => {
|
const fetchIntranetDashboard = async () => {
|
||||||
const dashboard = await intranetService.getDashboard()
|
const dashboard = await intranetService.getDashboard()
|
||||||
|
if (dashboard.data) {
|
||||||
setIntranetDashboard(dashboard.data)
|
setIntranetDashboard(dashboard.data)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchIntranetDashboard()
|
fetchIntranetDashboard()
|
||||||
|
|
@ -161,6 +164,18 @@ const IntranetDashboard: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
// If permissions arrive after mount, initialize default order when needed
|
||||||
|
const grantedPolicies = useStoreState((state) => state.abpConfig?.config?.auth.grantedPolicies)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
grantedPolicies &&
|
||||||
|
(!widgetOrder.left.length && !widgetOrder.center.length && !widgetOrder.right.length)
|
||||||
|
) {
|
||||||
|
initializeDefaultOrder()
|
||||||
|
}
|
||||||
|
}, [grantedPolicies])
|
||||||
|
|
||||||
const initializeDefaultOrder = () => {
|
const initializeDefaultOrder = () => {
|
||||||
const defaultOrder = {
|
const defaultOrder = {
|
||||||
left: widgetMetadata
|
left: widgetMetadata
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue