Skip to content

Commit

Permalink
Fix compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
steventux committed Feb 21, 2024
1 parent 82419e0 commit 75773cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
6 changes: 3 additions & 3 deletions app/profiles/edit/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}}) {
Expand All @@ -23,7 +23,7 @@ export default function ProfileEdit({params} :{params:{id:number}}) {
const [shockHsr, setShockHsr] = useState<string>('');
const [shockLsr, setShockLsr] = useState<string>('');

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)
Expand Down Expand Up @@ -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');
}

}
Expand Down
15 changes: 1 addition & 14 deletions app/profiles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ export default function Profiles() {
if (isLoading) return <div>Loading...</div>;
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 (
<div className="w-full max-w-7xl m-auto">
<table className="w-full border-collapse border border-slate-400">
Expand All @@ -48,7 +35,7 @@ export default function Profiles() {
</thead>
<tbody>
{
profiles && profiles.map((item : ProfileModel)=><Profile key={item.id} {...item} deleteProfile = {delete_Profile} />)
profiles && profiles.map((item : ProfileModel)=><Profile key={item.id} {...item} />)
}
<tr>
<td colSpan={6}>
Expand Down
7 changes: 2 additions & 5 deletions index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Link } from 'components';

export default Home;

function Home() {
import Link from "next/link";
export default function Home() {
return (
<div>
<h1>Next.js 10 - CRUD Example with React Hook Form</h1>
Expand Down

0 comments on commit 75773cc

Please sign in to comment.