Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jgravois committed Jun 1, 2024
1 parent adf2f74 commit 8eac51b
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 134 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## setup

```sh
npm install
npm run setup
```sh
npm install
npm run setup
```

## development

```sh
npm run dev
open http://localhost:3000
```
```sh
npm run dev
open http://localhost:3000
```

This starts the app in development mode, rebuilding assets on file changes.

Expand Down
4 changes: 2 additions & 2 deletions app/models/reservation.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function getReservation({
}: Pick<Reservation, "id"> & {
userId: User["id"];
}) {
userId
userId;
return prisma.reservation.findFirst({
select: { id: true, start: true, end: true, court: true, user: true },
where: { id },
Expand All @@ -23,7 +23,7 @@ export function getReservations() {
start: true,
end: true,
court: true,
openPlay: true
openPlay: true,
},
});
}
Expand Down
3 changes: 1 addition & 2 deletions app/models/user.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ export async function createUser(email: User["email"], stytchId: string) {
return prisma.user.create({
data: {
email,
stytchId
stytchId,
},
});
}

export async function deleteUserByEmail(email: User["email"]) {
return prisma.user.delete({ where: { email } });
}

30 changes: 30 additions & 0 deletions app/routes/HeaderLeft.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Link } from "@remix-run/react";

export const HeaderLeft = () => (
<div className="header_left">
<Link to="/" className="h1">
Court dibs
</Link>
<h2 className="h2">Call dibs on one of our sportsball courts</h2>
<div className="header_illustration">
<div className="header_icon header_icon___pickleball">
<img
alt="pball"
src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/pickleball-solid.svg?v=1714837585684"
/>
</div>
<div className="header_icon header_icon___tennis">
<img
alt="tennis racquet"
src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/tennis-ball-solid.svg?v=1714837585529"
/>
</div>
<div className="header_icon header_icon___basketball">
<img
alt="bball"
src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/basketball-solid.svg?v=1714837585367"
/>
</div>
</div>
</div>
);
19 changes: 2 additions & 17 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getReservations } from "~/models/reservation.server";
import { getSession } from "~/session.server";
import { useOptionalUser } from "~/utils";

import { HeaderLeft } from "./HeaderLeft";
import { ReservationList, Rez } from "./ReservationList";

export const meta: MetaFunction = () => [{ title: "Court dibs" }];
Expand All @@ -31,23 +32,7 @@ export default function Index() {
<>
<header className="header">
<div className="header_content">
<div className="header_left">
<Link to="/" className="h1">
Court dibs
</Link>
<h2 className="h2">Call dibs on one of our sportsball courts</h2>
<div className="header_illustration">
<div className="header_icon header_icon___pickleball">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/pickleball-solid.svg?v=1714837585684" />
</div>
<div className="header_icon header_icon___tennis">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/tennis-ball-solid.svg?v=1714837585529" />
</div>
<div className="header_icon header_icon___basketball">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/basketball-solid.svg?v=1714837585367" />
</div>
</div>
</div>
<HeaderLeft />
<div className="header_right">
{user ? (
<>
Expand Down
21 changes: 3 additions & 18 deletions app/routes/magic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { MetaFunction } from "@remix-run/node";
import { Link } from "@remix-run/react";

import { HeaderLeft } from "./HeaderLeft";

export const meta: MetaFunction = () => [{ title: "Magic" }];

Expand All @@ -8,23 +9,7 @@ export default function Magic() {
<>
<header className="header">
<div className="header_content">
<div className="header_left">
<Link to="/" className="h1">
Court dibs
</Link>
<h2 className="h2">Call dibs on one of our sportsball courts</h2>
<div className="header_illustration">
<div className="header_icon header_icon___pickleball">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/pickleball-solid.svg?v=1714837585684" />
</div>
<div className="header_icon header_icon___tennis">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/tennis-ball-solid.svg?v=1714837585529" />
</div>
<div className="header_icon header_icon___basketball">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/basketball-solid.svg?v=1714837585367" />
</div>
</div>
</div>
<HeaderLeft />
<div className="header_right"></div>
</div>
</header>
Expand Down
54 changes: 0 additions & 54 deletions app/routes/reservations.tsx

This file was deleted.

22 changes: 4 additions & 18 deletions app/routes/start.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Loader } from "@googlemaps/js-api-loader";
import type { ActionFunctionArgs, MetaFunction } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Link, Form, useActionData, useSearchParams } from "@remix-run/react";
import { Form, useActionData, useSearchParams } from "@remix-run/react";
import { useEffect, useRef } from "react";
import invariant from "tiny-invariant";

import { createUser, getUserByEmail } from "~/models/user.server";
import { validateCoordinates, validateEmail } from "~/utils";

import { HeaderLeft } from "./HeaderLeft";

const HALF = "AIzaSyBI_vhCo";
const OTHER_HALF = "hiRS0dvt5Yk7sAJ-978T_mUwd8";

Expand Down Expand Up @@ -141,23 +143,7 @@ export default function Start() {
<>
<header className="header">
<div className="header_content">
<div className="header_left">
<Link to="/" className="h1">
Court dibs
</Link>
<h2 className="h2">Call dibs on one of our sportsball courts</h2>
<div className="header_illustration">
<div className="header_icon header_icon___pickleball">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/pickleball-solid.svg?v=1714837585684" />
</div>
<div className="header_icon header_icon___tennis">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/tennis-ball-solid.svg?v=1714837585529" />
</div>
<div className="header_icon header_icon___basketball">
<img src="https://cdn.glitch.global/5f00a93b-ae9c-4d9a-b9cf-472487408ff8/basketball-solid.svg?v=1714837585367" />
</div>
</div>
</div>
<HeaderLeft />
<div className="header_right"></div>
</div>
</header>
Expand Down
12 changes: 6 additions & 6 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function validateEmail(email: unknown): email is string {
}

const HOA_BOUNDARY = {
"coordinates": [
coordinates: [
[
[-117.68496384123713, 33.48204151023167],
[-117.68388255720208, 33.48203351752436],
Expand All @@ -88,11 +88,11 @@ const HOA_BOUNDARY = {
[-117.67842443970255, 33.48174668927008],
[-117.67732407755909, 33.48353464046207],
[-117.68435950172221, 33.48353464046207],
[-117.68496384123713, 33.48204151023167]
]
[-117.68496384123713, 33.48204151023167],
],
],
"type": "Polygon"
}
type: "Polygon",
};

export const validateCoordinates = (coordinates: [number, number]) =>
contains(HOA_BOUNDARY as GeoJSON, { type: 'Point', coordinates });
contains(HOA_BOUNDARY as GeoJSON, { type: "Point", coordinates });
10 changes: 6 additions & 4 deletions cypress/e2e/smoke.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ describe("smoke tests", () => {
cy.visit({
url: "/reservations/new",
qs: {
"day": "2024-04-24"
}
day: "2024-04-24",
},
});
cy.findByRole("combobox", { name: /What time are you starting?/i }).select('8:00 am');
cy.findByRole("button", { name: /Save/i }).click();
cy.findByRole("combobox", { name: /What time are you starting?/i }).select(
"8:00 am",
);
cy.findByRole("button", { name: /Reserve/i }).click();
});
});
2 changes: 1 addition & 1 deletion cypress/support/create-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { installGlobals } from "@remix-run/node";
import { parse } from "cookie";
import { v4 as uuid } from 'uuid';
import { v4 as uuid } from "uuid";

import { createUser } from "~/models/user.server";
import { createUserSession } from "~/session.server";
Expand Down
8 changes: 3 additions & 5 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ async function seed() {
await prisma.user.deleteMany().catch(() => {
// no worries if records dont exist yet
});
await prisma.reservation.deleteMany()

await prisma.reservation.deleteMany();

const user = await prisma.user.create({
data: {
email,
stytchId: 'user-test-56e85954-ddf4-49eb-be5e-3901b0267f62'

stytchId: "user-test-56e85954-ddf4-49eb-be5e-3901b0267f62",
},
});

Expand All @@ -28,7 +26,7 @@ async function seed() {
start: tomorrow,
end: addMinutes(tomorrow, 30),
userId: user.id,
court: 'pb' // 'pb' | 'bball' | '10s'
court: "pb", // 'pb' | 'bball' | '10s'
},
});

Expand Down

0 comments on commit 8eac51b

Please sign in to comment.