-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ππ§ β [SSM-30 SSM-31]: Working on global view of community stations
- Loading branch information
1 parent
5d589a4
commit f89d120
Showing
14 changed files
with
177 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useState } from "react"; | ||
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { Building2 } from "lucide-react"; | ||
|
||
export interface IndividualStationProps { | ||
name: string; | ||
projects: Project[]; | ||
onClose?: () => void; | ||
// Will add more from `StationModal.tsx` script later | ||
// For now, the focus is on integrating projects | ||
}; | ||
|
||
type Project = { | ||
id: string; | ||
name: string; | ||
identifier: string; | ||
isUnlocked: boolean; | ||
level: number; | ||
}; | ||
|
||
const IndividualCommunityStation: React.FC<IndividualStationProps> = ({ | ||
name, | ||
projects, | ||
onClose, | ||
}) => { | ||
const [activeSection, setActiveSection] = useState<string | null>(null); | ||
const [selectedItem, setSelectedItem] = useState<Project | null>(null); | ||
const [isExpanded, setExpanded] = useState(false); | ||
|
||
const [isDarkMode, setIsDarkMode] = useState(false); | ||
const toggleDarkMode = () => setIsDarkMode(!isDarkMode); | ||
const baseColors = isDarkMode | ||
? { bg: "#303F51", text: "#F7F5E9", accent1: "#85DDA2", accent2: "#5FCBC3" } | ||
: { | ||
bg: "#F7F5E9", | ||
text: "#303F51", | ||
accent1: "#FFD580", | ||
accent2: "#5FCBC3", | ||
}; | ||
|
||
const handleItemClick = (item: any) => { | ||
setSelectedItem(item); | ||
}; | ||
|
||
const handleBack = () => { | ||
setSelectedItem(null); | ||
setActiveSection(null); | ||
}; | ||
|
||
const handleClose = () => { | ||
setExpanded(false); | ||
if (onClose) { | ||
onClose(); | ||
}; | ||
}; | ||
|
||
return ( | ||
<Dialog defaultOpen> | ||
<div | ||
className={`flex flex-col items-center p-6 rounded-lg shadow-lg w-full max-w-md mx-auto transition-colors duration-300 ease-in-out overflow-hidden`} | ||
style={{ backgroundColor: baseColors.bg, color: baseColors.text }} | ||
> | ||
<div className="flex justify-between items-center w-full mb-6"> | ||
<Building2 | ||
className="w-10 h-10" | ||
style={{ color: baseColors.accent2}} | ||
/> | ||
<h2 className="text-2xl font-bold"> | ||
{name} | ||
</h2> | ||
</div> | ||
</div> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default IndividualCommunityStation; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use client"; | ||
|
||
import React, { useCallback, useEffect, useState } from "react"; | ||
import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; | ||
import { useActivePlanet } from "@/context/ActivePlanet"; | ||
import IndividualCommunityStation, { IndividualStationProps } from "./IndividualStation"; | ||
import { InventoryStructureItem, StructureItemDetail } from "@/types/Items"; | ||
|
||
import "../../styles/Anims/StarterStructureAnimations.css"; | ||
import { CreateCommunityStation } from "../Build/MakeCommunityStation"; | ||
|
||
export default function StationsOnPlanet() { | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
|
||
const { activePlanet } = useActivePlanet(); | ||
|
||
const [stationsOnPlanet, setStationsOnPlanet] = useState<IndividualStationProps[]>([]); | ||
const [itemDetails, setItemDetails] = useState<Map<number, StructureItemDetail>>(new Map()); | ||
const [selectedStation, setSelectedStation] = useState<IndividualStationProps | null>(null); | ||
|
||
const [loading, setLoading] = useState(true); | ||
|
||
const fetchStructures = useCallback(async () => { | ||
if (!session || !activePlanet) { | ||
setLoading(false); | ||
return; | ||
}; | ||
|
||
try { | ||
const response = await fetch('/api/gameplay/inventory'); | ||
const itemData: StructureItemDetail[] = await response.json(); | ||
const itemMap = new Map<number, StructureItemDetail>(); | ||
itemData.forEach(item => { | ||
if (item.ItemCategory === "CommunityStation") { | ||
itemMap.set(item.id, item); | ||
} | ||
}); | ||
|
||
setItemDetails(itemMap); | ||
const { data: inventoryData, error: inventoryError } = await supabase | ||
.from('inventory') | ||
.select("*") | ||
.eq('anomaly', activePlanet.id); | ||
|
||
if (inventoryError) { | ||
throw inventoryError; | ||
}; | ||
|
||
const stations = new Map<number, InventoryStructureItem>(); | ||
inventoryData.forEach(structure => { | ||
const itemDetail = itemMap.get(structure.item); | ||
if (itemDetail && itemDetail.locationType === 'Surface' && !stations.has(structure.item)) { | ||
stations.set(structure.item, structure); | ||
}; | ||
}); | ||
|
||
const uniqueStations = Array.from(stations.values()); | ||
// setStationsOnPlanet(uniqueStations || []); | ||
} catch (error: any) { | ||
console.error("Error fetching structures", error); | ||
} finally { | ||
setLoading(false); | ||
}; | ||
}, [session, activePlanet, supabase, itemDetails]); | ||
|
||
return ( | ||
<></> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.