Преглед на файлове

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({