-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
πΎπ‘ β [SSG-50]: Merge pull request #162 from Signal-K/SSG-50
π©πΎ β [SSG-50]: Community station initialisation
- Loading branch information
Showing
84 changed files
with
3,173 additions
and
3,010 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
app/api/gameplay/communityStations/projects/31011/route.ts
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,60 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
interface Project { | ||
id: string; | ||
name: string; | ||
identifier: string; | ||
missionRoute: number; | ||
}; | ||
|
||
interface Mission { | ||
id: string; | ||
name: string; | ||
type: string; | ||
project: string; | ||
missionRouteId?: number; | ||
}; | ||
|
||
interface CommunityStationConfig { | ||
stationName: string; | ||
inventoryItemId: number; | ||
projects: Project[]; | ||
missions: Mission[]; | ||
}; | ||
|
||
const greenhouseStation: CommunityStationConfig = { | ||
stationName: "Greenhouse", | ||
inventoryItemId: 31011, | ||
projects: [ | ||
{ | ||
id: "1", | ||
name: "Wildwatch Burrowing Owls", | ||
identifier: "zoodex-burrOwls", | ||
missionRoute: 3000002, | ||
}, | ||
{ | ||
id: "2", | ||
name: "Iguanas from Above", | ||
identifier: "zoodex-iguanasFromAbove", | ||
missionRoute: 3000004, | ||
}, | ||
], | ||
missions: [ | ||
{ | ||
id: "1", | ||
name: "Spot an owl in the wild", | ||
type: "Upload", | ||
project: "1", | ||
}, | ||
{ | ||
id: "2", | ||
name: "Track iguana movement", | ||
type: "Analysis", | ||
project: "2", | ||
}, | ||
], | ||
}; | ||
|
||
export async function GET(req: NextRequest) { | ||
return NextResponse.json(greenhouseStation); | ||
}; |
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,110 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import React from 'react'; | ||
|
||
import { BurrowingOwl } from '@/components/Projects/Zoodex/burrowingOwls'; | ||
import { ZoodexIguanas } from '@/components/Projects/Zoodex/iguanasFromAbove'; | ||
|
||
interface Project { | ||
id: string; | ||
name: string; | ||
identifier: string; | ||
component: React.ComponentType; | ||
missionRoute: number; | ||
structure: string; | ||
// isUnlocked: boolean; // Uncomment if needed | ||
// level: number; // Uncomment if needed | ||
} | ||
|
||
interface Mission { | ||
id: string; | ||
name: string; | ||
type: string; | ||
// completionRate: number; // Uncomment if needed | ||
project: string; | ||
// level: number; // Uncomment if needed | ||
// isUnlocked: boolean; // Uncomment if needed | ||
} | ||
|
||
interface CommunityStationConfig { | ||
stationName: string; | ||
inventoryItemId: number; | ||
projects: Project[]; | ||
missions: Mission[]; | ||
} | ||
|
||
const greenhouseStation: CommunityStationConfig = { | ||
stationName: "Greenhouse", | ||
inventoryItemId: 31011, | ||
projects: [ | ||
{ | ||
id: "1", | ||
name: "Wildwatch Burrowing Owls", | ||
identifier: "zoodex-burrowingOwls", | ||
component: BurrowingOwl, | ||
structure: "Zoodex", | ||
missionRoute: 3000002, | ||
}, | ||
{ | ||
id: "2", | ||
name: "Iguanas from Above", | ||
identifier: "zoodex-iguanasFromAbove", | ||
component: ZoodexIguanas, | ||
structure: "Zoodex", | ||
missionRoute: 3000004, | ||
}, | ||
], | ||
missions: [ | ||
{ | ||
id: "1", | ||
name: "Spot an owl in the wild", | ||
type: "Upload", | ||
project: "1", | ||
}, | ||
{ | ||
id: "2", | ||
name: "Track iguana movement", | ||
type: "Analysis", | ||
project: "2", | ||
}, | ||
], | ||
}; | ||
|
||
const weatherBalloonStation: CommunityStationConfig = { | ||
stationName: "Weather balloon", | ||
inventoryItemId: 31012, | ||
projects: [], | ||
missions: [ | ||
{ | ||
id: "1", | ||
name: "Determine planet type to allow for population of relevant anomalies, and then attribute some clouds", | ||
type: "Upload", | ||
project: "1", | ||
}, | ||
], | ||
}; | ||
|
||
const spaceTelescopeStation: CommunityStationConfig = { | ||
stationName: "Space telescope", | ||
inventoryItemId: 31013, | ||
projects: [], | ||
missions: [ | ||
{ | ||
id: "1", | ||
name: "Map planet type based on lightcurve information", // and then we can attribute/participate other missions/projects", | ||
type: "Upload", | ||
project: "1", | ||
}, | ||
], | ||
}; | ||
|
||
export async function GET(req: NextRequest) { | ||
const response = { | ||
stations: [ | ||
greenhouseStation, | ||
weatherBalloonStation, | ||
spaceTelescopeStation, | ||
], | ||
}; | ||
|
||
return NextResponse.json(response); | ||
}; |
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,49 @@ | ||
'use client'; | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; | ||
|
||
export default function OnlineUserList() { | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); // Session must be loaded first | ||
const [onlineUsers, setOnlineUsers] = useState(0); | ||
|
||
useEffect(() => { | ||
// Wait until session is ready | ||
if (!session?.user?.id) return; | ||
|
||
const roomOne = supabase.channel('room_01', { | ||
config: { | ||
presence: { | ||
key: session.user.id, // Ensure session user id is used correctly | ||
}, | ||
}, | ||
}); | ||
|
||
roomOne | ||
.on('presence', { event: 'sync' }, () => { | ||
const currentPresenceState = roomOne.presenceState(); | ||
const onlineUsersCount = Object.keys(currentPresenceState).length; | ||
setOnlineUsers(onlineUsersCount); | ||
}) | ||
.on('presence', { event: 'join' }, ({ key, newPresences }) => { | ||
console.log('User joined:', key, newPresences); | ||
}) | ||
.on('presence', { event: 'leave' }, ({ key, leftPresences }) => { | ||
console.log('User left:', key, leftPresences); | ||
}) | ||
.subscribe(); | ||
|
||
// Clean up the subscription on unmount | ||
return () => { | ||
roomOne.unsubscribe(); | ||
}; | ||
}, [session?.user?.id, supabase]); | ||
|
||
return ( | ||
<div className="flex items-center gap-1"> | ||
<div className="h-4 w-4 bg-green-500 rounded-full animate-pulse"></div> | ||
<h1 className='text-sm text-gray-400'>{onlineUsers} Online</h1> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.