From 1618cb12c5f1183d886c4323eff3d0bd3f226755 Mon Sep 17 00:00:00 2001 From: chuanyu Date: Tue, 17 Jan 2023 21:18:48 +0800 Subject: [PATCH] fix: remove redundant code --- .gitignore | 3 +++ components/DropDown.tsx | 8 ++++---- pages/index.tsx | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c5b834ee..4e16113e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ yarn-error.log* *.tsbuildinfo next-env.d.ts .env + +# idea +.idea diff --git a/components/DropDown.tsx b/components/DropDown.tsx index 5e0c8f00..d575aabe 100644 --- a/components/DropDown.tsx +++ b/components/DropDown.tsx @@ -10,14 +10,14 @@ function classNames(...classes: string[]) { return classes.filter(Boolean).join(" "); } -type vibeType = "Professional" | "Casual" | "Funny"; +export type VibeType = "Professional" | "Casual" | "Funny"; interface DropDownProps { - vibe: "Professional" | "Casual" | "Funny"; - setVibe: (vibe: vibeType) => void; + vibe: VibeType + setVibe: (vibe: VibeType) => void; } -let vibes: vibeType[] = ["Professional", "Casual", "Funny"]; +let vibes: VibeType[] = ["Professional", "Casual", "Funny"]; export default function DropDown({ vibe, setVibe }: DropDownProps) { return ( diff --git a/pages/index.tsx b/pages/index.tsx index 5419d456..ae341cf0 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -4,7 +4,7 @@ import Head from "next/head"; import Image from "next/image"; import { useState } from "react"; import { Toaster, toast } from "react-hot-toast"; -import DropDown from "../components/DropDown"; +import DropDown, { VibeType } from "../components/DropDown"; import Footer from "../components/Footer"; import Github from "../components/GitHub"; import Header from "../components/Header"; @@ -14,7 +14,7 @@ import ResizablePanel from "../components/ResizablePanel"; const Home: NextPage = () => { const [loading, setLoading] = useState(false); const [bio, setBio] = useState(""); - const [vibe, setVibe] = useState<"Professional" | "Casual" | "Funny">( + const [vibe, setVibe] = useState( "Professional" ); const [generatedBios, setGeneratedBios] = useState("");