Skip to content

Commit 37ccd37

Browse files
committed
update reducers + few changes
1 parent 84ee7ff commit 37ccd37

File tree

4 files changed

+81
-53
lines changed

4 files changed

+81
-53
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { FC } from "react";
2+
3+
import { OrbitControls } from "@react-three/drei";
4+
5+
import ModelSkate from "@/_3d/models/skate";
6+
import LoaderScene from "@/_3d/utils/loaderScene";
7+
import useTexture from "@/_3d/utils/loaderTexture";
8+
9+
export type props = {
10+
deckTexture: string;
11+
placeholderTexture: string;
12+
_id: number;
13+
};
14+
15+
const Scene: FC<props> = (props) => {
16+
const deckTexs = useTexture(props.deckTexture);
17+
const placeholderTexs = useTexture(props.placeholderTexture);
18+
19+
return (
20+
<>
21+
<ambientLight intensity={0.95} />
22+
<ModelSkate
23+
{...props}
24+
deckTexture={deckTexs}
25+
placeholderTexture={placeholderTexs}
26+
_id={props._id}
27+
/>
28+
<OrbitControls
29+
autoRotate={true}
30+
autoRotateSpeed={7.5}
31+
enableZoom={false}
32+
enableRotate={false}
33+
target={[0, 40, 0]}
34+
/>
35+
</>
36+
);
37+
};
38+
39+
const SceneLoader: FC<props> = (props) => {
40+
return (
41+
<LoaderScene camera={[0, 40, -60]}>
42+
<Scene {...props} />
43+
</LoaderScene>
44+
);
45+
};
46+
47+
export default SceneLoader;

packages/app/src/dapp/dapp.tsx

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import ModelSkate from "@/_3d/scenes/skate_0";
3232
import ClickAwayListener from "@mui/material/ClickAwayListener";
3333
import Clickable from "../_utils/components/stateless/clickable";
3434
import { useSelector } from "./store/hooks";
35+
import SceneLoader from "@/_3d/scenes/skate_1";
3536

3637
const pastilles = [
3738
{
@@ -52,39 +53,11 @@ const pastilles = [
5253
},
5354
];
5455

55-
const deckTextures = ["/models/skate/Tex/Deck_Sublimes.png"];
56-
const placeholderTextures = ["/models/skate/Tex/imgForMiddle.png"];
57-
export const My3DScene: FC = () => {
58-
return (
59-
<Canvas
60-
flat={true}
61-
linear={true}
62-
camera={{ position: [0, 40, -60] }}
63-
style={{ height: "100%", width: "100%" }}
64-
>
65-
{/* */}
66-
<ambientLight intensity={0.95} />
67-
<ModelSkate
68-
_id={0}
69-
deckTextures={deckTextures}
70-
deckIndex={0}
71-
placeholderTextures={placeholderTextures}
72-
placeholderIndex={0}
73-
/>
74-
<OrbitControls
75-
target={[0, 40, 0]}
76-
autoRotate={true}
77-
autoRotateSpeed={7.5}
78-
enableZoom={false}
79-
enableRotate={false}
80-
/>
81-
</Canvas>
82-
);
83-
};
84-
8556
const Drop: FC = () => {
8657
const state = useSelector((state) => state.appState);
8758

59+
const nfts = state.walletAssets.nfts;
60+
8861
const [currentItem, setItem] = React.useState(undefined as any);
8962
const [checked, setChecked] = React.useState(false);
9063

@@ -96,15 +69,17 @@ const Drop: FC = () => {
9669
}
9770
};
9871

72+
const deckTexture = "/models/skate/textures/sublime-deck.png";
73+
const placeholderTexture = "/models/skate/textures/imgForMiddle.png";
74+
9975
//
10076
return (
10177
<Fade duration={1500} triggerOnce>
10278
<Style.Root>
10379
<Style.Header></Style.Header>
10480
<Style.Part1>
105-
{/* 3D */}
106-
{/* <Suspense fallback={null}>{<My3DScene />}</Suspense> */}
107-
81+
<SceneLoader deckTexture={deckTexture} placeholderTexture={placeholderTexture} _id={1} />
82+
{/* <My3DScene /> */}
10883
<Style.LeftSide>
10984
<Style.HeaderLeftSide container spacing={0} alignItems="center">
11085
<Grid item xs={6}>
@@ -137,8 +112,8 @@ const Drop: FC = () => {
137112
<Style.BodyLeftSide>
138113
{/* */}
139114
<Style.InnerLeftSide>
140-
{state.nfts.length ? (
141-
state.nfts.map((list, index1) => (
115+
{nfts.length ? (
116+
nfts.map((list, index1) => (
142117
<div key={index1}>
143118
<Style.CollectionName>{list.collection}</Style.CollectionName>
144119
<ImageList cols={4} gap={4} style={{ marginBottom: "20px" }}>
@@ -173,8 +148,10 @@ const Drop: FC = () => {
173148
</ImageList>
174149
</div>
175150
))
176-
) : (
151+
) : state.signedIn ? (
177152
<Style.InnerLeftSideNoNfts>You do not own any NFTs :'(</Style.InnerLeftSideNoNfts>
153+
) : (
154+
<Style.InnerLeftSideNoNfts>You are not connected :'(</Style.InnerLeftSideNoNfts>
178155
)}
179156
</Style.InnerLeftSide>
180157
</Style.BodyLeftSide>

packages/app/src/dapp/navbar/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const NavbarComponent: FC = () => {
1717
const state = useSelector((state) => state.appState);
1818
const dispatch = useDispatch();
1919

20+
const drips = state.walletAssets.drips;
21+
2022
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);
2123
const handlePopoverOpen = (event: React.MouseEvent<HTMLElement>) => {
2224
setAnchorEl(event.currentTarget);
@@ -77,9 +79,9 @@ export const NavbarComponent: FC = () => {
7779
>
7880
<ClickAwayListener onClickAway={handlePopoverClose}>
7981
<Style.WalletView>
80-
{state.drips.length ? (
82+
{drips.length ? (
8183
<Grid container>
82-
{state.drips.map((drip, index) => (
84+
{drips.map((drip, index) => (
8385
<Grid item key={index}>
8486
<Grid container>
8587
<Grid item xs={2}>

packages/app/src/dapp/store/reducers/app.reducer.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ export type appState = {
77
address: string;
88
reducedAddress: string;
99

10-
// drips owned
11-
drips: {
12-
collection: string;
13-
id: number;
14-
img: string;
15-
}[];
10+
walletAssets: {
11+
//
12+
drips: {
13+
collection: string;
14+
id: number;
15+
img: string;
16+
}[];
1617

17-
// nfts
18-
nfts: {
19-
collection: string;
20-
list: { img: string; title: string; id: number }[];
21-
}[];
18+
//
19+
nfts: {
20+
collection: string;
21+
list: { img: string; title: string; id: number }[];
22+
}[];
23+
};
2224
};
2325

2426
const appStateReducer = (
@@ -28,10 +30,10 @@ const appStateReducer = (
2830
reducedAddress: "",
2931

3032
//
31-
drips: [],
32-
33-
//
34-
nfts: [],
33+
walletAssets: {
34+
drips: [],
35+
nfts: [],
36+
},
3537
},
3638
action: AppActionTypes
3739
): appState => {

0 commit comments

Comments
 (0)