| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- 'use server';
- import { ChangeEmailRequest, ChangeNameRequest, ChangeApproveRequest, ChangeSummaryRequest, ChangeIntroRequest, ChangePasswordRequest } from '@/dtos/request/account';
- import { MemberResponse } from '@/dtos/response/account/member';
- import { ResultDto } from '@/dtos/response/common';
- import { fetchJson } from '@/lib/utils/server';
- // 회원정보 조회
- export async function fetchMemberInfo(): Promise<ResultDto<MemberResponse>> {
- return await fetchJson<MemberResponse>('/api/auth/profile', {
- method: 'GET'
- });
- }
- // 이메일 변경 인증 메일 발송
- export async function fetchChangeEmail(params: ChangeEmailRequest) {
- return await fetchJson('/api/mypage/email', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(params)
- });
- }
- // 이메일 변경 인증 확인
- export async function fetchValidEmail(token: string) {
- return await fetchJson(`/api/mypage/email/verify?token=${token}`, {
- method: 'GET',
- headers: {
- 'Accept': 'application/json'
- }
- });
- }
- // 별명 변경
- export async function fetchChangeName(params: ChangeNameRequest) {
- return await fetchJson('/api/mypage/name', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(params)
- });
- }
- // 별명 삭제
- export async function fetchRemoveName() {
- return await fetchJson('/api/mypage/name', {
- method: 'DELETE',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- }
- });
- }
- // 수신 설정
- export async function fetchChangeApprove(params: ChangeApproveRequest) {
- return await fetchJson('/api/mypage/receive-settings', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(params)
- });
- }
- // 한마디 변경
- export async function fetchChangeSummary(params: ChangeSummaryRequest) {
- return await fetchJson('/api/mypage/summary', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(params)
- });
- }
- // 한마디 삭제
- export async function fetchRemoveSummary() {
- return await fetchJson('/api/mypage/summary', {
- method: 'DELETE',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- }
- });
- }
- // 자기소개 변경
- export async function fetchChangeIntro(params: ChangeIntroRequest) {
- return await fetchJson('/api/mypage/intro', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(params)
- });
- }
- // 자기소개 삭제
- export async function fetchRemoveIntro() {
- return await fetchJson('/api/mypage/intro', {
- method: 'DELETE',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- }
- });
- }
- // 회원 사진 변경
- export async function fetchChangeThumb(f: File|null): Promise<ResultDto<{thumbUrl: string}>> {
- const formData = new FormData();
- formData.append('thumb', f || '');
- return await fetchJson<{thumbUrl: string}>('/api/mypage/thumb', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json'
- },
- body: formData
- });
- }
- // 비밀번호 변경
- export async function fetchChangePassword(params: ChangePasswordRequest) {
- return await fetchJson('/api/mypage/password', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(params)
- });
- }
- // 회원탈퇴
- export async function fetchWithdraw() {
- return await fetchJson('/api/mypage/withdraw', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- }
- });
- }
- // 로그인 기록
- export async function fetchLoginLog(page: number, type: string = 'today', pageSize: number = 20) {
- return await fetchJson(`/api/mypage/login-logs?page=${page}&type=${type}&pageSize=${pageSize}`, {
- method: 'GET',
- headers: {
- 'Accept': 'application/json'
- }
- });
- }
|