Skip to content

Commit

Permalink
Merge branch '1-featurebranch'
Browse files Browse the repository at this point in the history
Исправления для #3, #4 и #5
  • Loading branch information
reyzitwo committed Jun 20, 2023
2 parents 0aba405 + c3a6bce commit df527f0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/ModalRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ModalRoot: FC<ModalRootProps> = (props) => {
activeModal={activeModal}
onClose={() => {
toModal(-1);
props.onClose();
props.onClose && props.onClose();
}}
{...props}
>
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
RouterViewI,
RouterPopoutI,
RouterModalI,
RouterHooksI,
} from "./interfaces";

export const useRouterView = (): RouterViewI => {
Expand Down Expand Up @@ -90,3 +91,13 @@ export const useRouterModal = (): RouterModalI => {

return <RouterModalI>{ activeModal, toModal };
};

export const useRouterHooks = (): RouterHooksI => {
const { toView } = useRouterView();
const { toPanel } = useRouterPanel();
const { toPopout } = useRouterPopout();
const { toModal } = useRouterModal();
const toBack = useRouterBack();

return { toView, toPanel, toPopout, toModal, toBack };
};
8 changes: 8 additions & 0 deletions src/hooks/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ export interface RouterModalI {
value: string | number;
};
}

export interface RouterHooksI {
toView: RouterViewI["toView"];
toPanel: RouterPanelI["toPanel"];
toPopout: RouterPopoutI["toPopout"];
toModal: RouterModalI["toModal"];
toBack: (step: number | string) => RouterBackI;
}
6 changes: 3 additions & 3 deletions src/storage/selectors/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export const useView = selector<string | number>({
}

if (view === "@kokateam/router_event_back") {
activeView = viewsHistory.slice(-1)[0];
history = HistoryBackViews(old.back_step, history); // функция удаляет N View вместе с их Panel's

const viewsDeleting = viewsHistory.splice(old.back_step);
// история таких панелей возвращается в изначальное состояние
viewsDeleting.map(
(key) => (viewsPanels[key] = structureRouter.panels[key].slice(0, 1))
);

activeView = viewsHistory.slice(-1)[0];
history = HistoryBackViews(old.back_step, history); // функция удаляет N View вместе с их Panel's
} else {
if (!structureRouter.views.includes(view as string)) {
return console.error(
Expand Down

0 comments on commit df527f0

Please sign in to comment.