Skip to content

Commit

Permalink
Merge pull request #74 from emiliosheinz/dev
Browse files Browse the repository at this point in the history
chore: 🚀 release
  • Loading branch information
emiliosheinz authored Jun 23, 2024
2 parents 8d0bc46 + 240cc3b commit 9d8cc8a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 43 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
12 changes: 10 additions & 2 deletions src/app/signin/_components/AuthenticationProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -53,7 +54,14 @@ export function AuthenticationProviders({
}, [providers]);

if (["loading", "idle"].includes(getProvidersState)) {
return <Loader2 className="mt-10 size-8 animate-spin" />;
return (
<div className="mt-5 flex w-full flex-col gap-5">
<Skeleton className="h-10 w-full" />
<OrSeparator />
<Skeleton className="h-10 w-full" />
<Skeleton className="h-10 w-full" />
</div>
);
}

if (getProvidersState === "error") {
Expand Down
8 changes: 2 additions & 6 deletions src/app/signin/_components/EmailProviderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -39,12 +40,7 @@ export function EmailProviderForm() {
className="mt-5 flex flex-col gap-5"
onSubmit={form.handleSubmit(onSubmit)}
>
<div className="relative my-5">
<span className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform bg-white pb-1 text-lg tracking-widest text-neutral-500">
ou
</span>
<hr />
</div>
<OrSeparator />
<FormField
name="email"
control={form.control}
Expand Down
10 changes: 10 additions & 0 deletions src/app/signin/_components/OrSeparator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function OrSeparator() {
return (
<div className="relative my-5">
<span className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform bg-white pb-1 text-lg tracking-widest text-neutral-500">
ou
</span>
<hr />
</div>
);
}
9 changes: 5 additions & 4 deletions src/app/signin/page.tsx
Original file line number Diff line number Diff line change
@@ -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<string, string>;
};

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 ?? "/");
Expand Down Expand Up @@ -41,7 +42,7 @@ export default async function SignInPage({ searchParams }: SignInPageProps) {
</AlertDescription>
</Alert>
)}
<AuthenticationProviders />
<AuthenticationProviders callbackUrl={searchParams.callbackUrl} />
</Suspense>
);
}
3 changes: 3 additions & 0 deletions src/app/signin/verify/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
Expand Down
2 changes: 0 additions & 2 deletions src/app/user/shelters/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { FormEditRegister } from "~/app/user/shelters/_components";

export default function CreateShelterPage() {
Expand Down
30 changes: 12 additions & 18 deletions src/app/user/shelters/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Suspense
fallback={
<div className="flex w-full justify-center pt-28">
<Loader2 className="size-8 animate-spin" />
</div>
}
>
{children}
</Suspense>
);

return children;
}

0 comments on commit 9d8cc8a

Please sign in to comment.