From 6b192aea3f9c6bdbe37876aaf95f6a516c8abc8f Mon Sep 17 00:00:00 2001 From: Emilio Heinzmann <103655828+emiliosheinz@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:27:32 -0300 Subject: [PATCH 1/4] Update README.md --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d5e12aa..2a338f8 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ # SOS Pet -![Banner with a white dog in the mud](./docs/images/banner.png) +SOS Pet is a system dedicated to connecting animals rescued from floods with available temporary shelters. We believe that in times of crisis, every life is important, and it is our mission to help ensure that animals at risk find a safe and welcoming place while awaiting their return home or a new beginning. -O SOS Pet é um sistema dedicado a conectar animais resgatados de enchentes com abrigos temporários disponíveis. Acreditamos que, em momentos de crise, cada vida é importante, e é nossa missão ajudar a garantir que animais em situação de risco encontrem um local seguro e acolhedor enquanto aguardam seu retorno ao lar ou um novo começo. +![Banner with a white dog in the mud](./docs/images/banner.png) -Com o SOS Pet, as pessoas que resgatam animais de enchentes podem rapidamente encontrar abrigos próximos com vagas disponíveis, obtendo informações cruciais, como capacidade, contato e localização. Nosso sistema permite que abrigos se cadastrem e atualizem suas informações, proporcionando uma base de dados confiável para os resgatadores. +With SOS Pet, people who rescue animals from floods can quickly find nearby shelters with available spaces, obtaining crucial information such as capacity, contact details, and location. Our system allows shelters to register and update their information, providing a reliable database for rescuers. -## Rodando o projeto localmente +## Local Development -1. Clone o repositório -1. Instale as dependências -1. Crie um arquivo `.env` baseando se no `.env.example` -1. Assegure se de preencher todas as variáveis ambiente. -1. Suba o baco de dados: `docker-compose up -d` -1. Rode as migrations: `npx prisma migrate dev` -1. Rode o projeto com o script `dev` disponível no `package.json` +1. Clone the repository +1. Install the dependencies +1. Create a `.env` file based on `.env.example` +1. Ensure all environment variables are filled in +1. Start the database with `docker-compose up -d` +1. Run the migrations with `npx prisma migrate dev` +1. Run the project using the dev script available in `package.json` From f7f0ce53cdf00c153e4f296acb55c78decad2244 Mon Sep 17 00:00:00 2001 From: Emilio Heinzmann Date: Sat, 22 Jun 2024 08:58:06 -0300 Subject: [PATCH 2/4] feat: improve signin loading state --- .../signin/_components/AuthenticationProviders.tsx | 12 ++++++++++-- src/app/signin/_components/EmailProviderForm.tsx | 8 ++------ src/app/signin/_components/OrSeparator.tsx | 10 ++++++++++ src/app/signin/page.tsx | 9 +++++---- 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 src/app/signin/_components/OrSeparator.tsx diff --git a/src/app/signin/_components/AuthenticationProviders.tsx b/src/app/signin/_components/AuthenticationProviders.tsx index 0ca0066..d128c50 100644 --- a/src/app/signin/_components/AuthenticationProviders.tsx +++ b/src/app/signin/_components/AuthenticationProviders.tsx @@ -4,9 +4,10 @@ import { getProviders } from "next-auth/react"; import { useEffect, useMemo, useState } from "react"; import { SignInProviderButton } from "./SignInProviderButton"; import { EmailProviderForm } from "./EmailProviderForm"; -import { Loader2 } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"; import { FiAlertTriangle } from "react-icons/fi"; +import { Skeleton } from "~/components/ui/skeleton"; +import { OrSeparator } from "./OrSeparator"; type GetProvidersState = "idle" | "loading" | "success" | "error"; @@ -53,7 +54,14 @@ export function AuthenticationProviders({ }, [providers]); if (["loading", "idle"].includes(getProvidersState)) { - return ; + return ( +
+ + + + +
+ ); } if (getProvidersState === "error") { diff --git a/src/app/signin/_components/EmailProviderForm.tsx b/src/app/signin/_components/EmailProviderForm.tsx index 83c3720..f6e142e 100644 --- a/src/app/signin/_components/EmailProviderForm.tsx +++ b/src/app/signin/_components/EmailProviderForm.tsx @@ -15,6 +15,7 @@ import { FormMessage, } from "~/components/ui/form"; import { Input } from "~/components/ui/input"; +import { OrSeparator } from "./OrSeparator"; const formSchema = z.object({ email: z.string().email("Por favor, insira um e-mail válido"), @@ -39,12 +40,7 @@ export function EmailProviderForm() { className="mt-5 flex flex-col gap-5" onSubmit={form.handleSubmit(onSubmit)} > -
- - ou - -
-
+ + + ou + +
+ + ); +} diff --git a/src/app/signin/page.tsx b/src/app/signin/page.tsx index 3ccace1..47a8795 100644 --- a/src/app/signin/page.tsx +++ b/src/app/signin/page.tsx @@ -1,18 +1,19 @@ +"use client"; import { redirect } from "next/navigation"; -import { getServerAuthSession } from "~/server/auth"; import Image from "next/image"; import { Suspense } from "react"; import { Loader2 } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"; import { FiAlertTriangle } from "react-icons/fi"; import { AuthenticationProviders } from "./_components/AuthenticationProviders"; +import { useSession } from "next-auth/react"; type SignInPageProps = { searchParams: Record; }; -export default async function SignInPage({ searchParams }: SignInPageProps) { - const session = await getServerAuthSession(); +export default function SignInPage({ searchParams }: SignInPageProps) { + const { data: session } = useSession(); if (session) { redirect(searchParams.callbackUrl ?? "/"); @@ -41,7 +42,7 @@ export default async function SignInPage({ searchParams }: SignInPageProps) { )} - + ); } From 69893dd28bc61c0e9367cd03c6f04ad3cf195700 Mon Sep 17 00:00:00 2001 From: Emilio Heinzmann Date: Sat, 22 Jun 2024 08:59:15 -0300 Subject: [PATCH 3/4] feat: make verify page static --- src/app/signin/verify/page.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/signin/verify/page.tsx b/src/app/signin/verify/page.tsx index ccf79ce..752616e 100644 --- a/src/app/signin/verify/page.tsx +++ b/src/app/signin/verify/page.tsx @@ -1,5 +1,8 @@ import { FaRegCheckCircle } from "react-icons/fa"; +export const dynamic = "force-static"; +export const revalidate = 60 * 60 * 24; + export default function SignInVerifyPage() { return ( <> From 277d45fd79888293b4503fa14e2ffd3ac3fa32b5 Mon Sep 17 00:00:00 2001 From: Emilio Heinzmann Date: Sat, 22 Jun 2024 09:22:31 -0300 Subject: [PATCH 4/4] feat: improve user shelters loading and performance --- src/app/user/shelters/create/page.tsx | 2 -- src/app/user/shelters/layout.tsx | 30 +++++++++++---------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/app/user/shelters/create/page.tsx b/src/app/user/shelters/create/page.tsx index 02eb8d2..51aafba 100644 --- a/src/app/user/shelters/create/page.tsx +++ b/src/app/user/shelters/create/page.tsx @@ -1,5 +1,3 @@ -"use client"; - import { FormEditRegister } from "~/app/user/shelters/_components"; export default function CreateShelterPage() { diff --git a/src/app/user/shelters/layout.tsx b/src/app/user/shelters/layout.tsx index fa257aa..53c4047 100644 --- a/src/app/user/shelters/layout.tsx +++ b/src/app/user/shelters/layout.tsx @@ -1,22 +1,16 @@ -import { Loader2 } from "lucide-react"; -import { redirect } from "next/navigation"; -import { Suspense, type PropsWithChildren } from "react"; -import { getServerAuthSession } from "~/server/auth"; +"use client"; + +import { useSession } from "next-auth/react"; +import { redirect, usePathname } from "next/navigation"; +import { type PropsWithChildren } from "react"; + +export default function ShelterLayout({ children }: PropsWithChildren) { + const pathname = usePathname(); + const { data: session } = useSession(); -export default async function ShelterLayout({ children }: PropsWithChildren) { - const session = await getServerAuthSession(); if (!session) { - redirect("/signin?callbackUrl=/user/shelters"); + redirect(`/signin?callbackUrl=${pathname}`); } - return ( - - - - } - > - {children} - - ); + + return children; }