From 80a8262dd6ccc0f6f566f479234243a6e7e5ebd5 Mon Sep 17 00:00:00 2001 From: Pablo Alayeto <55535804+Pabl0cks@users.noreply.github.com> Date: Tue, 10 Sep 2024 11:19:37 +0200 Subject: [PATCH] Add configuration to enable or disable submissions (#78) --- packages/nextjs/app/api/submissions/route.ts | 5 +++-- packages/nextjs/app/submit/_component/SubmitButton.tsx | 9 +++++---- .../extensions-hackathon/StickySubmissionInfo.tsx | 7 ++++--- packages/nextjs/scaffold.config.ts | 4 ++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/nextjs/app/api/submissions/route.ts b/packages/nextjs/app/api/submissions/route.ts index 3ca8811..6b716a8 100644 --- a/packages/nextjs/app/api/submissions/route.ts +++ b/packages/nextjs/app/api/submissions/route.ts @@ -1,6 +1,7 @@ import { NextResponse } from "next/server"; import { getServerSession } from "next-auth"; import { recoverTypedDataAddress } from "viem"; +import scaffoldConfig from "~~/scaffold.config"; import { createBuilder, getBuilderById } from "~~/services/database/repositories/builders"; import { createSubmission, getAllSubmissions } from "~~/services/database/repositories/submissions"; import { SubmissionInsert } from "~~/services/database/repositories/submissions"; @@ -26,8 +27,8 @@ export type CreateNewSubmissionBody = SubmissionInsert & { signature: `0x${strin export async function POST(req: Request) { try { - const isSubmissionClosed = true; - if (isSubmissionClosed) { + const { submissionsEnabled } = scaffoldConfig; + if (!submissionsEnabled) { return NextResponse.json({ error: "Submissions are closed" }, { status: 403 }); } diff --git a/packages/nextjs/app/submit/_component/SubmitButton.tsx b/packages/nextjs/app/submit/_component/SubmitButton.tsx index 81724f3..14dad1b 100644 --- a/packages/nextjs/app/submit/_component/SubmitButton.tsx +++ b/packages/nextjs/app/submit/_component/SubmitButton.tsx @@ -3,18 +3,19 @@ import { useFormStatus } from "react-dom"; import { useAccount } from "wagmi"; import { RainbowKitCustomConnectButton } from "~~/components/scaffold-eth"; +import scaffoldConfig from "~~/scaffold.config"; const SubmitButton = () => { const { pending } = useFormStatus(); const { isConnected } = useAccount(); - const isSubmissionClosed = true; + const { submissionsEnabled } = scaffoldConfig; return (
AUG 20 - SEP 2