2026-09-24 20:48:09 -03:00
|
|
|
import { useUpliftsCanApprove } from "@/domain/uplifts/use-cases/use-uplifts-can-approve";
|
|
|
|
|
import { getNavGroups, type NavGroup } from "@/config/menu";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sidebar groups for the signed-in user. The APPROVALS group appears only
|
|
|
|
|
* when the backend's can-approve answer (UpliftService tier-role rule, the
|
|
|
|
|
* same authority behind uplift approve/reject) is true for either tier.
|
|
|
|
|
* Loading and error states stay closed so the entry never flashes for a
|
2026-09-24 20:53:05 -03:00
|
|
|
* user the backend would refuse, including when a refetch fails and the
|
|
|
|
|
* query still holds an earlier `true`.
|
2026-09-24 20:48:09 -03:00
|
|
|
*/
|
|
|
|
|
export function useNavGroups(): NavGroup[] {
|
|
|
|
|
const tier1 = useUpliftsCanApprove(1);
|
|
|
|
|
const tier2 = useUpliftsCanApprove(2);
|
2026-09-24 20:53:05 -03:00
|
|
|
const allows = (query: { data?: boolean; isError?: boolean }) =>
|
|
|
|
|
query.data === true && !query.isError;
|
|
|
|
|
const canReviewUplifts = allows(tier1) || allows(tier2);
|
2026-09-24 20:48:09 -03:00
|
|
|
|
|
|
|
|
return getNavGroups({ canReviewUplifts });
|
|
|
|
|
}
|