Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: export cta related stuff #794

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
import {
QueryClient,
QueryClientProvider,
QueryClientProviderProps
} from "react-query";

import React from "react";

const queryClient = new QueryClient({
defaultOptions: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove duplicated code

queries: {
refetchOnWindowFocus: false
}
}
});

type QueryClientProviderCustomProps = Partial<QueryClientProviderProps>;

export const QueryClientProviderCustom: React.FC<
QueryClientProviderCustomProps
> = ({ ...props }) => {
return (
<QueryClientProvider client={queryClient} {...props}>
{props.children}
</QueryClientProvider>
);
};
import { QueryClientProviderCustom } from "./QueryClientProviderCustom";

export const withQueryClientProvider = <P extends object>(
WrappedComponent: React.ComponentType<P>
Expand Down
3 changes: 3 additions & 0 deletions packages/react-kit/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ export * from "./ipfs/useIpfsStorage";
export * from "./location/buildUseSearchParams";
export * from "./form/useForm";
export * from "./useBreakpoints";
export * from "./useSignerAddress";
export * from "./useMetaTx";
export { useCtaClickHandler } from "./useCtaClickHandler";
5 changes: 4 additions & 1 deletion packages/react-kit/src/hooks/useCtaClickHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export function useCtaClickHandler<T>({
successPayload
}: {
waitBlocks: number;
coreSdk: CoreSDK;
coreSdk: Pick<
CoreSDK,
"relayNativeMetaTransaction" | "relayMetaTransaction" | "parseError"
>;
useMetaTx: boolean;
actions: Action[];
successPayload: T | ((receipt: providers.TransactionReceipt) => T);
Expand Down
4 changes: 3 additions & 1 deletion packages/react-kit/src/hooks/useMetaTx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { CoreSDK } from "@bosonprotocol/core-sdk";
import { useSignerAddress } from "./useSignerAddress";

export function useMetaTx(coreSdk: CoreSDK | undefined) {
export function useMetaTx(
coreSdk: Pick<CoreSDK, "isMetaTxConfigSet" | "web3Lib"> | undefined
) {
const { signerAddress, signerContract } = useSignerAddress(coreSdk?.web3Lib);
const isMetaTx = coreSdk
? Boolean(coreSdk.isMetaTxConfigSet && signerAddress && !signerContract)
Expand Down
3 changes: 3 additions & 0 deletions packages/react-kit/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./components/buttons/BurgerButton";
export * from "./components/buttons/Button";
export * from "./components/buttons/CommitButtonView";
export * from "./components/config/ConfigProvider";
export * from "./components/cta/common/types";
export * from "./components/cta/dispute/DecideDisputeButton";
export * from "./components/cta/dispute/EscalateDisputeButton";
export * from "./components/cta/dispute/ExpireDisputeButton";
Expand Down Expand Up @@ -45,6 +46,8 @@ export * from "./components/modal/components/Redeem/DetailView/ExternalExchangeD
export * from "./components/portal/Portal";
export * from "./components/productCard/const";
export * from "./components/productCard/ProductCard";
export * from "./components/queryClient/withQueryClientProvider";
export * from "./components/queryClient/QueryClientProviderCustom";
export * from "./components/scroll/ScrollToID";
export * from "./components/scroll/ScrollToTop";
export * from "./components/searchBar/SearchBar";
Expand Down
4 changes: 1 addition & 3 deletions packages/react-kit/src/stories/buttons/Upload.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { fn } from "@storybook/test";
import React from "react";
import { Meta } from "@storybook/react";
import { Upload } from "../..";
import { QueryClientProviderCustom, Upload } from "../..";
import { EnvironmentProvider } from "../../components/environment/EnvironmentProvider";
import { IpfsProvider } from "../../components/ipfs/IpfsProvider";
import { Formik } from "formik";
import { QueryClientProviderCustom } from "../../components/queryClient/withQueryClientProvider";
import {
bosonButtonThemeKeys,
bosonButtonThemes
Expand Down
Loading