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 | 1x 1x 14x 14x 14x 14x 9343x 9351x 9351x 9351x 14x 9357x 14x 1x 1x 6x 6x 6x 2827x 6x | import { type TeamContract, type TeamTreeNode } from '@amalia/tenants/teams/types';
function getTeamAncestorsRecursive<
TTeam extends Pick<TeamContract, 'id' | 'parentTeamId'>,
TTeamTreeNode extends TeamTreeNode<TTeam>,
>(teamNode: TTeamTreeNode, acc: TTeam[] = []): TTeam[] {
if (teamNode.parent) {
acc.push(teamNode.parent.team);
getTeamAncestorsRecursive(teamNode.parent, acc);
}
return acc;
}
export function getTeamAncestors<
TTeam extends Pick<TeamContract, 'id' | 'parentTeamId'>,
TTeamTreeNode extends TeamTreeNode<TTeam> = TeamTreeNode<TTeam>,
>(teamNode: TTeamTreeNode): TTeam[] {
return getTeamAncestorsRecursive(teamNode);
}
|