fix: data loading after login fixed

This commit is contained in:
2025-07-04 21:12:01 +04:00
parent c3d135eba9
commit c866231730
6 changed files with 35 additions and 27 deletions

View File

@@ -1,19 +1,27 @@
import { useParams } from "@tanstack/react-router";
import { CardPageContextProvider, useCardPageContext } from "../../CardsPage/contexts/CardPageContext.tsx";
import ProductAndServiceTab from "../../../modules/cardModules/cardEditorTabs/ProductAndServiceTab/ProductAndServiceTab.tsx";
import ProductAndServiceTab
from "../../../modules/cardModules/cardEditorTabs/ProductAndServiceTab/ProductAndServiceTab.tsx";
import React, { FC, useEffect } from "react";
import { CardService } from "../../../client";
import { useSelector } from "react-redux";
import { RootState } from "../../../redux/store.ts";
export type Props = {
cardId: number;
};
const CardPageContent: FC<Props> = ({ cardId }) => {
const { setSelectedCard } = useCardPageContext();
const authState = useSelector((state: RootState) => state.auth);
useEffect(() => {
CardService.getCardById({ cardId }).then(card => {
setSelectedCard(card);
});
}, []);
if (authState.isAuthorized) {
CardService.getCardById({ cardId }).then(card => {
setSelectedCard(card);
});
}
}, [authState.isAuthorized]);
return <ProductAndServiceTab />;
};