This commit is contained in:
parent
a3a3bca81f
commit
bf70d7b476
5 changed files with 53 additions and 30 deletions
|
@ -28,7 +28,13 @@ export default function Button({
|
|||
'transition-colors'
|
||||
);
|
||||
if (!noDefaultColous) {
|
||||
classes.push('bg-slate-600', 'text-slate-50', 'hover:bg-slate-500', 'disabled:bg-slate-900', 'disabled:text-slate-200');
|
||||
classes.push(
|
||||
'bg-slate-600',
|
||||
'text-slate-50',
|
||||
'hover:bg-slate-500',
|
||||
'disabled:bg-slate-900',
|
||||
'disabled:text-slate-200'
|
||||
);
|
||||
}
|
||||
return <button className={classes.join(' ')} {...props} />;
|
||||
}
|
||||
|
|
17
next-auth.d.ts
vendored
17
next-auth.d.ts
vendored
|
@ -1,11 +1,10 @@
|
|||
import NextAuth, { DefaultSession } from "next-auth"
|
||||
import NextAuth, { DefaultSession } from 'next-auth';
|
||||
|
||||
declare module "next-auth" {
|
||||
interface Session {
|
||||
user: {
|
||||
/** The user's internal ID. */
|
||||
id: string;
|
||||
} & DefaultSession["user"]
|
||||
}
|
||||
declare module 'next-auth' {
|
||||
interface Session {
|
||||
user: {
|
||||
/** The user's internal ID. */
|
||||
id: string;
|
||||
} & DefaultSession['user'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ export default async function handler(
|
|||
},
|
||||
include: {
|
||||
bubbles: true,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await auditPageUpdate(page, after, data, session.user);
|
||||
|
|
|
@ -219,7 +219,8 @@ export default function TranscribePage(props: Props) {
|
|||
<AreaSelector
|
||||
areas={regions.map((r) => r.area)}
|
||||
onChange={(areas) =>
|
||||
!lockAreas && !saving &&
|
||||
!lockAreas &&
|
||||
!saving &&
|
||||
setRegions(
|
||||
areas.map((area, i) => {
|
||||
if (i < regions.length) {
|
||||
|
@ -269,7 +270,9 @@ export default function TranscribePage(props: Props) {
|
|||
</section>
|
||||
<section className='flex-1'>
|
||||
<div>
|
||||
<Button disabled={saving} onClick={extractText}>Extract text</Button>
|
||||
<Button disabled={saving} onClick={extractText}>
|
||||
Extract text
|
||||
</Button>
|
||||
<br />
|
||||
<label htmlFor='indicate-numbers'>
|
||||
<input
|
||||
|
@ -360,7 +363,8 @@ export default function TranscribePage(props: Props) {
|
|||
<div
|
||||
key={i}
|
||||
onClick={() =>
|
||||
!saving && setSelectedBubble(
|
||||
!saving &&
|
||||
setSelectedBubble(
|
||||
selectedBubble === i ? -1 : i
|
||||
)
|
||||
}
|
||||
|
@ -384,7 +388,9 @@ export default function TranscribePage(props: Props) {
|
|||
<hr className='border-slate-600 my-2' />
|
||||
|
||||
<div>
|
||||
<Button disabled={saving} onClick={submitBubbles}>Save!</Button>
|
||||
<Button disabled={saving} onClick={submitBubbles}>
|
||||
Save!
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
42
src/audit.ts
42
src/audit.ts
|
@ -1,27 +1,39 @@
|
|||
import { ComicBubble, ComicPage } from "@prisma/client";
|
||||
import { WebhookClient } from "discord.js";
|
||||
import { Session } from "next-auth";
|
||||
import { PageBubbles } from "../pages/api/submit-page-bubbles";
|
||||
import { ComicBubble, ComicPage } from '@prisma/client';
|
||||
import { WebhookClient } from 'discord.js';
|
||||
import { Session } from 'next-auth';
|
||||
import { PageBubbles } from '../pages/api/submit-page-bubbles';
|
||||
import { createPatch } from 'diff';
|
||||
|
||||
type Page = ComicPage & { bubbles: ComicBubble[] };
|
||||
|
||||
const DJS_CLIENT = new WebhookClient({
|
||||
url: process.env.AUDIT_WEBHOOK!,
|
||||
}, {
|
||||
allowedMentions: {
|
||||
parse: [],
|
||||
const DJS_CLIENT = new WebhookClient(
|
||||
{
|
||||
url: process.env.AUDIT_WEBHOOK!,
|
||||
},
|
||||
})
|
||||
{
|
||||
allowedMentions: {
|
||||
parse: [],
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export async function auditPageUpdate(before: Page, after: Page, update: PageBubbles, user: Session['user']) {
|
||||
export async function auditPageUpdate(
|
||||
before: Page,
|
||||
after: Page,
|
||||
update: PageBubbles,
|
||||
user: Session['user']
|
||||
) {
|
||||
const beforeS = JSON.stringify(before, null, 2);
|
||||
const afterS = JSON.stringify(after, null, 2);
|
||||
if (beforeS === afterS) {
|
||||
return;
|
||||
}
|
||||
|
||||
const patch = createPatch(`/comic/${update.comicId}/${update.pageId}`, beforeS, afterS);
|
||||
const patch = createPatch(
|
||||
`/comic/${update.comicId}/${update.pageId}`,
|
||||
beforeS,
|
||||
afterS
|
||||
);
|
||||
await DJS_CLIENT.send({
|
||||
embeds: [
|
||||
{
|
||||
|
@ -40,7 +52,7 @@ export async function auditPageUpdate(before: Page, after: Page, update: PageBub
|
|||
footer: {
|
||||
text: `${user.name} (${user.id})`,
|
||||
},
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue