4a099ed097
https://github.com/user-attachments/assets/a31b8523-2d0a-4a02-bcd9-5548c906b7cc --------- Co-authored-by: Charles Bochet <charles@twenty.com>
23 lines
874 B
TypeScript
23 lines
874 B
TypeScript
import { isNonEmptyString } from '@sniptt/guards';
|
|
|
|
import { sidePanelPageInfoState } from '@/side-panel/states/sidePanelPageInfoState';
|
|
import { sidePanelSubPageStackComponentState } from '@/side-panel/states/sidePanelSubPageStackComponentState';
|
|
import { type SidePanelSubPageEntry } from '@/side-panel/types/SidePanelSubPageEntry';
|
|
import { createAtomSelector } from '@/ui/utilities/state/jotai/utils/createAtomSelector';
|
|
|
|
export const sidePanelSubPageStackForActiveSidePanelPageSelector =
|
|
createAtomSelector<SidePanelSubPageEntry[]>({
|
|
key: 'sidePanelSubPageStackForActiveSidePanelPage',
|
|
get: ({ get }) => {
|
|
const pageInfo = get(sidePanelPageInfoState);
|
|
|
|
if (!isNonEmptyString(pageInfo.instanceId)) {
|
|
return [];
|
|
}
|
|
|
|
return get(sidePanelSubPageStackComponentState, {
|
|
instanceId: pageInfo.instanceId,
|
|
});
|
|
},
|
|
});
|