Searchbar, state mngmt. etc.. #3
@ -29,6 +29,7 @@ export default function Filtermenu() {
 | 
			
		||||
    const value = Math.max(Number(e.target.value), minPrice + 1);
 | 
			
		||||
    setMaxPrice(value);
 | 
			
		||||
    setSliderValues([sliderValues[0], value]);
 | 
			
		||||
    setStorePrice(minPrice, maxPrice);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const handleSliderChange = (values: [number, number]) => {
 | 
			
		||||
 | 
			
		||||
@ -1,3 +0,0 @@
 | 
			
		||||
export default function WineName(props: { name: string }) {
 | 
			
		||||
  return <p>{props.name}</p>;
 | 
			
		||||
}
 | 
			
		||||
@ -1,25 +0,0 @@
 | 
			
		||||
import getProducer from "~/server/actions/getProducer";
 | 
			
		||||
 | 
			
		||||
export default async function WineProducer(props: { id: string }) {
 | 
			
		||||
  const { id } = props;
 | 
			
		||||
 | 
			
		||||
  // Validate the id before making the database call
 | 
			
		||||
  if (!id) {
 | 
			
		||||
    return <p>Invalid producer ID</p>;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
    const result = await getProducer(id);
 | 
			
		||||
    return !result ? <p>Unable to retrieve producer</p> : <p>{result?.name}</p>;
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    console.error("Error fetching producer:", error);
 | 
			
		||||
    return <p>Error fetching producer</p>;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Utility function to validate UUID
 | 
			
		||||
function isValidUUID(uuid: string) {
 | 
			
		||||
  const uuidRegex =
 | 
			
		||||
    /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
 | 
			
		||||
  return uuidRegex.test(uuid);
 | 
			
		||||
}
 | 
			
		||||
@ -7,6 +7,7 @@ interface FilterState {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Filters {
 | 
			
		||||
  searchQuery: string;
 | 
			
		||||
  regions: string[];
 | 
			
		||||
  countries: string[];
 | 
			
		||||
  producers: string[];
 | 
			
		||||
@ -40,6 +41,7 @@ type FilterActions = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const initialFilters: Filters = {
 | 
			
		||||
  searchQuery: "",
 | 
			
		||||
  regions: [],
 | 
			
		||||
  countries: [],
 | 
			
		||||
  producers: [],
 | 
			
		||||
@ -60,6 +62,7 @@ const useFilterStore = create<FilterState & FilterActions>()(
 | 
			
		||||
  persist(
 | 
			
		||||
    (set) => ({
 | 
			
		||||
      filters: {
 | 
			
		||||
        searchQuery: "",
 | 
			
		||||
        regions: [],
 | 
			
		||||
        countries: [],
 | 
			
		||||
        producers: [],
 | 
			
		||||
 | 
			
		||||
@ -1,8 +0,0 @@
 | 
			
		||||
export interface Producer {
 | 
			
		||||
    id: string;
 | 
			
		||||
    name: string;
 | 
			
		||||
    createdAt: Date;
 | 
			
		||||
    country: string;
 | 
			
		||||
    region: string;
 | 
			
		||||
    email: string;
 | 
			
		||||
  }
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user