'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import InventoryAdjustmentForm from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm'; import type { InventoryAdjustment } from '@/types/api/inventory/adjustment'; const DetailInventoryAdjustment = () => { const router = useRouter(); const [inventoryAdjustment, setInventoryAdjustment] = useState(null); // Ambil data dari router state useEffect(() => { console.log("Router State"); console.log(window.history.state); const state = window.history.state?.usr as | { inventoryAdjustment?: InventoryAdjustment } | undefined; if (state?.inventoryAdjustment) { // jika object dikirim via router.push(state) setInventoryAdjustment(state.inventoryAdjustment); } }, [router]); const finalData = inventoryAdjustment; console.log("Final Data"); console.log(finalData); if (!finalData) { return (
); } return (
); }; export default DetailInventoryAdjustment;