Closed Sylvesterx1 closed 7 months ago
It's not an issue with the plugin itself but I will try to help you with that. useAttributes() is a custom hook to fetch /store/attributes
. For this particular example I'm using SWR but you can use whatever fetch abstraction you like. Here is an example of code:
// use-attributes.ts
import { $api } from "@/shared/api";
import useSWR, { Fetcher } from "swr";
const fetcher = () =>
$api
.get(`store/attributes`)
.then((res) => res.data);
export const ATTRIBUTES_KEY = `store/attributes`;
export const useAttributes = () => {
const { data, error, isLoading } = useSWR(
ATTRIBUTES_KEY,
fetcher
);
return {
attributes: data,
error,
isLoading,
};
};
@vholik Thank you for the information. Could you provide us with some sample files containing integration with visible imported components?
For UI we try use
import { VStack, Checkbox, CheckboxGroup } from "@chakra-ui/react";
import classnames from 'classnames';
but chakra-ui not have CheckboxList so we create manual component.
import CheckboxList from "@modules/attributes/components/checkbox-list";
but the output filter is:
Not possible filter products. (not clickable) So if you could share some files with us somewhere to see how it works witk all compoentns or send them to brandwrox1@gmail.com, I would be grateful.
Follows the integration documentation with the Medusa core storefront. For refference: https://rigby.pl/en/blog/custom-attributes-in-medusa.js-part-2-ui
I created: @modules/attributes/components/product-filters-context
@modules/attributes/components/attribute-filters
Now I try implement this filter directly in base category template: https://github.com/medusajs/nextjs-starter-medusa/blob/main/src/modules/categories/templates/index.tsx
add line:
import { AttributeFilters } from "@modules/attributes/components/attribute-filters";
But everytime I get:
Can you help/give advice on how we can implement this filter directly into the category template?
I can't find information with the definition of useAttributes() anywhere.