80 lines
2.1 KiB
TypeScript
80 lines
2.1 KiB
TypeScript
import axios from "@/config/axios";
|
|
import { UserMeResponseType } from "@/share/types/SharedTypes";
|
|
import {
|
|
UpdateProfileRequest,
|
|
UpdateProfileResponse,
|
|
AddressLocationResponse,
|
|
UpdateAddressType,
|
|
WishlistResponse,
|
|
CommentsResponse,
|
|
ChatListResponse,
|
|
ChatMessagesResponse,
|
|
CreateChatRequest,
|
|
CreateChatResponse,
|
|
} from "../types/ProfileTypes";
|
|
|
|
export const getProfile = async () => {
|
|
const { data } = await axios.get<UserMeResponseType>("/user/profile");
|
|
return data;
|
|
};
|
|
|
|
export const updateProfile = async (profileData: UpdateProfileRequest) => {
|
|
const { data } = await axios.patch<UpdateProfileResponse>(
|
|
"/user/profile",
|
|
profileData
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const getAddressByLocation = async (lat: number, lon: number) => {
|
|
const { data } = await axios.get<AddressLocationResponse>(
|
|
`/address/location/reverse?lat=${lat}&lon=${lon}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const updateAddress = async (addressData: UpdateAddressType) => {
|
|
const { data } = await axios.post("/address/user/save", addressData);
|
|
return data;
|
|
};
|
|
|
|
export const getWithList = async (): Promise<WishlistResponse> => {
|
|
const { data } = await axios.get("/user/profile/wishlist");
|
|
return data;
|
|
};
|
|
|
|
export const getComments = async (): Promise<CommentsResponse> => {
|
|
const { data } = await axios.get("/user/profile/comments");
|
|
return data;
|
|
};
|
|
|
|
export const changeEmail = async (email: string) => {
|
|
const { data } = await axios.post("/user/profile/email/change", { email });
|
|
return data;
|
|
};
|
|
|
|
// Chat Services
|
|
export const getChatList = async (): Promise<ChatListResponse> => {
|
|
const { data } = await axios.get("/chat/list");
|
|
return data;
|
|
};
|
|
|
|
export const getChatMessages = async (
|
|
chatId: string
|
|
): Promise<ChatMessagesResponse> => {
|
|
const { data } = await axios.get(`/chat/${chatId}/messages`);
|
|
return data;
|
|
};
|
|
|
|
export const createChat = async (
|
|
chatData: CreateChatRequest
|
|
): Promise<CreateChatResponse> => {
|
|
const { data } = await axios.post("/chat/create", chatData);
|
|
return data;
|
|
};
|
|
|
|
export const markChatAsRead = async (chatId: string) => {
|
|
const { data } = await axios.patch(`/chat/${chatId}/read`);
|
|
return data;
|
|
};
|