feat(search): improve Search component with conditional rendering and debugging logs

- Added conditional rendering for the "No results found" message using the Show component.
- Introduced debugging logs in getUserImages and Search component to track data flow.
- Cleaned up the data mapping process in getUserImages for better readability.
This commit is contained in:
2025-04-14 10:54:18 +02:00
parent 0bc556f47c
commit a1369719d7
2 changed files with 24 additions and 15 deletions

View File

@@ -3,13 +3,13 @@ import { fetch } from "@tauri-apps/plugin-http";
import {
type InferOutput,
array,
literal,
nullable,
strictObject,
parse,
pipe,
strictObject,
string,
uuid,
literal,
variant,
} from "valibot";
@@ -19,9 +19,7 @@ type BaseRequestParams = Partial<{
method: "GET" | "POST";
}>;
export const base = import.meta.env.DEV
? "http://localhost:3040"
: "https://haystack.johncosta.tech";
export const base = "https://haystack.johncosta.tech";
const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => {
return new Request(`${base}/${path}`, {
@@ -134,8 +132,12 @@ export type UserImage = InferOutput<typeof dataTypeValidator>;
export const getUserImages = async (): Promise<UserImage[]> => {
const request = getBaseAuthorizedRequest({ path: "image" });
console.log("DBG: ", request);
const res = await fetch(request).then((res) => res.json());
console.log("DBG: ", res);
return parse(getUserImagesResponseValidator, res);
};