user eklleme
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter, useSearchParams } from "next/navigation"
|
||||||
import { useForm } from "react-hook-form"
|
import { useForm } from "react-hook-form"
|
||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import * as z from "zod"
|
import * as z from "zod"
|
||||||
@@ -77,6 +77,8 @@ interface UserFormProps {
|
|||||||
|
|
||||||
export function UserForm({ initialData, mode = "admin" }: UserFormProps) {
|
export function UserForm({ initialData, mode = "admin" }: UserFormProps) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const searchParams = useSearchParams()
|
||||||
|
const returnTo = searchParams.get("returnTo")
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
const form = useForm<UserFormValues>({
|
const form = useForm<UserFormValues>({
|
||||||
@@ -140,7 +142,10 @@ export function UserForm({ initialData, mode = "admin" }: UserFormProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
router.refresh()
|
router.refresh()
|
||||||
if (mode === "admin") {
|
router.refresh()
|
||||||
|
if (returnTo) {
|
||||||
|
router.push(returnTo)
|
||||||
|
} else if (mode === "admin") {
|
||||||
router.push("/dashboard/users")
|
router.push("/dashboard/users")
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ export function UsersTable({ users }: UsersTableProps) {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="flex items-center justify-between space-y-2">
|
<div className="flex items-center justify-between space-y-2">
|
||||||
<h3 className="text-lg font-medium">Kullanıcı Listesi</h3>
|
<h3 className="text-lg font-medium">Kullanıcı Listesi</h3>
|
||||||
{/*
|
<Link href="/dashboard/users/new?returnTo=/dashboard/settings">
|
||||||
<Link href="/dashboard/users/new">
|
|
||||||
<Button size="sm">Yeni Kullanıcı</Button>
|
<Button size="sm">Yeni Kullanıcı</Button>
|
||||||
</Link>
|
</Link>
|
||||||
*/}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
<Table>
|
||||||
|
|||||||
Reference in New Issue
Block a user