chore: run prettier
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ashhhleyyy 2022-07-26 22:18:54 +01:00
parent a3a3bca81f
commit bf70d7b476
Signed by: ash
GPG key ID: 83B789081A0878FB
5 changed files with 53 additions and 30 deletions

View file

@ -28,7 +28,13 @@ export default function Button({
'transition-colors' 'transition-colors'
); );
if (!noDefaultColous) { 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} />; return <button className={classes.join(' ')} {...props} />;
} }

7
next-auth.d.ts vendored
View file

@ -1,11 +1,10 @@
import NextAuth, { DefaultSession } from "next-auth" import NextAuth, { DefaultSession } from 'next-auth';
declare module "next-auth" { declare module 'next-auth' {
interface Session { interface Session {
user: { user: {
/** The user's internal ID. */ /** The user's internal ID. */
id: string; id: string;
} & DefaultSession["user"] } & DefaultSession['user'];
} }
} }

View file

@ -110,7 +110,7 @@ export default async function handler(
}, },
include: { include: {
bubbles: true, bubbles: true,
} },
}); });
await auditPageUpdate(page, after, data, session.user); await auditPageUpdate(page, after, data, session.user);

View file

@ -219,7 +219,8 @@ export default function TranscribePage(props: Props) {
<AreaSelector <AreaSelector
areas={regions.map((r) => r.area)} areas={regions.map((r) => r.area)}
onChange={(areas) => onChange={(areas) =>
!lockAreas && !saving && !lockAreas &&
!saving &&
setRegions( setRegions(
areas.map((area, i) => { areas.map((area, i) => {
if (i < regions.length) { if (i < regions.length) {
@ -269,7 +270,9 @@ export default function TranscribePage(props: Props) {
</section> </section>
<section className='flex-1'> <section className='flex-1'>
<div> <div>
<Button disabled={saving} onClick={extractText}>Extract text</Button> <Button disabled={saving} onClick={extractText}>
Extract text
</Button>
<br /> <br />
<label htmlFor='indicate-numbers'> <label htmlFor='indicate-numbers'>
<input <input
@ -360,7 +363,8 @@ export default function TranscribePage(props: Props) {
<div <div
key={i} key={i}
onClick={() => onClick={() =>
!saving && setSelectedBubble( !saving &&
setSelectedBubble(
selectedBubble === i ? -1 : i selectedBubble === i ? -1 : i
) )
} }
@ -384,7 +388,9 @@ export default function TranscribePage(props: Props) {
<hr className='border-slate-600 my-2' /> <hr className='border-slate-600 my-2' />
<div> <div>
<Button disabled={saving} onClick={submitBubbles}>Save!</Button> <Button disabled={saving} onClick={submitBubbles}>
Save!
</Button>
</div> </div>
</section> </section>
</div> </div>

View file

@ -1,27 +1,39 @@
import { ComicBubble, ComicPage } from "@prisma/client"; import { ComicBubble, ComicPage } from '@prisma/client';
import { WebhookClient } from "discord.js"; import { WebhookClient } from 'discord.js';
import { Session } from "next-auth"; import { Session } from 'next-auth';
import { PageBubbles } from "../pages/api/submit-page-bubbles"; import { PageBubbles } from '../pages/api/submit-page-bubbles';
import { createPatch } from 'diff'; import { createPatch } from 'diff';
type Page = ComicPage & { bubbles: ComicBubble[] }; type Page = ComicPage & { bubbles: ComicBubble[] };
const DJS_CLIENT = new WebhookClient({ const DJS_CLIENT = new WebhookClient(
{
url: process.env.AUDIT_WEBHOOK!, url: process.env.AUDIT_WEBHOOK!,
}, { },
{
allowedMentions: { allowedMentions: {
parse: [], 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 beforeS = JSON.stringify(before, null, 2);
const afterS = JSON.stringify(after, null, 2); const afterS = JSON.stringify(after, null, 2);
if (beforeS === afterS) { if (beforeS === afterS) {
return; 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({ await DJS_CLIENT.send({
embeds: [ embeds: [
{ {
@ -40,7 +52,7 @@ export async function auditPageUpdate(before: Page, after: Page, update: PageBub
footer: { footer: {
text: `${user.name} (${user.id})`, text: `${user.name} (${user.id})`,
}, },
} },
] ],
}) });
} }