parent
4f97c1ea6a
commit
0f133ca467
@ -0,0 +1,69 @@
|
||||
import { FC, useContext } from 'react'
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
const Dashboard:FC <Props> = () => {
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="stats shadow">
|
||||
|
||||
<div className="stat">
|
||||
<div className="stat-figure text-primary">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" className="inline-block w-8 h-8 stroke-current"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"></path></svg>
|
||||
</div>
|
||||
<div className="stat-title">Total Likes</div>
|
||||
<div className="stat-value text-primary">25.6K</div>
|
||||
<div className="stat-desc">21% more than last month</div>
|
||||
</div>
|
||||
|
||||
<div className="stat">
|
||||
<div className="stat-figure text-secondary">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" className="inline-block w-8 h-8 stroke-current"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg>
|
||||
</div>
|
||||
<div className="stat-title">Page Views</div>
|
||||
<div className="stat-value text-secondary">2.6M</div>
|
||||
<div className="stat-desc">21% more than last month</div>
|
||||
</div>
|
||||
|
||||
<div className="stat">
|
||||
<div className="stat-figure text-secondary">
|
||||
<div className="avatar online">
|
||||
<div className="w-16 rounded-full">
|
||||
<img src="/images/stock/photo-1534528741775-53994a69daeb.jpg" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="stat-value">86%</div>
|
||||
<div className="stat-title">Tasks done</div>
|
||||
<div className="stat-desc text-secondary">31 tasks remaining</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div className="carousel w-full">
|
||||
<div id="item1" className="carousel-item w-full">
|
||||
<img src="https://daisyui.com/images/stock/photo-1625726411847-8cbb60cc71e6.jpg" className="w-full" />
|
||||
</div>
|
||||
<div id="item2" className="carousel-item w-full">
|
||||
<img src="/images/stock/photo-1609621838510-5ad474b7d25d.jpg" className="w-full" />
|
||||
</div>
|
||||
<div id="item3" className="carousel-item w-full">
|
||||
<img src="/images/stock/photo-1414694762283-acccc27bca85.jpg" className="w-full" />
|
||||
</div>
|
||||
<div id="item4" className="carousel-item w-full">
|
||||
<img src="/images/stock/photo-1665553365602-b2fb8e5d1707.jpg" className="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-center w-full py-2 gap-2">
|
||||
<a href="#item1" className="btn btn-xs">1</a>
|
||||
<a href="#item2" className="btn btn-xs">2</a>
|
||||
<a href="#item3" className="btn btn-xs">3</a>
|
||||
<a href="#item4" className="btn btn-xs">4</a>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Dashboard;
|
@ -0,0 +1,72 @@
|
||||
'use client'
|
||||
|
||||
import { FC } from 'react'
|
||||
import { useBasicAuth } from 'hooks/useBasicAuth';
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useForm } from 'react-hook-form';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
export const Form:FC <Props> = () => {
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const { register, handleSubmit, getValues, formState: { errors } } = useForm();
|
||||
|
||||
const onSubmit = async (entity: any) => {
|
||||
console.log("on submit")
|
||||
try {
|
||||
|
||||
|
||||
const { data, error } = await useBasicAuth("/login",getValues("user"),getValues("password") );
|
||||
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
if (data && data.length>0){
|
||||
Cookies.set("token",data);
|
||||
router.push("/dashboard");
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Post error:");
|
||||
console.table(e);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="form-control">
|
||||
<label className="label">
|
||||
<span className="label-text">Email</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Usuario"
|
||||
className="input input-bordered"
|
||||
{...register("user")}/>
|
||||
</div>
|
||||
<div className="form-control">
|
||||
<label className="label">
|
||||
<span className="label-text">Password</span>
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="password"
|
||||
className="input input-bordered"
|
||||
{...register("password")}
|
||||
/>
|
||||
<label className="label">
|
||||
<a href="#" className="label-text-alt link link-hover">Forgot password?</a>
|
||||
</label>
|
||||
</div>
|
||||
<div className="form-control mt-6">
|
||||
<button type="submit" className="btn btn-primary">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
import { Form } from "./form";
|
||||
|
||||
|
||||
const login = () => {
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<div className="hero min-h-screen bg-base-200">
|
||||
<div className="hero-content flex-col lg:flex-row-reverse">
|
||||
<div className="text-center lg:text-left">
|
||||
<h1 className="text-5xl font-bold">Login now!</h1>
|
||||
<p className="py-6">Provident cupiditate voluptatem et in. Quaerat fugiat ut assumenda excepturi exercitationem quasi. In deleniti eaque aut repudiandae et a id nisi.</p>
|
||||
</div>
|
||||
<div className="card flex-shrink-0 w-full max-w-sm shadow-2xl bg-base-100">
|
||||
<div className="card-body">
|
||||
<Form/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default login;
|
@ -1,113 +1,19 @@
|
||||
import Image from 'next/image'
|
||||
|
||||
export default function Home() {
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-between p-24">
|
||||
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
|
||||
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
|
||||
Get started by editing
|
||||
<code className="font-mono font-bold">app/page.tsx</code>
|
||||
</p>
|
||||
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
|
||||
<a
|
||||
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
|
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
By{' '}
|
||||
<Image
|
||||
src="/vercel.svg"
|
||||
alt="Vercel Logo"
|
||||
className="dark:invert"
|
||||
width={100}
|
||||
height={24}
|
||||
priority
|
||||
/>
|
||||
</a>
|
||||
<div className="hero min-h-screen bg-base-200">
|
||||
<div className="hero-content flex-col lg:flex-row">
|
||||
<Image src="/logo.png" width={"320"} height={"320"} className="max-w-sm rounded-lg shadow-2xl" alt={'Logotipo Sistemaagil'} />
|
||||
<div>
|
||||
<h1 className="text-5xl font-bold">Box Office News!</h1>
|
||||
<p className="py-6">Provident cupiditate voluptatem et in. Quaerat fugiat ut assumenda excepturi exercitationem quasi. In deleniti eaque aut repudiandae et a id nisi.</p>
|
||||
<button className="btn btn-primary">Get Started</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px]">
|
||||
<Image
|
||||
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js Logo"
|
||||
width={180}
|
||||
height={37}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mb-32 grid text-center lg:mb-0 lg:grid-cols-4 lg:text-left">
|
||||
<a
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Docs{' '}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Find in-depth information about Next.js features and API.
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800 hover:dark:bg-opacity-30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Learn{' '}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Learn about Next.js in an interactive course with quizzes!
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Templates{' '}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Explore the Next.js 13 playground.
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Deploy{' '}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Instantly deploy your Next.js site to a shareable URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
import { FC } from 'react'
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
export const Input:FC <Props> = () => {
|
||||
return (
|
||||
<>
|
||||
<input/>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export default function Button() {
|
||||
return <button>Click me</button>
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import {Buffer} from 'buffer';
|
||||
|
||||
const fecher = async (url: string, token: string) => {
|
||||
return await fetch(url, {
|
||||
method: 'POST',
|
||||
|
||||
headers: {
|
||||
'Authorization' :token
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const useBasicAuth = async (endpoint: string, username:string, password: string) => {
|
||||
//url= process.env.API_URL+url;
|
||||
const token = 'Basic '+ Buffer.from(username + ':' + password).toString('base64');
|
||||
let data;
|
||||
let error;
|
||||
try{
|
||||
const url = process.env.API_URL + endpoint;
|
||||
|
||||
const response = await fecher(url, token)
|
||||
|
||||
if (response.ok){
|
||||
const token = response.headers.get('Authorization') ;
|
||||
if (token){
|
||||
data = token.replaceAll("Basic ","")
|
||||
}
|
||||
}else {
|
||||
const trace = await response.json();
|
||||
error = "Servidor: "+ trace.message;
|
||||
}
|
||||
}catch (trace){
|
||||
error = "Cliente: "+trace;
|
||||
}
|
||||
return {
|
||||
data,
|
||||
error
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
|
||||
import { NextResponse } from 'next/server'
|
||||
import type { NextRequest } from 'next/server'
|
||||
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
|
||||
const token = request.cookies.get('token')?.value
|
||||
console.log("token"+token)
|
||||
if (!token) {
|
||||
return NextResponse.rewrite(new URL('/login', request.url))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ['/((?!api|_next/static|_next/image|favicon.ico|login).*)',],
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {}
|
||||
const nextConfig = {
|
||||
env: {
|
||||
API_URL: 'http://localhost:8081',
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
|
After Width: | Height: | Size: 80 KiB |
Loading…
Reference in new issue