From 2a2dd4f4e39caa43d71eef33fa8249a620d4d0a0 Mon Sep 17 00:00:00 2001 From: freddyheredia4 Date: Thu, 29 Jun 2023 16:44:03 -0500 Subject: [PATCH] Cambia a por link, quita html en layout anidado, quita /api de endpoint, agrega key en TBody, --- src/app/layout.tsx | 2 +- src/app/login/LoginForm.tsx | 3 +- src/app/page.tsx | 107 +------------------------- src/app/pedidos/cliente/[id]/page.tsx | 3 + src/app/pedidos/cliente/form.tsx | 21 ----- src/app/pedidos/cliente/page.tsx | 2 +- src/app/pedidos/layout.tsx | 14 ++-- src/app/pedidos/page.tsx | 9 +++ src/components/Navbar.tsx | 43 +++++------ src/components/Sidebar.tsx | 9 ++- src/components/table/TBody.tsx | 6 +- src/hooks/useFetchWithAuth.tsx | 2 +- 12 files changed, 55 insertions(+), 166 deletions(-) create mode 100644 src/app/pedidos/cliente/[id]/page.tsx delete mode 100644 src/app/pedidos/cliente/form.tsx create mode 100644 src/app/pedidos/page.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 431f783..828d36b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -19,7 +19,7 @@ export default function RootLayout({ -
+
{children}
diff --git a/src/app/login/LoginForm.tsx b/src/app/login/LoginForm.tsx index f77367c..9305652 100644 --- a/src/app/login/LoginForm.tsx +++ b/src/app/login/LoginForm.tsx @@ -2,6 +2,7 @@ import useBasicAuth from '@/hooks/useBasicAuth'; import Cookies from 'js-cookie'; +import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { FC } from 'react' import { useForm } from 'react-hook-form' @@ -43,7 +44,7 @@ export const LoginForm = () => { {...register("password")} />
diff --git a/src/app/page.tsx b/src/app/page.tsx index 7e80296..75a423f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,111 +3,10 @@ import Image from 'next/image' export default function Home() { return (
-
-

- Get started by editing  - src/app/page.tsx -

-
- - By{' '} - Vercel Logo - -
-
- -
- Next.js Logo -
- -
- -

- Docs{' '} - - -> - -

-

- Find in-depth information about Next.js features and API. -

-
- - -

- Learn{' '} - - -> - -

-

- Learn about Next.js in an interactive course with quizzes! -

-
- - -

- Templates{' '} - - -> - -

-

- Explore the Next.js 13 playground. -

-
- - -

- Deploy{' '} - - -> - -

-

- Instantly deploy your Next.js site to a shareable URL with Vercel. -

-
+
+ Home
+
) } diff --git a/src/app/pedidos/cliente/[id]/page.tsx b/src/app/pedidos/cliente/[id]/page.tsx new file mode 100644 index 0000000..6761c12 --- /dev/null +++ b/src/app/pedidos/cliente/[id]/page.tsx @@ -0,0 +1,3 @@ +export default function Page({ params }: { params: { id: string } }) { + return
My Post: {params.id}
+} \ No newline at end of file diff --git a/src/app/pedidos/cliente/form.tsx b/src/app/pedidos/cliente/form.tsx deleted file mode 100644 index 6656882..0000000 --- a/src/app/pedidos/cliente/form.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { NextPage } from 'next'; -import { useRouter } from 'next/router' -import { FC } from 'react' - -interface Props { -} - -const Form:NextPage = () => { - - const router = useRouter(); - const entidadId = router.query.id ? router.query.id as string : "0"; - - - return ( - <> - formulario - - ) -} - -export default Form \ No newline at end of file diff --git a/src/app/pedidos/cliente/page.tsx b/src/app/pedidos/cliente/page.tsx index 4cc50dc..6e47124 100644 --- a/src/app/pedidos/cliente/page.tsx +++ b/src/app/pedidos/cliente/page.tsx @@ -14,7 +14,7 @@ const ListadoCliente:FC = () => {
- +
diff --git a/src/app/pedidos/layout.tsx b/src/app/pedidos/layout.tsx index 4a4b2ad..3ef6da6 100644 --- a/src/app/pedidos/layout.tsx +++ b/src/app/pedidos/layout.tsx @@ -16,16 +16,16 @@ export default function RootLayout({ children: React.ReactNode }) { return ( - - - + + <> +
+ {children}
- - - - + + + ) } diff --git a/src/app/pedidos/page.tsx b/src/app/pedidos/page.tsx new file mode 100644 index 0000000..d0d0d74 --- /dev/null +++ b/src/app/pedidos/page.tsx @@ -0,0 +1,9 @@ +import Image from 'next/image' + +export default function Home() { + return ( +
+ Home +
+ ) +} \ No newline at end of file diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index d355c15..74a24dc 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -4,6 +4,7 @@ import { FC } from 'react' import Button from './Button' import Cookies from 'js-cookie' import { useRouter } from 'next/navigation'; +import Link from 'next/link'; interface Props { } @@ -22,34 +23,28 @@ const name:FC = () => { return ( <>
-
- daisyUI -
-
-
- +
+ daisyUI
-
-
) } diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 8684fcf..83983bf 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -7,7 +7,8 @@ interface Props { const Sidebar:FC = () => { return ( <> -
    +
    +
    • @@ -21,12 +22,14 @@ const Sidebar:FC = () => {
    • - + Pedido - +
    +
    + ) } diff --git a/src/components/table/TBody.tsx b/src/components/table/TBody.tsx index 8e3be76..14ecde6 100644 --- a/src/components/table/TBody.tsx +++ b/src/components/table/TBody.tsx @@ -33,14 +33,14 @@ const TBody:FC = ({columnas, endpoint}) => { Editar {columnas.map((columna)=> ( - {entidad[columna]} + {entidad[columna]} ))} ))} diff --git a/src/hooks/useFetchWithAuth.tsx b/src/hooks/useFetchWithAuth.tsx index 6fd99eb..94294ae 100644 --- a/src/hooks/useFetchWithAuth.tsx +++ b/src/hooks/useFetchWithAuth.tsx @@ -15,7 +15,7 @@ const useBasicAuth = async (endpoint:string) => { const token = Cookies.get("token")|| ""; - const baseUrl = process.env.API_URL + "/"+ endpoint + "/"; + const baseUrl = process.env.API_URL + "/api/"+ endpoint + "/"; const response = await fecher(baseUrl, token);