Spaces:
Sleeping
Sleeping
copilot-swe-agent[bot]
ArnavSingh76533
commited on
Commit
·
3d28d1e
1
Parent(s):
74486d1
Add Go Back button to NameModal for better UX
Browse filesCo-authored-by: ArnavSingh76533 <160649079+ArnavSingh76533@users.noreply.github.com>
components/modal/NameModal.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { FC, useState } from "react"
|
|
| 2 |
import Modal from "./Modal"
|
| 3 |
import InputText from "../input/InputText"
|
| 4 |
import Button from "../action/Button"
|
|
|
|
| 5 |
|
| 6 |
interface Props {
|
| 7 |
show: boolean
|
|
@@ -11,6 +12,7 @@ interface Props {
|
|
| 11 |
const NameModal: FC<Props> = ({ show, onSubmit }) => {
|
| 12 |
const [name, setName] = useState("")
|
| 13 |
const [error, setError] = useState("")
|
|
|
|
| 14 |
|
| 15 |
const handleSubmit = () => {
|
| 16 |
const trimmedName = name.trim()
|
|
@@ -29,6 +31,10 @@ const NameModal: FC<Props> = ({ show, onSubmit }) => {
|
|
| 29 |
onSubmit(trimmedName)
|
| 30 |
}
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
return (
|
| 33 |
<Modal title="Enter Your Name" show={show} close={() => {}}>
|
| 34 |
<div className="space-y-4">
|
|
@@ -54,7 +60,15 @@ const NameModal: FC<Props> = ({ show, onSubmit }) => {
|
|
| 54 |
<p className="text-red-500 text-sm mt-2">{error}</p>
|
| 55 |
)}
|
| 56 |
</div>
|
| 57 |
-
<div className="flex justify-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
<Button
|
| 59 |
tooltip="Continue with this name"
|
| 60 |
className="px-6 py-2.5 font-medium"
|
|
|
|
| 2 |
import Modal from "./Modal"
|
| 3 |
import InputText from "../input/InputText"
|
| 4 |
import Button from "../action/Button"
|
| 5 |
+
import { useRouter } from "next/router"
|
| 6 |
|
| 7 |
interface Props {
|
| 8 |
show: boolean
|
|
|
|
| 12 |
const NameModal: FC<Props> = ({ show, onSubmit }) => {
|
| 13 |
const [name, setName] = useState("")
|
| 14 |
const [error, setError] = useState("")
|
| 15 |
+
const router = useRouter()
|
| 16 |
|
| 17 |
const handleSubmit = () => {
|
| 18 |
const trimmedName = name.trim()
|
|
|
|
| 31 |
onSubmit(trimmedName)
|
| 32 |
}
|
| 33 |
|
| 34 |
+
const handleGoBack = () => {
|
| 35 |
+
router.push("/")
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
return (
|
| 39 |
<Modal title="Enter Your Name" show={show} close={() => {}}>
|
| 40 |
<div className="space-y-4">
|
|
|
|
| 60 |
<p className="text-red-500 text-sm mt-2">{error}</p>
|
| 61 |
)}
|
| 62 |
</div>
|
| 63 |
+
<div className="flex justify-between gap-3 pt-2">
|
| 64 |
+
<Button
|
| 65 |
+
tooltip="Go back to home"
|
| 66 |
+
className="px-4 py-2 font-medium"
|
| 67 |
+
actionClasses="bg-dark-700 hover:bg-dark-600 active:bg-dark-500"
|
| 68 |
+
onClick={handleGoBack}
|
| 69 |
+
>
|
| 70 |
+
Go Back
|
| 71 |
+
</Button>
|
| 72 |
<Button
|
| 73 |
tooltip="Continue with this name"
|
| 74 |
className="px-6 py-2.5 font-medium"
|