Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade make stable #35

Merged
merged 131 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
620b96e
Update README.md
danielvanc Mar 20, 2022
64747ed
Merge branch 'main' of github.com:danielvanc/bookworm
danielvanc Mar 20, 2022
36dfbc4
updated package.json. added gh action
danielvanc Mar 20, 2022
18af681
updated readme
danielvanc Mar 20, 2022
75c4108
updated README. fixed validation bits
danielvanc Mar 20, 2022
e17a60c
chore: added husky
danielvanc Mar 20, 2022
6b3da54
chore: installed headless-ui/react
danielvanc Mar 20, 2022
3a2a679
feat: added 404 handler
danielvanc Mar 20, 2022
fc23e82
feat: altered logged in/out routes
danielvanc Mar 20, 2022
af74a22
feat: created basic skeleton
danielvanc Mar 21, 2022
d3baa15
feat: added more nested routing
danielvanc Mar 24, 2022
3144227
feat: fetched books for discover - latest
danielvanc Mar 25, 2022
bb935e9
chore: migrate init
danielvanc Mar 25, 2022
2953f6c
feat: Added books table. Refactored HR scroll. Set up prisma client w…
danielvanc Mar 25, 2022
30ec6a0
fix: removed action from auth form
danielvanc Mar 28, 2022
c6ed19c
feat: introduced google books api for overview
danielvanc Apr 7, 2022
01850d9
feat: re-moved user auth to root
danielvanc Apr 7, 2022
ab53833
chore: upgraded deps
danielvanc Apr 8, 2022
bbed30e
feat: update prisma connection
danielvanc Apr 8, 2022
a4d02be
refactor: some tidying up
danielvanc Apr 9, 2022
5fb1e27
feat: changed db query for finding users bookmarks
danielvanc Apr 9, 2022
1e0f176
feat: added some disabled states for bookmarking
danielvanc Apr 10, 2022
0bba3d2
feat: added ability to remove bookmark
danielvanc Apr 10, 2022
79d4f42
Update README.md
danielvanc Apr 11, 2022
0a8fe3d
refactor: small tidy up in overview action handler
danielvanc Apr 11, 2022
72bafe0
feat: preview list book item tidy up
danielvanc Apr 11, 2022
4c205d6
feat: slight tweak to prisma set up
danielvanc Apr 11, 2022
2f7c417
feat: slightly improved adding/removing bmarks
danielvanc Apr 11, 2022
33dcb8d
feat: styling and error handling improvements to list items
danielvanc Apr 11, 2022
12ba3f6
feat(overview-list): initial logic of bookmark list
danielvanc Apr 11, 2022
189fa00
refactor: slight tidy up
danielvanc Apr 11, 2022
0b638c1
refactor: some tidying up of types etc
danielvanc Apr 13, 2022
223954d
feat: added prefetching for each book item
danielvanc Apr 13, 2022
6f36d03
refactor: more tidying up
danielvanc Apr 13, 2022
1c3e9ae
chore: moved api urls to config. more housekeeping
danielvanc Apr 13, 2022
33dac5f
updated remix deps
danielvanc Apr 20, 2022
2bc861b
chore: ran migration script
danielvanc Apr 20, 2022
6db561d
chore: upgraded deps
danielvanc Apr 21, 2022
533723c
feat: added ability to mark as reading and read
danielvanc Apr 22, 2022
9a31e7e
feat: added a sprinkling of styling to preview book items
danielvanc Apr 24, 2022
498293f
feat: reduced queries + moved 'reading' to sidebar
danielvanc Apr 26, 2022
8827946
feat: initial header set up
danielvanc Apr 26, 2022
d9ac7f0
feat: small tweaks to header elements
danielvanc Apr 26, 2022
06e3fa3
feat(sidebar): added menu and updates to reading
danielvanc Apr 26, 2022
18f14d2
feat(bookmarks): added initial page
danielvanc Apr 28, 2022
50208ec
feat(reading): added initial implementation
danielvanc Apr 28, 2022
527ae71
feat(read): added initiial implementation
danielvanc Apr 28, 2022
3e7d6d7
feat(discover): added initial implementation
danielvanc Apr 28, 2022
746da09
feat(sidebar): added prefetch intent for overview
danielvanc Apr 28, 2022
30001be
feat(entry-page): added initial implementation
danielvanc Apr 29, 2022
46adc9f
feat(sidebar): added sub page active styles
danielvanc Apr 29, 2022
60cad0e
chore: reverted to using jest
danielvanc May 4, 2022
aad6341
chore: updated test config
danielvanc Jul 14, 2022
c2d36b7
chore: upgraded remix
danielvanc Jul 14, 2022
b472829
chore: updated to use new type safety
danielvanc Jul 14, 2022
5097ffb
chore(scripts): added cs script and config
danielvanc Jul 15, 2022
f592132
chore(auth): upgraded supabase dependencies+auth
danielvanc Jul 23, 2022
e2e6e4b
chore(prisma): upgraded to latest version
danielvanc Jul 23, 2022
5e4a65c
feat(dashboard): re-skinned + other improvements
danielvanc Sep 19, 2022
79eaea8
feat(notifications): added initial implementation
danielvanc Oct 1, 2022
5bd0d1c
chore: upgraded remix deps
danielvanc Oct 1, 2022
443045a
feat(search): temporarily removed
danielvanc Oct 1, 2022
07338ad
feat(loading-ui): added skeleton for home
danielvanc Oct 2, 2022
7ff2f61
feat(preview-book-item): dont show if no data
danielvanc Oct 2, 2022
321b445
feat(preview-book-item): altered column widths
danielvanc Oct 2, 2022
9413f53
feat(home): provided catch boundary for fetching books
danielvanc Oct 2, 2022
85d6da4
feat(marketing): reskinned landing page
danielvanc Oct 9, 2022
df71941
fix(notification): data load bug on login
danielvanc Oct 9, 2022
a315a56
feat(latest-books): added some basic redis caching
danielvanc Oct 9, 2022
2cb7518
chore: set up upstash
danielvanc Oct 9, 2022
09a461c
chore: changed env vars for upstash
danielvanc Oct 9, 2022
c9d628b
chore: changed redis package
danielvanc Oct 9, 2022
a2e7119
test: added initial tests for login screen
danielvanc Oct 16, 2022
89f11c2
test(loggedout): test login route loader returns 200
danielvanc Oct 23, 2022
fb5ed86
test(login): added todos
danielvanc Oct 23, 2022
063363c
test(home): started adding tests for book components
danielvanc Oct 23, 2022
a1cd80e
feat(app): added vercel analytics
danielvanc Oct 30, 2022
16007ad
feat(app): added vercel analytics
danielvanc Oct 30, 2022
5a1599a
feat(app): added vercel analytics
danielvanc Oct 30, 2022
1163e3b
chore: upgraded remix
danielvanc Oct 31, 2022
38a4857
chore: switched to yarn
danielvanc Nov 2, 2022
b5986b7
refactor(auth): moved to supabase auth-helpers
danielvanc Nov 11, 2022
59c437b
feat(auth): added remaining social logins
danielvanc Nov 11, 2022
b53a853
feat(auth): added login with magic link
danielvanc Nov 12, 2022
2c8b077
feat: added spotify signin
danielvanc Nov 12, 2022
ecb395f
fix: amend typo
danielvanc Nov 12, 2022
51e5507
Merge pull request #3 from danielvanc/refactor-auth
danielvanc Nov 12, 2022
55d56d3
Create SECURITY.md
danielvanc Nov 12, 2022
6f40f84
Create LICENSE.md
danielvanc Nov 12, 2022
e35ed76
feat(auth): check for session on homepage
danielvanc Nov 13, 2022
4e25999
chore: updated tailwind dep
danielvanc Nov 14, 2022
1d6a008
chore: updated heroicons dep
danielvanc Nov 14, 2022
adf65be
fix: corrected problem with getting the users id
danielvanc Nov 14, 2022
480f6e4
feat: updated prisma client
danielvanc Nov 26, 2022
252c7b3
feat(book-page): added initial styling+markup
danielvanc Dec 13, 2022
032ee01
feat(book-page): styling tweaks
danielvanc Dec 13, 2022
92846fa
feat(book-page): add extended book meta
danielvanc Dec 13, 2022
aa52433
feat(book-page): alignment tweaks
danielvanc Dec 13, 2022
1ae04d4
chore: dep updates and minor tweaks
danielvanc Dec 14, 2022
4de7a41
feat(home): fixed skeleton loading glitch
danielvanc Dec 14, 2022
7bbb808
chore: migrated to built in tailwindcss support
danielvanc Feb 19, 2023
64512c3
chore: removed redundant code
danielvanc Feb 19, 2023
db2afa9
chore: removed gitignore for tailwindcss
danielvanc Feb 19, 2023
d7ee377
test(discover): added render list of books test
danielvanc Mar 27, 2023
f03e065
chore: moved from jest to vitest
danielvanc Mar 28, 2023
8d1270a
Update README.md
danielvanc Mar 28, 2023
8f56d9e
chore: moved from cypress to playwright
danielvanc Mar 28, 2023
3762314
chore: tidy up of test locations
danielvanc Mar 28, 2023
229af65
chore: removed postcss
danielvanc Mar 28, 2023
6983c76
chore: added render util and used useNavigation
danielvanc Mar 28, 2023
a53e4f5
test(login): loader and response checks
danielvanc Mar 28, 2023
db3ceef
chore: removed cypress json
danielvanc Mar 28, 2023
df49dd9
chore: added vitest ui and moved mocks dir
danielvanc Mar 29, 2023
bf8fc8e
test: added unit tests gh action
danielvanc Mar 30, 2023
bf07ca4
test: added caching to runner
danielvanc Mar 30, 2023
b6458c9
Merge pull request #32 from danielvanc/add-caching-to-runner
danielvanc Mar 30, 2023
5b95937
feat: wip prep move to v2
danielvanc May 8, 2023
b7a3af0
feat: prepped for remix v2 + updated auth strategy
danielvanc May 21, 2023
cf9c5d5
chore: fixes
danielvanc May 21, 2023
a579534
chore: add prisma vercel fix
danielvanc May 21, 2023
9d83e19
Merge pull request #33 from danielvanc/prep_v2_remix
danielvanc May 21, 2023
d993687
chore: upgraded remix
danielvanc Jul 1, 2023
549dbc8
fix: resolved saving bugs
danielvanc Sep 16, 2023
9eeae6c
refactor: moved auth area to dash
danielvanc Sep 16, 2023
21212a6
chore: add build to gitignore
danielvanc Sep 16, 2023
7428fe0
Merge branch 'main' into upgrade_make_updates_stable
danielvanc Sep 16, 2023
15f4809
chore: updated esbuild
danielvanc Sep 16, 2023
948e725
chore: upgraded to v2
danielvanc Sep 17, 2023
0ab2ebf
chore: move to flat routing
danielvanc Sep 17, 2023
34fbccd
fix: resolve index route issue
danielvanc Oct 31, 2023
ae0894b
chore: remove build files
danielvanc Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ api/_build
tests/e2e/example.spec.ts

