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:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user