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("/user/profile"); return data; }; export const updateProfile = async (profileData: UpdateProfileRequest) => { const { data } = await axios.patch( "/user/profile", profileData ); return data; }; export const getAddressByLocation = async (lat: number, lon: number) => { const { data } = await axios.get( `/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 => { const { data } = await axios.get("/user/profile/wishlist"); return data; }; export const getComments = async (): Promise => { 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 => { const { data } = await axios.get("/chat/list"); return data; }; export const getChatMessages = async ( chatId: string ): Promise => { const { data } = await axios.get(`/chat/${chatId}/messages`); return data; }; export const createChat = async ( chatData: CreateChatRequest ): Promise => { 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; };