admin judgements
This commit is contained in:
parent
5ae4e20d37
commit
5db0a9edc3
1 changed files with 35 additions and 1 deletions
|
@ -80,8 +80,23 @@ export default async function Home({
|
|||
.orderBy('judgements.published', 'desc')
|
||||
.selectAll()
|
||||
.execute() as unknown[] as JSONJudgementTable[];
|
||||
|
||||
let allAdmins = await db
|
||||
.selectFrom('users')
|
||||
.where('users.admin', '=', true)
|
||||
.selectAll()
|
||||
.execute();
|
||||
|
||||
console.log(content, contentOwner)
|
||||
let judgementWinners = await db
|
||||
.selectFrom('judgements')
|
||||
.where('judgements.author_id', 'in', allAdmins.map(x=>x.id))
|
||||
.where('judgements.content_id', '=', content.id)
|
||||
.selectAll()
|
||||
.execute();
|
||||
|
||||
let adminsWhoSaid = judgementWinners?.map((judgement:JSONJudgementTable) =>
|
||||
allAdmins.find(x => x.id == judgement.author_id)
|
||||
);
|
||||
|
||||
return (
|
||||
<MainLayout currentPage="/jams/" title={content.name} subtitle="Jams" backButton>
|
||||
|
@ -105,6 +120,25 @@ export default async function Home({
|
|||
<p><a href={`/jams/new/judgement/${content.id}`}>Judge this submission</a></p>
|
||||
</div>
|
||||
</ConditionalNull>
|
||||
<ConditionalNull condition={judgementWinners.length > 0}>
|
||||
<h1>Admin Judgements</h1>
|
||||
{judgementWinners.map(async (judgement:JSONJudgementTable, index:number) => {
|
||||
const judgementOwner = adminsWhoSaid[index];
|
||||
|
||||
return (<div style={{
|
||||
margin: "16px 0"
|
||||
}}>
|
||||
<h2><a href={`/jams/user/${judgementOwner.id}`}>{`${judgementOwner.username}@${judgementOwner.instance}`}</a></h2>
|
||||
<ConditionalNull condition={existingUser != null}>
|
||||
<div>
|
||||
<ConditionalNull condition={existingUser?.admin || judgementOwner.id == existingUser?.id}><p><a href={`/jams/edit/judgement/${judgement.id}`}>Edit judgement</a> - <a href={`/jams/delete/judgement/${judgement.id}`}>Delete judgement</a></p></ConditionalNull>
|
||||
</div>
|
||||
</ConditionalNull>
|
||||
<p><small>Published {new Date(parseInt(judgement.published)).toDateString()}</small></p>
|
||||
<p>{judgement.content}</p>
|
||||
</div>);
|
||||
})}
|
||||
</ConditionalNull>
|
||||
<h1>Judgements</h1>
|
||||
{judgements.map(async (judgement:JSONJudgementTable) => {
|
||||
let judgementOwner = await db
|
||||
|
|
Loading…
Reference in a new issue