property management angefangen
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import ky from 'ky'
|
||||
import type { PropertyTypeGroup } from '../data/propertyTypeGroupTable'
|
||||
|
||||
const API_BASE_URL = 'http://localhost:8088'
|
||||
|
||||
type ApiResponse<T> = {
|
||||
message: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
type ParentGroupsResponse = {
|
||||
message: string;
|
||||
parentId: number;
|
||||
data: PropertyTypeGroup[];
|
||||
}
|
||||
|
||||
export async function createPropertyTypeGroup(propertyTypeGroup: PropertyTypeGroup): Promise<PropertyTypeGroup> {
|
||||
const response = await ky
|
||||
.post(`${API_BASE_URL}/createPropertyTypeGroup`, { json: propertyTypeGroup })
|
||||
.json<ApiResponse<PropertyTypeGroup>>()
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function updatePropertyTypeGroup(propertyTypeGroup: PropertyTypeGroup): Promise<PropertyTypeGroup> {
|
||||
const response = await ky
|
||||
.put(`${API_BASE_URL}/updatePropertyTypeGroup`, { json: propertyTypeGroup })
|
||||
.json<ApiResponse<PropertyTypeGroup>>()
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function deletePropertyTypeGroup(id: number): Promise<number> {
|
||||
const response = await ky
|
||||
.delete(`${API_BASE_URL}/deletePropertyTypeGroup/${id}`)
|
||||
.json<ApiResponse<number>>()
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function getPropertyTypeGroup(id: number): Promise<PropertyTypeGroup> {
|
||||
const response = await ky
|
||||
.get(`${API_BASE_URL}/getPropertyTypeGroup/${id}`)
|
||||
.json<ApiResponse<PropertyTypeGroup>>()
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function getPropertyTypeGroupsByParentId(parentId: number): Promise<PropertyTypeGroup[]> {
|
||||
const response = await ky
|
||||
.get(`${API_BASE_URL}/getPropertyTypeGroupsByParentId/${parentId}`)
|
||||
.json<ParentGroupsResponse>()
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function deletePropertyTypeFromPropertyTypeGroupId(propertyTypeGroupId: number): Promise<void> {
|
||||
await ky.delete(`${API_BASE_URL}/deletePropertyTypeFromPropertyTypeGroupId/${propertyTypeGroupId}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user