Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration to enable or disable submissions #78

Merged
merged 7 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/nextjs/app/api/submissions/route.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 });
}

Expand Down
9 changes: 5 additions & 4 deletions packages/nextjs/app/submit/_component/SubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div
className={`items-center flex flex-col ${!isConnected && !isSubmissionClosed && "tooltip tooltip-bottom"}`}
data-tip={`${!isConnected && !isSubmissionClosed ? "Please connect your wallet" : ""}`}
className={`items-center flex flex-col ${!isConnected && submissionsEnabled && "tooltip tooltip-bottom"}`}
data-tip={`${!isConnected && submissionsEnabled ? "Please connect your wallet" : ""}`}
>
{isSubmissionClosed ? (
{!submissionsEnabled ? (
<button className="btn border border-black px-6 text-lg h-10 min-h-10 font-medium" disabled>
Submissions Closed
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useState } from "react";
import Link from "next/link";
import scaffoldConfig from "~~/scaffold.config";

export const StickySubmissionInfo = () => {
const [isVisible, setIsVisible] = useState(true);
const isSubmissionClosed = true;
const { submissionsEnabled } = scaffoldConfig;

if (!isVisible) {
return (
Expand All @@ -27,11 +28,11 @@ export const StickySubmissionInfo = () => {
</button>
<h2 className="text-2xl underline mb-0 md:mb-4 2xl:text-3xl 2xl:mb-6">
{isSubmissionClosed ? "Submissions closed" : "Submissions open"}
{submissionsEnabled ? "Submissions open" : "Submissions closed"}
</h2>
<p className="md:mb-10 mt-2 2xl:text-xl 2xl:mb-12 2xl:mt-4">AUG 20 - SEP 2</p>
<div className="flex md:block space-x-2 2xl:space-x-4">
{!isSubmissionClosed && (
{submissionsEnabled && (
<Link
href="/submit"
className="bg-[#B7EBEC] py-2 px-2 sm:px-4 border border-1 border-black text-center flex-1 2xl:py-3 2xl:px-6 text-sm sm:text-base 2xl:text-xl"
Expand Down
4 changes: 4 additions & 0 deletions packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type ScaffoldConfig = {
votingEnabled: boolean;
winnersThreshold: number;
runnersUpThreshold: number;
submissionsEnabled: boolean;
};

const scaffoldConfig = {
Expand All @@ -34,6 +35,9 @@ const scaffoldConfig = {
// Only show the Burner Wallet when running on hardhat network
onlyLocalBurnerWallet: true,

// Enable submissions
submissionsEnabled: false,

// Enable voting on submissions
votingEnabled: false,

Expand Down
Loading