import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { Context } from "../../../../model.js";
import { getResourcesByProductId } from "../../../serve.js";
import ResourceList from "../../../../components/ResourceList/index.js";
import React, { useContext, useEffect } from "react";
import { locales } from "@pisell/utils";
import { useRequest } from "ahooks";
//#region src/components/schedules/products/ProductDetailDrawer/ProductDetail/ResourcesModule/index.tsx
const ResourcesModule = ({ product }) => {
	const { state, dispatch } = useContext(Context);
	const _getResourcesByProductId = useRequest(getResourcesByProductId, { manual: true });
	useEffect(() => {
		if (product) {
			console.log("product", product);
			_getResourcesByProductId.run({ id: product.id });
		}
	}, [product]);
	const goResource = (item) => {
		dispatch({
			type: "setState",
			payload: {
				tabKey: "resources",
				resources: _objectSpread2(_objectSpread2({}, state.resources), {}, { cacheResource: item })
			}
		});
	};
	return /* @__PURE__ */ React.createElement("div", { className: "product-detail-card-module" }, /* @__PURE__ */ React.createElement("div", { className: "product-detail-card-title" }, locales.getText("pisell2.text.schedules.resources-title")), /* @__PURE__ */ React.createElement(ResourceList, {
		dataSource: _getResourcesByProductId.data || [],
		loading: _getResourcesByProductId.loading,
		onClick: goResource
	}));
};
//#endregion
export { ResourcesModule as default };
