22 lines
496 B
TypeScript
22 lines
496 B
TypeScript
|
|
import { useMemo, useState } from "react";
|
||
|
|
|
||
|
|
import { CustomerDtoAdapter } from "../adapters";
|
||
|
|
import { useCustomerGetQuery } from "../hooks";
|
||
|
|
|
||
|
|
export const useCustomerViewController = () => {
|
||
|
|
const [customerId, setCustomerId] = useState("");
|
||
|
|
|
||
|
|
const query = useCustomerGetQuery(customerId);
|
||
|
|
const data = useMemo(
|
||
|
|
() => (query.data ? CustomerDtoAdapter.fromDto(query.data) : undefined),
|
||
|
|
[query.data]
|
||
|
|
);
|
||
|
|
|
||
|
|
return {
|
||
|
|
...query,
|
||
|
|
data,
|
||
|
|
customerId,
|
||
|
|
setCustomerId,
|
||
|
|
};
|
||
|
|
};
|