Skip to content

Commit

Permalink
Mock collections
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Jan 23, 2025
1 parent 09b051a commit ffbee54
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 31 deletions.
1 change: 1 addition & 0 deletions packages/profile/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const config: StorybookConfig = {
resolve: {
alias: {
"@/hooks/account": require.resolve("../src/hooks/account.mock.ts"),
"@/hooks/collection": require.resolve("../src/hooks/collection.mock.ts"),
"@/hooks/token": require.resolve("../src/hooks/token.mock.ts"),
"@cartridge/utils/api/cartridge": require.resolve("../node_modules/@cartridge/utils/dist/api/cartridge/index.js"),
"@cartridge/utils/api/indexer": require.resolve("../node_modules/@cartridge/utils/dist/api/indexer/index.js"),
Expand Down
13 changes: 9 additions & 4 deletions packages/profile/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SonnerToaster } from "@cartridge/ui-next";
import { Provider } from "../src/components/provider";

import "../src/index.css";
import { MemoryRouter, Route, Routes } from "react-router-dom";

const preview: Preview = {
parameters: {
Expand Down Expand Up @@ -41,10 +42,14 @@ const preview: Preview = {
(Story,
// { parameters }
) => (
<Provider>
<Story />
<SonnerToaster />
</Provider>
<MemoryRouter initialEntries={["/project-1"]}>
<Provider>
<Routes>
<Route path="/:project" element={<Story />} />
</Routes>
<SonnerToaster />
</Provider>
</MemoryRouter>
),
],
};
Expand Down
33 changes: 15 additions & 18 deletions packages/profile/src/components/provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { QueryClient, QueryClientProvider } from "react-query";
import { ArcadeProvider } from "./arcade";
import { ThemeProvider } from "./theme";
import { ConnectionProvider } from "./connection";
import { BrowserRouter } from "react-router-dom";
import { CartridgeAPIProvider } from "@cartridge/utils/api/cartridge";
import { IndexerAPIProvider } from "@cartridge/utils/api/indexer";
import { DataProvider } from "./data";
Expand All @@ -29,23 +28,21 @@ export function Provider({ children }: PropsWithChildren) {

return (
<PostHogProvider client={posthog}>
<BrowserRouter>
<CartridgeAPIProvider
url={`${import.meta.env.VITE_CARTRIDGE_API_URL!}/query`}
>
<IndexerAPIProvider credentials="omit">
<QueryClientProvider client={queryClient}>
<ArcadeProvider>
<ConnectionProvider>
<ThemeProvider defaultScheme="system">
<DataProvider>{children}</DataProvider>
</ThemeProvider>
</ConnectionProvider>
</ArcadeProvider>
</QueryClientProvider>
</IndexerAPIProvider>
</CartridgeAPIProvider>
</BrowserRouter>
<CartridgeAPIProvider
url={`${import.meta.env.VITE_CARTRIDGE_API_URL!}/query`}
>
<IndexerAPIProvider credentials="omit">
<QueryClientProvider client={queryClient}>
<ArcadeProvider>
<ConnectionProvider>
<ThemeProvider defaultScheme="system">
<DataProvider>{children}</DataProvider>
</ThemeProvider>
</ConnectionProvider>
</ArcadeProvider>
</QueryClientProvider>
</IndexerAPIProvider>
</CartridgeAPIProvider>
</PostHogProvider>
);
}
25 changes: 25 additions & 0 deletions packages/profile/src/hooks/collection.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function useCollections() {
return {
collections: Object.values(collections),
status: "success",
};
}

export function useCollection() {
return {
collection: collections.collection1,
status: "success",
};
}

const collections = {
collection1: {
address:
"0x00539f522b29ae9251dbf7443c7a950cf260372e69efab3710a11bf17a9599f1",
name: "Blobert",
type: "ERC-721",
imageUrl:
"https://media.arkproject.dev/contracts/0x00539f522b29ae9251dbf7443c7a950cf260372e69efab3710a11bf17a9599f1/avatar.jpg",
totalCount: 100,
},
};
2 changes: 1 addition & 1 deletion packages/profile/src/hooks/token.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { tokens } from "@cartridge/utils/mock/data";

export function useTokens() {
return {
data: [tokens.ETH, tokens.STARK],
data: Object.values(tokens),
isFetching: false,
isLoading: false,
};
Expand Down
9 changes: 6 additions & 3 deletions packages/profile/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { createRoot } from "react-dom/client";
import { SonnerToaster } from "@cartridge/ui-next";
import { App } from "@/components/app";
import { Provider } from "@/components/provider";
import { BrowserRouter } from "react-router-dom";

import "./index.css";

createRoot(document.getElementById("root")!).render(
<StrictMode>
<Provider>
<App />
</Provider>
<BrowserRouter>
<Provider>
<App />
</Provider>
</BrowserRouter>
<SonnerToaster position="bottom-right" />
</StrictMode>,
);
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ffbee54

Please sign in to comment.