You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.3 KiB

2 months ago
import apiService from "./apiClient";
export interface Address {
items: AddressItem[];
}
export interface AddressItem {
receiver_first_name: string;
receiver_last_name: string;
country: string;
receiver_phone: string;
whatsapp_phone: string;
province: string;
city: string;
district: string;
detail_address: string;
1 month ago
is_default: number;
address_id: number;
user_id: number;
2 months ago
create_time: string;
update_time: string;
}
export interface addressData {
1 month ago
user_id: number;
2 months ago
receiver_first_name: string;
receiver_last_name: string;
country: string;
receiver_phone: string;
whatsapp_phone: string;
province: string;
city: string;
district: string;
detail_address: string;
is_default: number;
1 month ago
address_id: number;
2 months ago
}
export const addressApi = {
getAddress: () => {
4 weeks ago
return apiService.get<Address>("/api/addresses/");
2 months ago
},
1 month ago
postAddress: (data: any) => {
4 weeks ago
return apiService.post("/api/addresses/", data );
1 month ago
},
addressesDefault: () => {
return apiService.get<addressData>("/api/addresses/default/");
},
updateAddress: (data: any) => {
4 weeks ago
return apiService.put(`/api/addresses/${data.address_id}/`, data);
1 month ago
},
deleteAddress: (address_id: number) => {
4 weeks ago
return apiService.delete(`/api/addresses/${address_id}/`);
2 months ago
},
};