diff --git a/public/assets/moon_1.png b/public/assets/moon_1.png index c93b2af..a5151f2 100644 Binary files a/public/assets/moon_1.png and b/public/assets/moon_1.png differ diff --git a/public/assets/moon_2.png b/public/assets/moon_2.png new file mode 100644 index 0000000..f6ebd01 Binary files /dev/null and b/public/assets/moon_2.png differ diff --git a/public/assets/moon_3.png b/public/assets/moon_3.png new file mode 100644 index 0000000..496f618 Binary files /dev/null and b/public/assets/moon_3.png differ diff --git a/public/assets/moon_4.png b/public/assets/moon_4.png new file mode 100644 index 0000000..c105bc3 Binary files /dev/null and b/public/assets/moon_4.png differ diff --git a/public/assets/moon_5.png b/public/assets/moon_5.png new file mode 100644 index 0000000..0049059 Binary files /dev/null and b/public/assets/moon_5.png differ diff --git a/src/app/Components/BankAccount.tsx b/src/app/Components/BankAccount.tsx deleted file mode 100644 index f3b9262..0000000 --- a/src/app/Components/BankAccount.tsx +++ /dev/null @@ -1,24 +0,0 @@ -"use client"; -import React from "react"; -import { IBankAccount } from "typings"; - -const BankAccount = (props: { account: IBankAccount }) => { - return ( -
-
- MoonBucks -

- {props.account.primaryBalance.toLocaleString("en-US", { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })}{" "} - kg -

-
-
- ); -}; - -export default BankAccount; diff --git a/src/app/Components/BankAccountsView.tsx b/src/app/Components/BankAccountsView.tsx index 5a5e091..2663c1f 100644 --- a/src/app/Components/BankAccountsView.tsx +++ b/src/app/Components/BankAccountsView.tsx @@ -1,31 +1,33 @@ "use client"; import React from "react"; import { IBankAccount } from "typings"; -import BankAccount from "./BankAccount"; import ResourceAccount from "./ResourceAccount"; +import { BiLoaderAlt } from "react-icons/bi"; const BankAccountsView = (props: { bankAccount: IBankAccount | undefined; setLightBoxIsActive: () => void; }) => { if (props.bankAccount === undefined) { - return

No bankaccount

; + return ( +
+ +
+ ); } return (
-
-
+
+
- Moonbucks + Moonbucks

- ${props.bankAccount?.primaryBalance} + $ + {props.bankAccount?.primaryBalance.toLocaleString("en-US", { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}

-
{props.bankAccount && diff --git a/src/app/Components/InventoryItem.tsx b/src/app/Components/InventoryItem.tsx index 000fe58..0b7025c 100644 --- a/src/app/Components/InventoryItem.tsx +++ b/src/app/Components/InventoryItem.tsx @@ -37,56 +37,62 @@ const InventoryItem = (props: {
-

+

{props.inventoryItem.storeItem.name}

{props.inventoryItem.storeItem.description}

-
+

Base Yield

+

{props.inventoryItem.storeItem.claimAmount}

+

Tier

+
{props.inventoryItem.storeItem.upgrades.map((upgrade, id) => { if (upgrade.tier <= currentUpgrade.tier) { return ( - + ); } else { return ( - + ); } })} +

(+{currentUpgrade.claimBoost})

-

Yield

-

- {props.inventoryItem.storeItem.claimAmount} +{" "} - {currentUpgrade.claimBoost} -

-
-
- {isInUse() ? ( - - ) : ( - + ) : ( + - )} -
+ + + + )} + ({getNextUpgradePrice()})
diff --git a/src/app/Components/InventoryItemView.tsx b/src/app/Components/InventoryItemView.tsx index 4c65bf0..d8ddbee 100644 --- a/src/app/Components/InventoryItemView.tsx +++ b/src/app/Components/InventoryItemView.tsx @@ -8,18 +8,20 @@ const InventoryItemView = (props: { upgradeInventoryItem: (inventoryItemId: number, storeItemId: string) => void; }) => { return ( -
-

Your Inventory

- {props.inventoryItems && - props.inventoryItems.length > 0 && - props.inventoryItems.map((inventoryItem, id) => ( - - ))} +
+

Your Inventory

+
+ {props.inventoryItems && + props.inventoryItems.length > 0 && + props.inventoryItems.map((inventoryItem, id) => ( + + ))} +
); }; diff --git a/src/app/Components/NavbarVertical.tsx b/src/app/Components/NavbarVertical.tsx new file mode 100644 index 0000000..6bf8825 --- /dev/null +++ b/src/app/Components/NavbarVertical.tsx @@ -0,0 +1,47 @@ +import React from "react"; + +interface MenuItem { + name: string; + componentKey: string; +} + +const menuItems: MenuItem[] = [ + { name: "Moons", componentKey: "stakingsourcesview" }, + { name: "Inventory", componentKey: "inventoryitemview" }, + { name: "Buy Items", componentKey: "storeitemview" }, + { name: "Sell Resources", componentKey: "resourcestore" }, +]; + +interface NavbarProps { + onMenuItemClick: (componentKey: string) => void; + activeItem: string; +} + +const NavbarVertical: React.FC = ({ + onMenuItemClick, + activeItem, +}) => { + return ( +
+ +
+ ); +}; + +export default NavbarVertical; diff --git a/src/app/Components/ResourceAccount.tsx b/src/app/Components/ResourceAccount.tsx index 00d6260..28b454c 100644 --- a/src/app/Components/ResourceAccount.tsx +++ b/src/app/Components/ResourceAccount.tsx @@ -5,12 +5,7 @@ import { resourceToBg, resourceToFc } from "../../utils/helpers"; const ResourceAccount = (props: { account: IResourceAccount }) => { return ( -
+
void; -}) => { +const ResourceStore = (props: { bankAccount: IBankAccount | undefined }) => { const [conversionRate, setConversionRate] = useState(0.1); const [conversionPairs, setConversionPairs] = useState< IConversionPair[] | null @@ -54,10 +51,8 @@ const ResourceStore = (props: { }; return ( -
-

- Sell Your Resources -

+
+

Sell Resources

{props.bankAccount && diff --git a/src/app/Components/StakingSource.tsx b/src/app/Components/StakingSource.tsx index 658f093..721fbcb 100644 --- a/src/app/Components/StakingSource.tsx +++ b/src/app/Components/StakingSource.tsx @@ -6,6 +6,7 @@ import { getObjectFromArray, } from "../../utils/helpers"; import SelectDropdown from "./SelectDropdown"; +import Image from "next/image"; const StakingSource = (props: { stakingSource: IStakingSource; @@ -115,81 +116,99 @@ const StakingSource = (props: { }; return ( - -

{props.stakingSource.name}

-

{props.stakingSource.description}

-
-
-

Active Drills

- {activeStakes && - activeStakes.map((stake, id) => ( -
-

- Drill: - {props.inventoryItems && - getObjectFromArray( - props.inventoryItems, - "id", - stake.inventoryItemId - )?.storeItem.name} -

-

- Resource: - {stake.resourceType} -

-

- Yield: - {stake.stakeAmount} -

- -
- ))} -
-
-

Inactive Drills

- {props.inventoryItems && - props.inventoryItems.map( - (item, id) => - !isActive(item) && ( -
-

{item.storeItem.name}

-

Select Resource

-
- ({ - value: well.id, - label: well.resourceType, - }) - )} - onChange={(value) => - handleSelectChange(value, item.id, item.storeItem.id) - } - isActive={selectedItemId === item.id} - /> - {selectedItemId === item.id ? ( - - ) : ( - <> - )} +
+
+ Moon +
+
+

+ {props.stakingSource.name} +

+

{props.stakingSource.description}

+
+
+

Active Drills

+ {activeStakes && + activeStakes.map((stake, id) => ( +
+

+ Drill: + {props.inventoryItems && + getObjectFromArray( + props.inventoryItems, + "id", + stake.inventoryItemId + )?.storeItem.name} +

+

+ Resource: + {stake.resourceType} +

+

+ Yield: + {stake.stakeAmount} +

+
-
- ) - )} + ))} +
+
+

Inactive Drills

+ {props.inventoryItems && + props.inventoryItems.map( + (item, id) => + !isActive(item) && ( +
+

{item.storeItem.name}

+

Select Resource

+
+ ({ + value: well.id, + label: well.resourceType, + }) + )} + onChange={(value) => + handleSelectChange( + value, + item.id, + item.storeItem.id + ) + } + isActive={selectedItemId === item.id} + /> + {selectedItemId === item.id ? ( + + ) : ( + <> + )} +
+
+ ) + )} +
+
+
- +
); }; diff --git a/src/app/Components/StakingSourcesView.tsx b/src/app/Components/StakingSourcesView.tsx index 39fcd6c..be27d26 100644 --- a/src/app/Components/StakingSourcesView.tsx +++ b/src/app/Components/StakingSourcesView.tsx @@ -3,6 +3,79 @@ import React from "react"; import { IInventoryItem, IStakingSource } from "typings"; import StakingSource from "./StakingSource"; +const moons = [ + { + name: "Caelusium", + description: + "Caelusium is a medium-sized moon with a diverse landscape. Its craters contain a wealth of common resources, making it an ideal starting location for beginners. The moon's relatively mild weather conditions and stable surface offer a friendly environment for establishing mining operations.", + image: "/assets/moon_1.png", + price: 100, + }, + { + name: "Caelusium", + description: + "Caelusium is a medium-sized moon with a diverse landscape. Its craters contain a wealth of common resources, making it an ideal starting location for beginners. The moon's relatively mild weather conditions and stable surface offer a friendly environment for establishing mining operations.", + image: "/assets/moon_2.png", + price: 100, + }, + { + name: "Caelusium", + description: + "Caelusium is a medium-sized moon with a diverse landscape. Its craters contain a wealth of common resources, making it an ideal starting location for beginners. The moon's relatively mild weather conditions and stable surface offer a friendly environment for establishing mining operations.", + image: "/assets/moon_3.png", + price: 100, + }, + { + name: "Caelusium", + description: + "Caelusium is a medium-sized moon with a diverse landscape. Its craters contain a wealth of common resources, making it an ideal starting location for beginners. The moon's relatively mild weather conditions and stable surface offer a friendly environment for establishing mining operations.", + image: "/assets/moon_4.png", + price: 100, + }, + { + name: "Caelusium", + description: + "Caelusium is a medium-sized moon with a diverse landscape. Its craters contain a wealth of common resources, making it an ideal starting location for beginners. The moon's relatively mild weather conditions and stable surface offer a friendly environment for establishing mining operations.", + image: "/assets/moon_5.png", + price: 100, + }, +]; + +interface RowProps { + stakingSources: IStakingSource[]; + inventoryItems: IInventoryItem[]; + claimStake: (stakingEventId: number) => void; + startStake: ( + inventoryItemId: number, + storeItemId: string, + wellId: number + ) => void; +} + +const Row: React.FC = ({ + stakingSources, + inventoryItems, + claimStake, + startStake, +}) => { + return ( +
+ {stakingSources.map((stakingSource, index) => ( +
+ +
+ ))} +
+ ); +}; + +const moonSizes = [250, 375, 300, 225, 175, 300, 200, 150, 300, 225]; + const StakingSourcesView = (props: { stakingSources: IStakingSource[] | null; inventoryItems: IInventoryItem[] | null | undefined; @@ -14,10 +87,38 @@ const StakingSourcesView = (props: { ) => void; createStakingSource: () => void; }) => { + // Generate rows of stakingSources + const handleRows = () => { + let rows = []; + let currentRow = []; + let rowSize = 3; + if (props.stakingSources) { + props.stakingSources.forEach((stakingSource, index) => { + currentRow.push({ ...stakingSource, size: moonSizes[index] }); + + if (currentRow.length === rowSize) { + rows.push(currentRow); + currentRow = []; + rowSize = rowSize === 3 ? 4 : 3; + } + }); + + if (currentRow.length) { + rows.push(currentRow); + } + + return rows; + } else { + return []; + } + }; + + const rows = handleRows(); + return ( -
+
-

Your Moons

+

Your Moons

- {props.stakingSources && - props.stakingSources.length > 0 && - props.stakingSources.map((stakingSource, id) => ( - - ))} + {rows.map((stakingSources, index) => ( + + ))}
); }; diff --git a/src/app/Components/StakingSourcesViewBackup.tsx b/src/app/Components/StakingSourcesViewBackup.tsx new file mode 100644 index 0000000..ff13c59 --- /dev/null +++ b/src/app/Components/StakingSourcesViewBackup.tsx @@ -0,0 +1,58 @@ +"use client"; +import React from "react"; +import { IInventoryItem, IStakingSource } from "typings"; +import StakingSource from "./StakingSource"; + +const StakingSourcesView = (props: { + stakingSources: IStakingSource[] | null; + inventoryItems: IInventoryItem[] | null | undefined; + claimStake: (stakingEventId: number) => void; + startStake: ( + inventoryItemId: number, + storeItemId: string, + wellId: number + ) => void; + createStakingSource: () => void; +}) => { + return ( +
+
+

Your Moons

+ +
+
+ {props.stakingSources && + props.stakingSources.length > 0 && + props.stakingSources.map((stakingSource, id) => ( + + ))} +
+
+ ); +}; + +export default StakingSourcesView; diff --git a/src/app/Components/StoreItem.tsx b/src/app/Components/StoreItem.tsx index 7bec7b6..7f9a002 100644 --- a/src/app/Components/StoreItem.tsx +++ b/src/app/Components/StoreItem.tsx @@ -1,7 +1,7 @@ "use client"; import React, { useState } from "react"; import { IStoreItem } from "typings"; -import CommonCardLayout from "../Layouts/CommonCardLayout"; +import CardLayout from "../Layouts/CardLayout"; import Image from "next/image"; const StoreItem = (props: { @@ -9,7 +9,7 @@ const StoreItem = (props: { buyStoreItem: (itemId: string) => void; }) => { return ( - +

{props.storeItem.name}

@@ -17,7 +17,7 @@ const StoreItem = (props: {
@@ -46,7 +46,7 @@ const StoreItem = (props: { />
- + ); }; diff --git a/src/app/Components/StoreItemView.tsx b/src/app/Components/StoreItemView.tsx index 4e06e64..b01b4de 100644 --- a/src/app/Components/StoreItemView.tsx +++ b/src/app/Components/StoreItemView.tsx @@ -8,9 +8,9 @@ const StoreItemView = (props: { buyStoreItem: (itemId: string) => void; }) => { return ( -
-

Store

-
+
+

Store

+
{props.storeItems && props.storeItems.length > 0 && props.storeItems diff --git a/src/app/Layouts/CardLayout.tsx b/src/app/Layouts/CardLayout.tsx index 348238f..24712f0 100644 --- a/src/app/Layouts/CardLayout.tsx +++ b/src/app/Layouts/CardLayout.tsx @@ -4,7 +4,7 @@ export default function CardLayout({ children: React.ReactNode; }) { return ( -
+
{children}
); diff --git a/src/app/page.tsx b/src/app/page.tsx index 0de3044..5604130 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -9,13 +9,13 @@ import NotificationPopover from "./Components/NotificationPopover"; import { gameConfig } from "@/utils/gameLogic"; import { IInventoryItem, - IStoreStakingSource, IStakingSource, IBankAccount, IStake, Notification, } from "typings"; import Navbar from "./Components/Navbar"; +import NavbarVertical from "./Components/NavbarVertical"; export default function Home() { const [inventoryItems, setInventoryItems] = useState< @@ -32,6 +32,7 @@ export default function Home() { const [notificationTime, setNotificationTime] = useState(30); const [storeItems, setStoreItems] = useState(gameConfig.store); const [isLoading, setIsLoading] = useState(true); + const [activeComponent, setActiveComponent] = useState("stakingsourcesview"); const isOwned = (storeItemId: string) => { if (inventoryItems && inventoryItems?.length > 0) { @@ -298,6 +299,10 @@ export default function Home() { setNotification(null); }; + const handleMenuItemClick = (componentKey: string) => { + setActiveComponent(componentKey); + }; + if (!userId) return ( <> @@ -310,7 +315,7 @@ export default function Home() { return

Loading...

; } - console.log(stakingSources); + //console.log(stakingSources); return ( <> @@ -324,30 +329,37 @@ export default function Home() { bankAccount={bankAccount} setLightBoxIsActive={handleSetLightBox} /> - {lightBoxIsActive && ( - - )} -
- - - + + {activeComponent === "stakingsourcesview" && ( + + )} + {activeComponent === "inventoryitemview" && ( + + )} + {activeComponent === "storeitemview" && ( + + )} + {activeComponent === "resourcestore" && ( + + )}
); diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 26bf881..292ce9d 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -34,11 +34,11 @@ export function resourceToBg(resourceName: string): string { export function resourceToFc(resourceName: string): string { const mapping: IMapping = { - "Sollux": "text-teal-400", - "Shadowstone": "text-cyan-400", - "Azurium": "text-purple-300", - "Novafor": "text-rose-300", - "Nebulance": "text-rose-300" + "Sollux": "text-teal-600", + "Shadowstone": "text-cyan-600", + "Azurium": "text-purple-500", + "Novafor": "text-rose-500", + "Nebulance": "text-rose-500" } return mapping[resourceName] diff --git a/typings.d.ts b/typings.d.ts index 7ccff58..7595872 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -34,18 +34,12 @@ export interface IStakingSource { description: string; resourceWells: IResourceWell[]; activeStakes: IStake[]; -} - -export interface IStoreStakingSource { - id: number; - name: string; - description: string; - image: string - price: number - resourceChance: number - resourceMinStartAmount: number - resourceMaxStartAmount: number - + image: string | null + price: number | null + resourceChance: number | null + resourceMinStartAmount: number | null + resourceMaxStartAmount: number | null + size: number | null } export interface IInventoryItem {