فهرست منبع

Refactor mutation hook in ProductDetailView

Replaces the getAreaMutation hook with getProductMutation and triggers the mutation on component mount using useEffect. This change ensures product data is loaded when the ProductDetailView component is rendered.
hieubt 3 هفته پیش
والد
کامیت
1867dc780f
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      EsimLao/esim-vite/src/pages/product-detail/ProductDetailView.tsx

+ 5 - 1
EsimLao/esim-vite/src/pages/product-detail/ProductDetailView.tsx

@@ -69,7 +69,11 @@ const ProductDetailView: React.FC = () => {
   //   staleTime: staleTime,
   // });
 
-  const getAreaMutation = useMutation({
+  useEffect(() => {
+    getProductMutation.mutate();
+  }, []);
+
+  const getProductMutation = useMutation({
     mutationFn: async () => {
       dispatch(startLoading({}));
       const res = await productApi.loadPackage({