summaryrefslogtreecommitdiff
path: root/app/routes/events._index.tsx
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-09-26 00:19:53 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-09-26 00:19:53 +0900
commit874749df46cc291ca61f2f98092ccabfdeffbf16 (patch)
treee4cb53b5bfa23974e7935eb2616e0e005954f782 /app/routes/events._index.tsx
parent999b7a3133fccc3f120ac5ae24c02bb38a4ecce9 (diff)
Add passkey login and favorite search termsHEADmaster
Single-user auth: any registered passkey logs in as the owner. First registration needs a one-time token that the app writes to data/registration-token when no passkey exists yet; once logged in, more passkeys can be added without a token. Logged in, /favorites manages a list of terms (e.g. band names). Events whose title or artist contains a term (NFKC + case-insensitive) get a ★, and the event list gains an "お気に入りのみ" filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'app/routes/events._index.tsx')
-rw-r--r--app/routes/events._index.tsx15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/routes/events._index.tsx b/app/routes/events._index.tsx
index 33568df..563b0c0 100644
--- a/app/routes/events._index.tsx
+++ b/app/routes/events._index.tsx
@@ -6,6 +6,7 @@ import EventListRow from "~/components/EventListRow";
import FilterBar from "~/components/FilterBar";
import ScrapeButton from "~/components/ScrapeButton";
import { useVenueFilter } from "~/lib/venue-filter";
+import { isLoggedIn } from "~/lib/auth.server";
function defaultWindow() {
const today = new Date();
@@ -27,19 +28,24 @@ export async function loader({ request }: Route.LoaderArgs) {
const keyword = url.searchParams.get("keyword") ?? undefined;
const capacity_range = (url.searchParams.get("capacity_range") ?? undefined) as CapacityRange | undefined;
const area = url.searchParams.get("area") ?? undefined;
+ const loggedIn = isLoggedIn(request);
+ const favorites_only = loggedIn && url.searchParams.get("fav") === "1";
const page = Math.max(1, parseInt(url.searchParams.get("page") ?? "1", 10));
const limit = 30;
const offset = (page - 1) * limit;
- const events = queryEvents({ date_from, date_to, venue_id, keyword, capacity_range, area, limit, offset });
+ const events = queryEvents({
+ date_from, date_to, venue_id, keyword, capacity_range, area,
+ with_favorites: loggedIn, favorites_only, limit, offset,
+ });
const venues = getVenues();
const areas = [...new Set(venues.filter((v) => v.area).map((v) => v.area as string))].sort();
- return { events, venues, areas, page, hasMore: events.length === limit, date_from, date_to };
+ return { events, venues, areas, page, hasMore: events.length === limit, date_from, date_to, loggedIn };
}
export default function EventsIndex() {
- const { events, venues, areas, page, hasMore, date_from, date_to } = useLoaderData<typeof loader>();
+ const { events, venues, areas, page, hasMore, date_from, date_to, loggedIn } = useLoaderData<typeof loader>();
const [searchParams, setSearchParams] = useSearchParams();
const view = (searchParams.get("view") ?? "card") as "card" | "list";
const { hiddenIds } = useVenueFilter();
@@ -67,6 +73,7 @@ export default function EventsIndex() {
<Link to="/events" className="hover:text-white transition-colors">イベント</Link>
<Link to="/events/by-date" className="hover:text-white transition-colors">日付別</Link>
<Link to="/venues" className="hover:text-white transition-colors">会場一覧</Link>
+ <Link to="/favorites" className="hover:text-white transition-colors">★ お気に入り</Link>
</nav>
</header>
@@ -94,7 +101,7 @@ export default function EventsIndex() {
</div>
</div>
- <FilterBar venues={venues} areas={areas} defaultDateFrom={date_from} defaultDateTo={date_to} />
+ <FilterBar venues={venues} areas={areas} defaultDateFrom={date_from} defaultDateTo={date_to} showFavorites={loggedIn} />
{hiddenEventCount > 0 && (
<p className="mt-3 text-xs text-gray-500">