Improve user pages
This commit is contained in:
parent
2512dd0732
commit
63a90cb3a4
1 changed files with 109 additions and 81 deletions
|
@ -16,11 +16,15 @@ export default async function Home({
|
|||
user: string
|
||||
},
|
||||
searchParams: {
|
||||
until: string
|
||||
jamuntil: string,
|
||||
conuntil: string,
|
||||
juduntil: string
|
||||
}
|
||||
}) {
|
||||
const curDate = Date.now();
|
||||
const curPage = parseInt(searchParams?.until) || curDate;
|
||||
const jamPage = parseInt(searchParams?.jamuntil) || curDate;
|
||||
const contentPage = parseInt(searchParams?.conuntil) || curDate;
|
||||
const judgementPage = parseInt(searchParams?.juduntil) || curDate;
|
||||
|
||||
const cookieStore = cookies();
|
||||
const token = cookieStore.get('token')?.value;
|
||||
|
@ -57,7 +61,7 @@ export default async function Home({
|
|||
let content = await db
|
||||
.selectFrom('content')
|
||||
.where('content.author_id', '=', user.id)
|
||||
.where('content.submitted', '<=', curPage)
|
||||
.where('content.submitted', '<=', contentPage)
|
||||
.limit(20)
|
||||
.orderBy('content.submitted', 'desc')
|
||||
.selectAll()
|
||||
|
@ -66,7 +70,7 @@ export default async function Home({
|
|||
let jams = await db
|
||||
.selectFrom('jams')
|
||||
.where('jams.author_id', '=', user.id)
|
||||
.where('jams.created', '<=', curPage)
|
||||
.where('jams.created', '<=', jamPage)
|
||||
.limit(20)
|
||||
.orderBy('jams.created', 'desc')
|
||||
.selectAll()
|
||||
|
@ -75,7 +79,7 @@ export default async function Home({
|
|||
let judgements = await db
|
||||
.selectFrom('judgements')
|
||||
.where('judgements.author_id', '=', user.id)
|
||||
.where('judgements.published', '<=', curPage)
|
||||
.where('judgements.published', '<=', judgementPage)
|
||||
.limit(20)
|
||||
.orderBy('judgements.published', 'desc')
|
||||
.selectAll()
|
||||
|
@ -93,6 +97,7 @@ export default async function Home({
|
|||
<ConditionalNull condition={existingUser?.admin || existingUser?.id == user.id}><p><a href={`/jams/delete/user/${user.id}`}>Delete user</a></p></ConditionalNull>
|
||||
</div>
|
||||
</ConditionalNull>
|
||||
<ConditionalNull condition={jams.length > 0}>
|
||||
<h1>Jams</h1>
|
||||
{jams.map(async (jam:JSONJamTable) => {
|
||||
const started = Date.now() >= parseInt(jam.date_start);
|
||||
|
@ -114,6 +119,16 @@ export default async function Home({
|
|||
<p>{jam.description}</p>
|
||||
</div>);
|
||||
})}
|
||||
<div className="navigation">
|
||||
<ConditionalNull condition={jamPage < curDate}>
|
||||
<Link href={`?`}>Later</Link>
|
||||
</ConditionalNull>
|
||||
<ConditionalNull condition={jams.length > 20}>
|
||||
<Link href={`?jamuntil=${parseInt(jams.at(-1)?.created || jamPage + "") - 1}`}>Earlier</Link>
|
||||
</ConditionalNull>
|
||||
</div>
|
||||
</ConditionalNull>
|
||||
<ConditionalNull condition={content.length > 0}>
|
||||
<h1>Submissions</h1>
|
||||
{content.map(async (content:JSONContentTable) => {
|
||||
let contentOwner = await db
|
||||
|
@ -141,6 +156,16 @@ export default async function Home({
|
|||
<p>{content.description}</p>
|
||||
</div>);
|
||||
})}
|
||||
<div className="navigation">
|
||||
<ConditionalNull condition={contentPage < curDate}>
|
||||
<Link href={`?`}>Later</Link>
|
||||
</ConditionalNull>
|
||||
<ConditionalNull condition={content.length > 20}>
|
||||
<Link href={`?conuntil=${parseInt(content.at(-1)?.submitted || contentPage + "") - 1}`}>Earlier</Link>
|
||||
</ConditionalNull>
|
||||
</div>
|
||||
</ConditionalNull>
|
||||
<ConditionalNull condition={judgements.length > 0}>
|
||||
<h1>Judgements</h1>
|
||||
{judgements.map(async (judgement:JSONJudgementTable) => {
|
||||
let judgementOwner = await db
|
||||
|
@ -166,12 +191,15 @@ export default async function Home({
|
|||
<p>{judgement.content}</p>
|
||||
</div>);
|
||||
})}
|
||||
{/* <div className="navigation">
|
||||
<ConditionalNull condition={curPage < curDate}>
|
||||
<div className="navigation">
|
||||
<ConditionalNull condition={judgementPage < curDate}>
|
||||
<Link href={`?`}>Later</Link>
|
||||
</ConditionalNull>
|
||||
<Link href={`?until=${content.at(-1)?.submitted}`}>Earlier</Link>
|
||||
</div> */}
|
||||
<ConditionalNull condition={judgements.length > 20}>
|
||||
<Link href={`?juduntil=${parseInt(judgements.at(-1)?.published || judgementPage + "") - 1}`}>Earlier</Link>
|
||||
</ConditionalNull>
|
||||
</div>
|
||||
</ConditionalNull>
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue