Skip to content

Commit

Permalink
Merge pull request #188 from polywrap/fix/handle-strategy-view-invali…
Browse files Browse the repository at this point in the history
…d-id

fix: handle strategy view with invalid id
  • Loading branch information
cbrzn authored Feb 18, 2024
2 parents 7ab3ff6 + 045fe6b commit 192a28b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import type { Metadata } from "next";
import { Plus_Jakarta_Sans } from "next/font/google";

import "./globals.css";
import "react-toastify/dist/ReactToastify.css";
import WalletProvider from "./WalletProvider";
import Main from "./main";
import AuthProvider from "@/components/Providers";
import Header from "./Header";
import { ToastContainer } from "react-toastify";

const sans = Plus_Jakarta_Sans({
subsets: ["latin"],
Expand Down Expand Up @@ -47,6 +49,7 @@ export default function RootLayout({
<WalletProvider>
<AuthProvider>
<Main>
<ToastContainer />
<Header />
{children}
<Footer />
Expand Down
6 changes: 3 additions & 3 deletions web/app/s/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
StrategiesWithProjects,
Application,
} from "@/hooks/useStrategiesHandler";
import TextField from "@/components/TextField";
import { getNetworkNameFromChainId, NetworkName } from "@/utils/ethereum";
import { checkIfFinished } from "@/utils/logs";
import { createSupabaseServerClient, createSupabaseServerClientWithSession } from "@/utils/supabase-server";
import { createSupabaseServerClient } from "@/utils/supabase-server";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";

export default async function StrategyPage({
params,
Expand Down Expand Up @@ -52,7 +52,7 @@ export default async function StrategyPage({

if (run.error || !run.data) {
console.error(run.error);
throw Error(`Runs with id ${params.id} not found.`);
redirect(`/?not-found=${params.id}`)
}

const strategyCreated = checkIfFinished(run.data.logs);
Expand Down
17 changes: 15 additions & 2 deletions web/components/Prompt.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
"use client";

import { useState } from "react";
import { useEffect, useState } from "react";
import { SparkleIcon } from "./Icons";
import { useRouter } from "next/navigation";
import { useRouter, useSearchParams } from "next/navigation";
import PromptInput from "./PromptInput";
import useSession from "@/hooks/useSession";
import { startRun } from "@/app/actions";
import clsx from "clsx";
import { EXAMPLE_PROMPTS } from "@/utils/examplePrompts";
import { toast } from "react-toastify";


export default function Prompt({ promptIdxs }: { promptIdxs: number[] }) {
const [prompt, setPrompt] = useState<string>("");
const [isWaiting, setIsWaiting] = useState(false);
const { data: session } = useSession();
const searchParams = useSearchParams()

const router = useRouter();

Expand All @@ -30,6 +33,16 @@ export default function Prompt({ promptIdxs }: { promptIdxs: number[] }) {
}
};

useEffect(() => {
const notFoundId = searchParams.get("not-found")
if (notFoundId) {
toast.error(`Run with id ${notFoundId} does not exist`, {
autoClose: 5000,
})
router.replace("/")
}
}, [searchParams, router])

return (
<>
<div className="mx-auto max-w-screen-lg">
Expand Down
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-markdown": "^9.0.1",
"react-toastify": "^10.0.4",
"siwe": "^2.1.4",
"uuid": "^9.0.1"
},
Expand Down
4 changes: 2 additions & 2 deletions workers/fund_public_goods/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

from dataclasses import dataclass
from typing import Any
from typing import Any, Union
from aws_lambda_typing.events import SQSEvent
from aws_lambda_typing.context import Context
from fastapi_events.typing import Event as LocalEvent
Expand Down Expand Up @@ -48,7 +48,7 @@ def sqs_handler(sqs_event: SQSEvent, _: Context):

for record in sqs_event['Records']:
message_body = record['body']
message: dict[str, Any] = json.loads(message_body)
message = json.loads(message_body)
events.append(EventData(
name=message[0],
payload=message[1]
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8944,6 +8944,13 @@ react-textarea-autosize@^8.5.2:
use-composed-ref "^1.3.0"
use-latest "^1.2.1"

react-toastify@^10.0.4:
version "10.0.4"
resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-10.0.4.tgz#6ecdbbf923a07fc45850e69b0566efc7bf733283"
integrity sha512-etR3RgueY8pe88SA67wLm8rJmL1h+CLqUGHuAoNsseW35oTGJEri6eBTyaXnFKNQ80v/eO10hBYLgz036XRGgA==
dependencies:
clsx "^2.1.0"

[email protected]:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
Expand Down

0 comments on commit 192a28b

Please sign in to comment.