From c609b45d995274594ce6173bc96ee23d053a14af Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 31 Mar 2025 17:49:17 +0000 Subject: [PATCH 1/3] feat(cards): adjusting for backend data types --- frontend/src/App.tsx | 47 ++++++++++++------- .../search-card/SearchCardEvent.tsx | 12 ++--- .../search-card/SearchCardLocation.tsx | 10 ++-- frontend/src/network/index.ts | 6 +-- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f273923..d1339b9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,46 +1,57 @@ import { IconSearch } from "@tabler/icons-solidjs"; import clsx from "clsx"; import Fuse from "fuse.js"; -import { For, createSignal } from "solid-js"; +import { For, createEffect, createResource, createSignal } from "solid-js"; import { SearchCardContact } from "./components/search-card/SearchCardContact"; import { SearchCardEvent } from "./components/search-card/SearchCardEvent"; import { SearchCardLocation } from "./components/search-card/SearchCardLocation"; import { SearchCardNote } from "./components/search-card/SearchCardNote"; import { SearchCardReceipt } from "./components/search-card/SearchCardReceipt"; import { SearchCardWebsite } from "./components/search-card/SearchCardWebsite"; -import { sampleData } from "./network/sampleData"; +import { UserImage, getUserImages } from "./network"; import type { DataItem } from "./network/types"; import { getCardSize } from "./utils/getCardSize"; -const getCardComponent = (item: DataItem) => { +const getCardComponent = (item: UserImage) => { switch (item.type) { - case "Location": + case "location": return ; - case "Event": + case "event": return ; - case "Contact": - return ; - case "Website": - return ; - case "Note": - return ; - case "Receipt": - return ; + // case "Contact": + // return ; + // case "Website": + // return ; + // case "Note": + // return ; + // case "Receipt": + // return ; default: return null; } }; function App() { - const [searchResults, setSearchResults] = createSignal([]); + const [searchResults, setSearchResults] = createSignal([]); const [searchQuery, setSearchQuery] = createSignal(""); - const [selectedItem, setSelectedItem] = createSignal(null); + const [selectedItem, setSelectedItem] = createSignal( + null, + ); - const fuze = new Fuse(sampleData, { - keys: [{ name: "title", weight: 2 }, "rawData"], + const [data] = createResource(getUserImages); + + let fuze = new Fuse(data() ?? [], { + keys: [{ name: "title", weight: 2 }, "data"], threshold: 0.4, }); + createEffect(() => { + fuze = new Fuse(data() ?? [], { + keys: [{ name: "data.Name", weight: 2 }], + threshold: 0.4, + }); + }); + const onInputChange = (event: InputEvent) => { const query = (event.target as HTMLInputElement).value; setSearchQuery(query); @@ -98,7 +109,7 @@ function App() { )} > - {item.title} + {item.data.Name} {getCardComponent(item)} diff --git a/frontend/src/components/search-card/SearchCardEvent.tsx b/frontend/src/components/search-card/SearchCardEvent.tsx index 8febd33..0a98bd7 100644 --- a/frontend/src/components/search-card/SearchCardEvent.tsx +++ b/frontend/src/components/search-card/SearchCardEvent.tsx @@ -1,10 +1,10 @@ import { Separator } from "@kobalte/core/separator"; import { IconCalendar } from "@tabler/icons-solidjs"; -import type { Event } from "../../network/types"; +import type { UserImage } from "../../network"; type Props = { - item: Event; + item: Extract; }; export const SearchCardEvent = ({ item }: Props) => { @@ -13,12 +13,12 @@ export const SearchCardEvent = ({ item }: Props) => { return (
-

{data.title}

+

{data.Name}

- Organized by {data.organizer.name} on{" "} - {new Date(data.dateTime.start).toLocaleDateString("en-US", { + Organized by TODO on{" "} + {new Date(data.StartDateTime).toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric", @@ -26,7 +26,7 @@ export const SearchCardEvent = ({ item }: Props) => {

- {data.description} + {data.Description}

); diff --git a/frontend/src/components/search-card/SearchCardLocation.tsx b/frontend/src/components/search-card/SearchCardLocation.tsx index 56f47ac..bae2e0d 100644 --- a/frontend/src/components/search-card/SearchCardLocation.tsx +++ b/frontend/src/components/search-card/SearchCardLocation.tsx @@ -1,10 +1,10 @@ import { Separator } from "@kobalte/core/separator"; import { IconMapPin } from "@tabler/icons-solidjs"; -import type { Location } from "../../network/types"; +import type { UserImage } from "../../network"; type Props = { - item: Location; + item: Extract; }; export const SearchCardLocation = ({ item }: Props) => { @@ -13,13 +13,13 @@ export const SearchCardLocation = ({ item }: Props) => { return (
-

{data.name}

+

{data.Name}

-

{data.address}

+

{data.Address}

- {data.description} + {data.Description}

); diff --git a/frontend/src/network/index.ts b/frontend/src/network/index.ts index e278ff1..72457e4 100644 --- a/frontend/src/network/index.ts +++ b/frontend/src/network/index.ts @@ -82,9 +82,9 @@ const eventDataType = object({ const dataTypeValidator = variant("type", [locationDataType, eventDataType]); const getUserImagesResponseValidator = array(dataTypeValidator); -export const getUserImages = async (): Promise< - InferOutput -> => { +export type UserImage = InferOutput; + +export const getUserImages = async (): Promise => { const request = getBaseRequest({ path: "image" }); const res = await fetch(request).then((res) => res.json()); From b7ed4e21696201beeea6252fda78f2d4ffa29111 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 31 Mar 2025 18:03:02 +0000 Subject: [PATCH 2/3] chore(imports): organisation --- frontend/src/App.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d1339b9..c419689 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2,14 +2,9 @@ import { IconSearch } from "@tabler/icons-solidjs"; import clsx from "clsx"; import Fuse from "fuse.js"; import { For, createEffect, createResource, createSignal } from "solid-js"; -import { SearchCardContact } from "./components/search-card/SearchCardContact"; import { SearchCardEvent } from "./components/search-card/SearchCardEvent"; import { SearchCardLocation } from "./components/search-card/SearchCardLocation"; -import { SearchCardNote } from "./components/search-card/SearchCardNote"; -import { SearchCardReceipt } from "./components/search-card/SearchCardReceipt"; -import { SearchCardWebsite } from "./components/search-card/SearchCardWebsite"; import { UserImage, getUserImages } from "./network"; -import type { DataItem } from "./network/types"; import { getCardSize } from "./utils/getCardSize"; const getCardComponent = (item: UserImage) => { From 01261258376e935f7cbc450752d499086ceb00a0 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 31 Mar 2025 20:17:14 +0000 Subject: [PATCH 3/3] fix --- backend/agents/event_location_agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/agents/event_location_agent.go b/backend/agents/event_location_agent.go index dabe9cd..33d690d 100644 --- a/backend/agents/event_location_agent.go +++ b/backend/agents/event_location_agent.go @@ -317,7 +317,7 @@ func NewLocationEventAgent(locationModel models.LocationModel, eventModel models Fn: func(info ToolHandlerInfo, args CreateEventArguments, call ToolCall) (model.Events, error) { ctx := context.Background() - layout := "2006-01-02T15:04:05" + layout := "2006-01-02T15:04:05Z" startTime, err := time.Parse(layout, args.StartDateTime) if err != nil {