/app/dump.rdb

build/
4 changes: 2 additions & 2 deletions app/components/BookItemFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export default function BookItemFooter({
}: Props) {
const statusFetcher = useFetcher();
const isIdle = statusFetcher.state === "idle";
const hasErrors = statusFetcher.data?.error;
const hasErrors = statusFetcher.formData?.get("errors");
const failedUpdate = hasErrors && isIdle;
const action = statusFetcher.data?.action;
const action = statusFetcher.formAction;
const subData = statusFetcher.formData;
const ErrorMessage = "Error, please retry";

Expand Down
18 changes: 10 additions & 8 deletions app/components/LoginWithEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Form, useActionData, useNavigation } from "@remix-run/react";
import { TextField } from "./Fields";
import { ActionFunctionArgs } from "@remix-run/node";
import { action } from "~/routes/login";

export default function LoginWithEmail() {
const data = useActionData();
const errors = useActionData();
const data = useActionData<typeof action>();
console.log("data", data);

const errors = useActionData<typeof action>();
console.log("errors", errors);
const transition = useNavigation();
const isSubmitting = transition.state === "submitting";

Expand All @@ -13,7 +18,7 @@ export default function LoginWithEmail() {
action="/login"
className="mt-10 grid grid-cols-1 gap-y-8"
>
{!errors?.email && data ? (
{data ? (
<p>Success! Go ahead and click the link in your email!</p>
) : (
<>
Expand All @@ -24,16 +29,13 @@ export default function LoginWithEmail() {
type="email"
autoComplete="email"
required
className={`${
data?.errors?.email ? "border-red-300 text-red-900" : ""
}`}
/>
{data?.errors?.email && <p>Please submit a valid email address</p>}

<div>
<button
type="submit"
disabled={isSubmitting}
className="group inline-flex w-full items-center justify-center rounded-full bg-rosyWorm py-2 px-4 text-sm font-semibold text-white focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 disabled:bg-slate-600"
className="bg-rosyWorm group inline-flex w-full items-center justify-center rounded-full px-4 py-2 text-sm font-semibold text-white focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 disabled:bg-slate-600"
>
{isSubmitting ? "Requesting a login link..." : null}
{!isSubmitting ? (
Expand Down
6 changes: 3 additions & 3 deletions app/components/PreviewBookItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function PreviewBookItem({

return (
<li
key={book.id}
key={book.book_id}
className="flex flex-col divide-y divide-gray-200 rounded-lg bg-white shadow"
>
<div className="flex flex-col items-start p-8 md:flex-row">
Expand All @@ -30,10 +30,10 @@ export default function PreviewBookItem({
/>
</div>

<div className="w-4/5 py-5 md:py-0 md:px-10">
<div className="w-4/5 py-5 md:px-10 md:py-0">
<h3 className="text-xl font-black text-gray-700">{book.title}</h3>
<dl className="mt-1 flex flex-grow flex-col justify-between">
<dd className="mt-1 mb-3">
<dd className="mb-3 mt-1">
<span className="rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-800">
{/* TODO: Replace with book genre */}
{book.title}
Expand Down
30 changes: 16 additions & 14 deletions app/components/TabNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ export default function TabNavigation({ tabs, optimisticPath }: Props) {
className={({ isActive }: { isActive: boolean }) =>
appendBorders(isActive, tabIdx)
}
end={tab.name === "Discover"}
>
{({ isActive }) => (
<>
<span>{tab.name}</span>
<span
aria-hidden="true"
className={
(isActive && !optimisticPath) ||
(optimisticPath && optimisticPath === `/${tab.href}`)
? activeLinkSpanStyles
: `bg-transparent ${defaultSpanStyles}`
}
/>
</>
)}
{({ isActive }) => {
return (
<>
<span>{tab.name}</span>
<span
aria-hidden="true"
className={
isActive
? activeLinkSpanStyles
: `bg-transparent ${defaultSpanStyles}`
}
/>
</>
);
}}
</NavLink>
))}
</nav>
Expand Down
56 changes: 31 additions & 25 deletions app/models/books.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const initialBookData = (data: initialBook) => ({
title: data.volumeInfo?.title,
description: data.volumeInfo?.description,
image: data.volumeInfo?.imageLinks?.thumbnail,
link: data.volumeInfo?.canonicalVolumeLink,
link: data.volumeInfo?.previewLink,
authors: data.volumeInfo?.authors,
publisher: data.volumeInfo?.publisher,
publishedDate: data.volumeInfo?.publishedDate,
Expand All @@ -20,13 +20,13 @@ const initialBookData = (data: initialBook) => ({
price: data.saleInfo?.retailPrice?.amount,
});

export function createBookmark(
export async function createBookmark(
id: books["id"],
book_id: books["book_id"],
user_id: books["user_id"]
) {
if (!id) {
return prisma.books.create({
return await prisma.books.create({
data: {
user_id,
book_id,
Expand All @@ -38,7 +38,7 @@ export function createBookmark(
});
}

return prisma.books.update({
return await prisma.books.update({
where: {
id,
},
Expand All @@ -48,24 +48,24 @@ export function createBookmark(
});
}

export function removeBookmark(id: books["id"]) {
return prisma.books.update({
export async function removeBookmark(book_id: books["id"]) {
return await prisma.books.update({
where: {
id,
id: book_id,
},
data: {
bookmarked: false,
},
});
}

export function markAsRead(
export async function markAsRead(
id: books["id"],
book_id: books["book_id"],
user_id: books["user_id"]
) {
if (!id) {
return prisma.books.create({
return await prisma.books.create({
data: {
user_id,
book_id,
Expand All @@ -77,7 +77,7 @@ export function markAsRead(
});
}

return prisma.books.upsert({
return await prisma.books.upsert({
create: {
user_id,
book_id,
Expand All @@ -95,8 +95,8 @@ export function markAsRead(
},
});
}
export function markAsNotRead(id: books["id"]) {
return prisma.books.update({
export async function markAsNotRead(id: books["id"]) {
return await prisma.books.update({
where: {
id,
},
Expand All @@ -106,13 +106,13 @@ export function markAsNotRead(id: books["id"]) {
});
}

export function markAsReading(
export async function markAsReading(
id: books["id"],
book_id: books["book_id"],
user_id: books["user_id"]
) {
if (!id) {
return prisma.books.create({
return await prisma.books.create({
data: {
user_id,
book_id,
Expand All @@ -124,7 +124,7 @@ export function markAsReading(
});
}

return prisma.books.upsert({
return await prisma.books.upsert({
create: {
user_id,
book_id,
Expand All @@ -143,8 +143,8 @@ export function markAsReading(
});
}

export function markAsNotReading(id: books["id"]) {
return prisma.books.update({
export async function markAsNotReading(id: books["id"]) {
return await prisma.books.update({
where: {
id,
},
Expand All @@ -168,12 +168,14 @@ export async function getAllRead(id: string) {
bookIds?.books
?.filter((book) => book.read || book.reading)
.map((book) => {
const { id: buid, book_id: id, reading, read, bookmarked } = book;
return { buid, id, reading, read, bookmarked };
const { id: buid, book_id, reading, read, bookmarked } = book;
return { buid, book_id, reading, read, bookmarked };
}) || [];

if (usersBookmarks.length) {
bookmarks = await getAllBooksmarkData(usersBookmarks);
}

return { userId: id, bookmarks };
}

Expand All @@ -191,9 +193,10 @@ export async function getBookmarks(id: string) {
bookIds?.books
?.filter((book) => book.bookmarked)
.map((book) => {
const { id: buid, book_id: id, reading, read, bookmarked } = book;
return { buid, id, reading, read, bookmarked };
const { id: buid, book_id, reading, read, bookmarked } = book;
return { buid, book_id, reading, read, bookmarked };
}) || [];

if (usersBookmarks.length) {
bookmarks = await getAllBooksmarkData(usersBookmarks);
}
Expand All @@ -208,8 +211,8 @@ export async function getUsersBookmarks(user_id: books["user_id"]) {
});
const usersBookmarks =
bookIds?.map((book) => {
const { id: buid, book_id: id, reading, read, bookmarked } = book;
return { buid, id, reading, read, bookmarked };
const { id: buid, book_id, reading, read, bookmarked } = book;
return { buid, book_id, reading, read, bookmarked };
}) || [];
return usersBookmarks;
}
Expand Down Expand Up @@ -240,10 +243,13 @@ export async function getLatestBooks(userId: books["user_id"], total: number) {
latestBooks = [...allBooks, { responseTime: `${t1 - t0}ms` }];
saveToRedis("home-latest-books", latestBooks);
}

const bookmarkIds = await getUsersBookmarks(userId);

if (bookmarkIds.length) {
usersBookmarks = await getAllBooksmarkData(bookmarkIds);
}

return { books: latestBooks, usersBookmarks };
}

Expand All @@ -257,9 +263,9 @@ export async function fetchBookInfo(bookId: string): Promise<Book> {
}

async function getAllBooksmarkData(bookmarkIds: usersBookmarks[]) {
return Promise.all(
return await Promise.all(
bookmarkIds.map(async (book: books) => {
const data = await fetchBookInfo(book.id);
const data = await fetchBookInfo(book.book_id);
data.buid = book.buid;
data.read = book.read;
data.reading = book.reading;
Expand Down
8 changes: 5 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { json, type LoaderArgs } from "@remix-run/node";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import {
Links,
LiveReload,
Expand All @@ -14,6 +15,7 @@ import tailwindStyles from "~/tailwind.css";
import { getMetaInfo } from "~/utils/seo";
import { getSession } from "./auth/auth.server";
import { useWatchSession } from "./auth/client";
import { Session } from "@supabase/auth-helpers-remix";

export function meta() {
return [
Expand All @@ -35,7 +37,7 @@ export function links() {
];
}

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
const { SUPABASE_URL, SUPABASE_KEY, NODE_ENV } = process.env;
const { session, error, response } = await getSession(request);

Expand All @@ -53,7 +55,7 @@ export const loader = async ({ request }: LoaderArgs) => {

export default function App() {
const { env, session } = useLoaderData<typeof loader>();
const context = useWatchSession(session);
const context = useWatchSession(session as unknown as Session);
const isLoggedIn = session?.user;
const htmlClasses = isLoggedIn ? `h-full bg-gray-100` : `h-full`;
const bodyClasses = isLoggedIn ? `h-full` : `flex flex-col h-full`;
Expand Down
14 changes: 9 additions & 5 deletions app/routes/__home/book/$id.tsx → app/routes/_dash.book.$id.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, redirect, type LoaderArgs } from "@remix-run/node";
import { json, redirect, type LoaderFunctionArgs } from "@remix-run/node";
import {
isRouteErrorResponse,
useFetchers,
Expand All @@ -12,20 +12,23 @@ import { fetchBookInfo, getUsersBookmarks } from "~/models/books.server";
import BookItemFooter from "~/components/BookItemFooter";
import Notification from "~/components/Notification";

export async function loader({ request, params }: LoaderArgs) {
export async function loader({ request, params }: LoaderFunctionArgs) {
const { session } = await getSession(request);
if (!session) return redirect(FAILURE_REDIRECT);

const { id: userId } = session?.user!;
const { id: userId } = session?.user;
const { id: bookId } = params;

invariant(bookId, "bookId is required");
invariant(userId, "userId is required");

const data = await fetchBookInfo(bookId);

const bookmarks = await getUsersBookmarks(userId);

const userBookmark = bookmarks.find((bookmark) => bookmark.id === bookId);
const userBookmark = bookmarks.find(
(bookmark) => bookmark.book_id === bookId
);
const buid = userBookmark?.buid;
const isBookmarked = userBookmark?.bookmarked ?? false;
const isReading = userBookmark?.reading ?? false;
Expand Down Expand Up @@ -90,7 +93,8 @@ export default function Book() {
/>
<p className="mt-14 hidden md:block">
<a
href={link}
// href={link}
href={`https://www.google.co.uk/books/edition/_/${bookId}`}
target="_blank"
className="bg-rosyWorm hover:bg-rosyWorm-900 rounded-lg px-10 py-5 text-white"
rel="noreferrer"
Expand Down
Loading
Loading