"use server";
import Axios from "@/lib/Axios";
import { SearchResponse } from "@/types";
import axios from "axios";
import ky from "ky";
const mockDelay = (ms: number) =>
  new Promise((resolve) => setTimeout(resolve, ms));

export const searchProductsByName = async (query: string) => {
  await mockDelay(1500);

  //   const resp = ky
  //     .get(`https://dummyjson.com/products/search?q=${query}`)
  //     .json<SearchResponse>();

  //   console.log(resp);
  //   return resp;

  // console.log("server ");

  const resp: SearchResponse = await Axios.get(
    `users/employees/?search=${query}`
  )
    .then((res) => {
      console.log(res.data);
      return res.data;
    })
    .catch((e) => {
      console.log(e);
    });

  return resp;
};
