Browse Source

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 weeks ago
parent
commit
1867dc780f
1 changed files with 5 additions and 1 deletions
  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({