Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
wip: search
  • Loading branch information
hi-ogawa committed Apr 7, 2024
commit 2509a9b9ffe1745fe9d855b1565b1c486dea8e2f
4 changes: 2 additions & 2 deletions src/routes/_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ContactRecord = ContactMutation & {
////////////////////////////////////////////////////////////////////////////////
// This is just a fake DB table. In a real app you'd be talking to a real db or
// fetching from an existing API.
const fakeContacts = {
export const fakeContacts = {
records: {} as Record<string, ContactRecord>,

async getAll(): Promise<ContactRecord[]> {
Expand Down Expand Up @@ -59,7 +59,7 @@ const fakeContacts = {
////////////////////////////////////////////////////////////////////////////////
// Handful of helper functions to be called from route loaders and actions
export async function getContacts(query?: string | null) {
await new Promise((resolve) => setTimeout(resolve, 500));
// await new Promise((resolve) => setTimeout(resolve, 500));
let contacts = await fakeContacts.getAll();
if (query) {
contacts.filter((c) => c.first?.includes(query) || c.last?.includes(query));
Expand Down
7 changes: 5 additions & 2 deletions src/routes/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Link } from "@hiogawa/react-server/client";
import { getContacts } from "./_data";
import { actionNewContact } from "./_action";
import type { LayoutProps } from "@hiogawa/react-server/server";

export default async function Layout(props: React.PropsWithChildren) {
export default async function Layout(props: LayoutProps) {
const contacts = await getContacts();
props.url.search;

return (
<html>
Expand All @@ -18,7 +20,8 @@ export default async function Layout(props: React.PropsWithChildren) {
<Link href="/">Remix Contacts</Link>
</h1>
<div>
<form id="search-form" role="search">
{/* TODO: GET form navigation */}
<form action="" id="search-form" role="search">
<input
aria-label="Search contacts"
id="q"
Expand Down