updated living space added

This commit is contained in:
2025-12-04 15:46:24 +03:00
parent 56b42bb906
commit 53e1f1e4fc
70 changed files with 1128 additions and 824 deletions

View File

@@ -11,7 +11,6 @@ const PageLivingSpaceList = () => {
const router = useRouter();
const [buildID, setBuildID] = useState<string | null>(null);
// const [collectionToken, setCollectionToken] = useState<string | null>(null);
const [isUserTypeEnabled, setIsUserTypeEnabled] = useState(false);
const [page, setPage] = useState(1);
const [limit, setLimit] = useState(10);
@@ -32,9 +31,7 @@ const PageLivingSpaceList = () => {
<div className="flex flex-col gap-2.5">
<PageLivingSpaceBuildsTableSection buildID={buildID} setBuildID={setBuildID} setIsUserTypeEnabled={setIsUserTypeEnabled} additionButtons={additionButtons} />
<h1 className="text-center justify-center">Living Space Added to selected Build with collectionToken: </h1><h1 className="text-center justify-center text-2xl font-bold">{buildID}</h1>
{
buildID && <LivingSpaceDataTable data={data?.data || []} totalCount={data?.totalCount || 0} currentPage={page} pageSize={limit} onPageChange={handlePageChange} onPageSizeChange={handlePageSizeChange} refetchTable={refetch} />
}
{buildID && <LivingSpaceDataTable data={data?.data || []} totalCount={data?.totalCount || 0} currentPage={page} pageSize={limit} onPageChange={handlePageChange} onPageSizeChange={handlePageSizeChange} refetchTable={refetch} buildID={buildID} />}
</div>
</>;
}

View File

@@ -11,6 +11,19 @@ const fetchGraphQlLivingSpaceList = async (buildID: string, params: ListArgument
} catch (error) { console.error('Error fetching test data:', error); throw error }
};
const fetchGraphQlLivingSpaceDetail = async (uuid: string, buildID: string): Promise<any> => {
console.log('Fetching test data from local API');
try {
const res = await fetch(`/api/living-space/detail`, { method: 'POST', cache: 'no-store', credentials: "include", body: JSON.stringify({ uuid, buildID }) });
if (!res.ok) { const errorText = await res.text(); console.error('Test data API error:', errorText); throw new Error(`API error: ${res.status} ${res.statusText}`) }; const data = await res.json();
return { data: data.data }
} catch (error) { console.error('Error fetching test data:', error); throw error }
};
export function useGraphQlLivingSpaceList(buildID: string, params: ListArguments) {
return useQuery({ queryKey: ['graphql-living-space-list', buildID, params], queryFn: () => fetchGraphQlLivingSpaceList(buildID, params) })
}
export function useGraphQlLivingSpaceDetail(uuid: string, buildID: string) {
return useQuery({ queryKey: ['graphql-living-space-detail', uuid, buildID], queryFn: () => fetchGraphQlLivingSpaceDetail(uuid, buildID) })
}