33 lines
991 B
TypeScript
33 lines
991 B
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { LocationTreeNode, Location } from "../../types/inventory";
|
|
import { LocationTreeView } from "./location.treeView";
|
|
import { locationFindById } from "../../actions/location.actions";
|
|
import { LocationForm } from "./location.form";
|
|
|
|
|
|
interface Params {
|
|
data: LocationTreeNode[]
|
|
}
|
|
|
|
export function LocationView({ data }: Params) {
|
|
const [selectedLocation, setSelectedLocation] = useState<Location | undefined>();
|
|
|
|
const handleSelect = async (node: LocationTreeNode) => {
|
|
console.log('node',node);
|
|
// const node = await locationFindById(value);
|
|
setSelectedLocation(() => node);
|
|
}
|
|
|
|
return (
|
|
<div className="w-120 flex flex-col p-4 pt-10 ps-10">
|
|
<div>xxx</div>
|
|
<LocationTreeView data={data} onSelect={(item) => handleSelect(item)}></LocationTreeView>
|
|
{selectedLocation &&
|
|
<LocationForm initData={selectedLocation}></LocationForm>
|
|
}
|
|
</div>
|
|
|
|
);
|
|
} |