Skip to content

Commit

Permalink
fix: Eliminate query errors on /quests, add release CI (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker authored Sep 7, 2024
1 parent d03457b commit b1bc99c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-beds-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"namesake": patch
---

Resolve query errors on /quests route for unauthenticated users
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Create release pull request
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"version": "0.0.0",
"type": "module",
"packageManager": "[email protected]",
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "npm-run-all --parallel dev:frontend dev:backend",
Expand Down
1 change: 1 addition & 0 deletions public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Namesake",
"icons": [
{ "src": "/favicon-192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "/favicon-512.png", "type": "image/png", "sizes": "512x512" }
Expand Down
6 changes: 4 additions & 2 deletions src/components/shared/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export const AppHeader = () => {
<div className="flex gap-4 items-center w-screen py-3 px-4 border-b border-gray-dim">
<Link href={{ to: "/" }}>Namesake</Link>
<Link href={{ to: "/quests" }}>Quests</Link>
{/* TODO: Conditionally render this link */}
<Link href={{ to: "/admin" }}>Admin</Link>
<Authenticated>
{/* TODO: Gate this by role */}
<Link href={{ to: "/admin" }}>Admin</Link>
</Authenticated>
<div className="ml-auto">
<Authenticated>
<MenuTrigger>
Expand Down
2 changes: 0 additions & 2 deletions src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
createRootRouteWithContext,
useRouter,
} from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
import type { ConvexAuthState } from "convex/react";
import { RouterProvider } from "react-aria-components";
import { AppHeader } from "../components/shared";
Expand Down Expand Up @@ -38,7 +37,6 @@ function RootRoute() {
<AppHeader />
<Outlet />
</main>
<TanStackRouterDevtools />
</RouterProvider>
);
}
33 changes: 7 additions & 26 deletions src/routes/quests/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { RiAddFill } from "@remixicon/react";
import { createFileRoute } from "@tanstack/react-router";
import { useMutation, useQuery } from "convex/react";
import { useQuery } from "convex/react";
import { api } from "../../../convex/_generated/api";
import {
Badge,
Button,
Container,
GridList,
GridListItem,
Expand All @@ -17,8 +15,6 @@ export const Route = createFileRoute("/quests/")({

function QuestsRoute() {
const allQuests = useQuery(api.quests.getAllActiveQuests);
const otherQuests = useQuery(api.usersQuests.getAvailableQuestsForUser);
const addQuest = useMutation(api.usersQuests.create);

if (allQuests === undefined) return;
if (allQuests === null) return null;
Expand All @@ -31,27 +27,12 @@ function QuestsRoute() {
items={allQuests}
renderEmptyState={() => "No quests found"}
>
{allQuests.map(({ _id, _creationTime, title, state }) => {
const isQuestAdded = !otherQuests?.some((quest) => quest._id === _id);

return (
<GridListItem textValue={title} key={_id}>
{title}
{state && <Badge>{state}</Badge>}
{isQuestAdded ? (
<Badge variant="info">{`Added ${new Date(_creationTime).toLocaleString()}`}</Badge>
) : (
<Button
onPress={() => addQuest({ questId: _id })}
variant="icon"
aria-label="Add quest"
>
<RiAddFill size={16} />
</Button>
)}
</GridListItem>
);
})}
{allQuests.map(({ _id, title, state }) => (
<GridListItem textValue={title} key={_id}>
{title}
{state && <Badge>{state}</Badge>}
</GridListItem>
))}
</GridList>
</Container>
);
Expand Down

0 comments on commit b1bc99c

Please sign in to comment.