diff --git a/app/profiles/edit/[id]/page.tsx b/app/profiles/edit/[id]/page.tsx index bd0b53a..87f7bd0 100644 --- a/app/profiles/edit/[id]/page.tsx +++ b/app/profiles/edit/[id]/page.tsx @@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation' import { fetcher } from '@/app/lib' import useSWR from 'swr' -import LabelAndTextField from '@/app/components/form/Label'; +import LabelAndTextField from '@/app/components/form/LabelAndTextField'; import Submit from '@/app/components/form/Submit'; export default function ProfileEdit({params} :{params:{id:number}}) { @@ -23,7 +23,7 @@ export default function ProfileEdit({params} :{params:{id:number}}) { const [shockHsr, setShockHsr] = useState(''); const [shockLsr, setShockLsr] = useState(''); - const {data : profile,isLoading, error} = useSWR(`/api/profiles/${params.id}`,fetcher) + const {data : profile, isLoading, error} = useSWR(`/api/profiles/${params.id}`,fetcher) useEffect(()=>{ if(profile){ setName(profile.name) @@ -69,7 +69,7 @@ export default function ProfileEdit({params} :{params:{id:number}}) { const content = await res.json(); if(content.success>0) { - router.push('/profile'); + router.push('/profiles'); } } diff --git a/app/profiles/page.tsx b/app/profiles/page.tsx index 4cb7718..4a37623 100644 --- a/app/profiles/page.tsx +++ b/app/profiles/page.tsx @@ -20,19 +20,6 @@ export default function Profiles() { if (isLoading) return
Loading...
; if (!data) return null; - let delete_Profile = async (id: number) => { - const res = await fetch(`/api/profiles/${id}`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json' - }, - }); - const content = await res.json(); - if (content.success > 0) - { - setProfiles(profiles?.filter((profile:ProfileModel) => { return profile.id !== id })); - } - } return (
@@ -48,7 +35,7 @@ export default function Profiles() { { - profiles && profiles.map((item : ProfileModel)=>) + profiles && profiles.map((item : ProfileModel)=>) }
diff --git a/index.tsx b/index.tsx index c880492..f6f79f5 100644 --- a/index.tsx +++ b/index.tsx @@ -1,8 +1,5 @@ -import { Link } from 'components'; - -export default Home; - -function Home() { +import Link from "next/link"; +export default function Home() { return (

Next.js 10 - CRUD Example with React Hook Form