Skip to content

Instantly share code, notes, and snippets.

@Bogdan808
Created February 16, 2024 12:28
Show Gist options
  • Save Bogdan808/bbdb1016c42f356a1eecb5879d040bcc to your computer and use it in GitHub Desktop.
Save Bogdan808/bbdb1016c42f356a1eecb5879d040bcc to your computer and use it in GitHub Desktop.
import type { ReactNode } from "react";
import { useEffect } from "react";
import { SalesHistoryLoaderNotReady } from "./components/SalesHistoryLoaderNotReady";
import { SalesHistoryLoaderProvider, useSalesHistoryLoaderFeature } from "./store/store";
export const SalesHistoryLoader = ({ children }: { children: ReactNode }) => {
return (
<SalesHistoryLoaderProvider
value={{
marketplace: "",
sellerId: "",
}}
>
<SalesHistorySwitcher>{children}</SalesHistorySwitcher>
</SalesHistoryLoaderProvider>
);
};
export const SalesHistorySwitcher = ({ children }: { children: ReactNode }) => {
const { useStore } = useSalesHistoryLoaderFeature();
const isReady = useStore((s) => s.isDataReady);
return isReady ? <>{children}</> : <SalesHistoryLoaderNotReady />;
};
// export const SalesHistoryLoader = ({ children }: { children: ReactNode }) => {
// return <SalesHistorySwitcher>{children}</SalesHistorySwitcher>;
// };
//
// export const SalesHistorySwitcher = ({ children }: { children: ReactNode }) => {
// const isReady = useSalesHistoryLoaderStore((s) => s.isDataReady);
//
// useEffect(() => {
// useRequest.action();
// }, []);
//
// return isReady ? <>{children}</> : <SalesHistoryLoaderNotReady />;
// };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment