fix: data loading after login fixed
This commit is contained in:
@@ -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 />;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user