-
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.
π«π β dynamic routing setup for individual sectors
- Loading branch information
1 parent
709f335
commit e9d4b4a
Showing
5 changed files
with
97 additions
and
5 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
41 changes: 41 additions & 0 deletions
41
components/Content/Planets/Base/IndividualBasePlanetSector.tsx
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,41 @@ | ||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
import { useRouter } from "next/router"; | ||
import React, { useState } from "react"; | ||
|
||
export default function BasePlanetSector({ id }: { id: string }) { | ||
const router = useRouter(); | ||
const { id: sectorId } = router.query; | ||
|
||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
|
||
const [sectorData, setSectorData] = useState(null) | ||
|
||
const getSectorData = async () => { | ||
try { | ||
const { data, error } = await supabase | ||
.from('basePlanetSectors') | ||
.select('*') | ||
.eq('id', sectorId) | ||
.single(); | ||
|
||
if (data) { | ||
setSectorData(data); | ||
}; | ||
|
||
if (error) { | ||
throw error; | ||
}; | ||
} catch (error: any) { | ||
console.error(error.message); | ||
}; | ||
}; | ||
|
||
// I think that sectors will have posts attributed to them via contentPLANETSECTORS -> following the IndividualBasePlanet.tsx fetch functions | ||
|
||
if (!sectorData) { | ||
return ( | ||
<div>Loading...</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useRouter } from "next/router"; | ||
import Layout from "../../../components/Section/Layout"; | ||
|
||
export default function SectorPage () { | ||
const router = useRouter(); | ||
const { id } = router.query; | ||
|
||
const [isMobile, setIsMobile] = useState(false); | ||
|
||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
const checkIsMobile = () => { | ||
setIsMobile(window.innerWidth <= 768); | ||
}; | ||
checkIsMobile(); | ||
window.addEventListener("resize", checkIsMobile); | ||
return () => { | ||
window.removeEventListener("resize", checkIsMobile); | ||
}; | ||
} | ||
}, []); | ||
|
||
if (!id) { | ||
return null; | ||
}; | ||
|
||
return ( | ||
<Layout> | ||
<div></div> | ||
</Layout> | ||
); | ||
}; |