- {children}
+
+ {props.children}
)
}
diff --git a/components/PartyDetails/index.tsx b/components/PartyDetails/index.tsx
index 81394059..3ee67f8b 100644
--- a/components/PartyDetails/index.tsx
+++ b/components/PartyDetails/index.tsx
@@ -98,9 +98,9 @@ const PartyDetails = (props: Props) => {
const readOnly = (
- { (appSnapshot.party.name) ? appSnapshot.party.name : 'No title' }
+ { (appSnapshot.party.name) ? appSnapshot.party.name
: '' }
{ (appSnapshot.party.raid) ? {appSnapshot.party.raid.name.en}
: '' }
- { (appSnapshot.party.description) ? appSnapshot.party.description : '' }
+ { (appSnapshot.party.description) ? appSnapshot.party.description
: '' }
)
diff --git a/pages/[username].tsx b/pages/[username].tsx
index 9442349e..3d027042 100644
--- a/pages/[username].tsx
+++ b/pages/[username].tsx
@@ -1,18 +1,24 @@
import React, { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
+import { useCookies } from 'react-cookie'
import api from '~utils/api'
import ProfileHeader from '~components/ProfileHeader'
import GridRep from '~components/GridRep'
import GridRepCollection from '~components/GridRepCollection'
+import FilterBar from '~components/FilterBar'
const ProfileRoute: React.FC = () => {
const router = useRouter()
const { username } = router.query
+ const [cookies] = useCookies(['user'])
+
const [found, setFound] = useState(false)
const [loading, setLoading] = useState(true)
+ const [scrolled, setScrolled] = useState(false)
+
const [parties, setParties] = useState
([])
const [user, setUser] = useState({
id: '',
@@ -20,13 +26,31 @@ const ProfileRoute: React.FC = () => {
granblueId: 0
})
+ // Filter states
+ const [element, setElement] = useState(null)
+ const [raidId, setRaidId] = useState(null)
+ const [recencyInSeconds, setRecencyInSeconds] = useState(null)
+
useEffect(() => {
if (username)
fetchProfile(username as string)
}, [username])
async function fetchProfile(username: string) {
- api.endpoints.users.getOne({ id: username })
+ const filterParams = {
+ params: {
+ element: element,
+ raid: raidId,
+ recency: recencyInSeconds
+ },
+ headers: {
+ 'Authorization': `Bearer ${cookies.user?.access_token}`
+ }
+ }
+
+ setLoading(true)
+
+ api.endpoints.users.getOne({ id: username, params: filterParams })
.then(response => {
setUser({
id: response.data.user.id,
@@ -52,6 +76,23 @@ const ProfileRoute: React.FC = () => {
})
}
+ function receiveFilters(element?: number, raid?: string, recency?: number) {
+ if (element != null && element >= 0)
+ setElement(element)
+ else
+ setElement(null)
+
+ if (raid && raid != '0')
+ setRaidId(raid)
+ else
+ setRaidId(null)
+
+ if (recency && recency > 0)
+ setRecencyInSeconds(recency)
+ else
+ setRecencyInSeconds(null)
+ }
+
function render() {
const content = (parties && parties.length > 0) ? renderGrids() : renderNoGrids()
return (
@@ -62,55 +103,57 @@ const ProfileRoute: React.FC = () => {
)
}
+ function handleScroll() {
+ if (window.pageYOffset > 90)
+ setScrolled(true)
+ else
+ setScrolled(false)
+ }
+
function goTo(shortcode: string) {
router.push(`/p/${shortcode}`)
}
-
- function renderGrids() {
- return (
-
- {
- parties.map((party, i) => {
- return
- })
- }
-
- )
- }
- function renderNoGrids() {
- return (
-
-
This user has no grids.
-
- )
- }
+ return (
+
+
+
+

+
{user.username}
+
+
- function renderNotFound() {
- return (
-
-
That user doesn't exist.
-
- )
- }
-
- if (!found && !loading) {
- return renderNotFound()
- } else if (found && !loading) {
- return render()
- } else {
- return (
)
- }
+
+
+ {
+ parties.map((party, i) => {
+ return
+ })
+ }
+
+ { (parties.length == 0) ?
+
+
{ (loading) ? 'Loading teams...' : 'No teams found' }
+
+ : '' }
+
+
+ )
}
export default ProfileRoute
\ No newline at end of file
diff --git a/pages/saved.tsx b/pages/saved.tsx
index ef2b28ac..b9ec1735 100644
--- a/pages/saved.tsx
+++ b/pages/saved.tsx
@@ -18,12 +18,12 @@ const SavedRoute: React.FC = () => {
'Authorization': `Bearer ${cookies.user.access_token}`
} : {}
- const [found, setFound] = useState(false)
const [loading, setLoading] = useState(true)
const [scrolled, setScrolled] = useState(false)
const [parties, setParties] = useState([])
+ // Filter states
const [element, setElement] = useState(null)
const [raidId, setRaidId] = useState(null)
const [recencyInSeconds, setRecencyInSeconds] = useState(null)
@@ -34,9 +34,7 @@ const SavedRoute: React.FC = () => {
}, [])
const handleError = useCallback((error: any) => {
- if (error.response != null && error.response.status == 404) {
- setFound(false)
- } else if (error.response != null) {
+ if (error.response != null) {
console.error(error)
} else {
console.error("There was an error.")
@@ -55,13 +53,14 @@ const SavedRoute: React.FC = () => {
}
}
+ setLoading(true)
+
api.savedTeams(filterParams)
.then(response => {
const parties: Party[] = response.data
setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1))
})
.then(() => {
- setFound(true)
setLoading(false)
})
.catch(error => handleError(error))
@@ -139,44 +138,41 @@ const SavedRoute: React.FC = () => {
function goTo(shortcode: string) {
router.push(`/p/${shortcode}`)
}
-
- function renderGrids() {
- return (
-
- {
- parties.map((party, i) => {
- return
- })
- }
-
- )
- }
-
- function renderNoGrids() {
- return (
-
-
You haven't saved any teams yet
-
- )
- }
return (
-
- { (parties.length > 0) ? renderGrids() : renderNoGrids() }
+
+ Your saved teams
+
+
+
+
+ {
+ parties.map((party, i) => {
+ return
+ })
+ }
+
+
+ { (parties.length == 0) ?
+
+
{ (loading) ? 'Loading saved teams...' : 'You haven't saved any teams yet' }
+
+ : '' }
+
)
}
diff --git a/pages/teams.tsx b/pages/teams.tsx
index 44961fb7..41874e17 100644
--- a/pages/teams.tsx
+++ b/pages/teams.tsx
@@ -18,12 +18,12 @@ const TeamsRoute: React.FC = () => {
'Authorization': `Bearer ${cookies.user.access_token}`
} : {}
- const [found, setFound] = useState(false)
const [loading, setLoading] = useState(true)
const [scrolled, setScrolled] = useState(false)
const [parties, setParties] = useState([])
+ // Filter states
const [element, setElement] = useState(null)
const [raidId, setRaidId] = useState(null)
const [recencyInSeconds, setRecencyInSeconds] = useState(null)
@@ -34,9 +34,7 @@ const TeamsRoute: React.FC = () => {
}, [])
const handleError = useCallback((error: any) => {
- if (error.response != null && error.response.status == 404) {
- setFound(false)
- } else if (error.response != null) {
+ if (error.response != null) {
console.error(error)
} else {
console.error("There was an error.")
@@ -55,13 +53,14 @@ const TeamsRoute: React.FC = () => {
}
}
+ setLoading(true)
+
api.endpoints.parties.getAll(filterParams)
.then(response => {
const parties: Party[] = response.data
setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1))
})
.then(() => {
- setFound(true)
setLoading(false)
})
.catch(error => handleError(error))
@@ -139,44 +138,41 @@ const TeamsRoute: React.FC = () => {
function goTo(shortcode: string) {
router.push(`/p/${shortcode}`)
}
-
- function renderGrids() {
- return (
-
- {
- parties.map((party, i) => {
- return
- })
- }
-
- )
- }
-
- function renderNoGrids() {
- return (
-
-
No teams found
-
- )
- }
return (
-
- { (parties.length > 0) ? renderGrids() : renderNoGrids() }
+
+ Discover Teams
+
+
+
+
+ {
+ parties.map((party, i) => {
+ return
+ })
+ }
+
+
+ { (parties.length == 0) ?
+
+
{ (loading) ? 'Loading teams...' : 'No teams found' }
+
+ : '' }
+
)
}
diff --git a/styles/globals.scss b/styles/globals.scss
index d7f43e04..b70a95db 100644
--- a/styles/globals.scss
+++ b/styles/globals.scss
@@ -161,11 +161,11 @@ select {
}
}
-#Teams {
+#Teams, #Profile {
display: flex;
height: 100%;
flex-direction: column;
- gap: $unit * 4;
+ gap: $unit * 2;
}
#NotFound {