Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/service/feature/auth/types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface User {
id: string;
name: string;
avatarUrl: string;
}
5 changes: 3 additions & 2 deletions src/service/feature/chat/api/chatAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createAxiosInstance } from '../../common/axios/axiosInstance';
import { Chat } from '../type/messages.ts'

const axios = createAxiosInstance();

Expand All @@ -7,9 +8,9 @@ export const fetchChannels = async () => {
return res.data;
};

export const fetchLatestMessages = async (channelId: string | undefined) => {
export const fetchLatestMessages = async (channelId: string | undefined): Promise<Chat[]> => {
const res = await axios.get(`/message/latest?chatId=${channelId}`);
return Array.isArray(res.data) ? res.data : [];
return Array.isArray(res.data.data) ? res.data.data : [];
};

export const deleteMessage = async (messageId: string) => {
Expand Down
29 changes: 7 additions & 22 deletions src/service/feature/chat/context/SocketProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { CompatClient, Stomp } from '@stomp/stompjs';
import SockJS from 'sockjs-client';
import { SocketContext } from './SocketContext';

import {getCookie} from "@service/feature/auth/lib/getCookie.ts";

type Props = {
children: React.ReactNode;
Expand All @@ -13,13 +13,11 @@ export const SocketProvider = ({ children }: Props) => {
const clientRef = useRef<CompatClient | null>(null);

useEffect(() => {
// const token = getTokenFromCookie();
// if (token === null) {
// console.error('토큰을 찾을 수 없습니다.');
// return;
// }

const token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJmYzgxMGZmMy1hMTU2LTQxMGMtODBkYi05Mzk0NDA1MDdkYzM6TUVNQkVSIiwiaXNzIjoiamVycnkwMzM5IiwiaWF0IjoxNzQ4NjE5MDY0LCJleHAiOjE3ODEwMTkwNjR9.IO6VIqIfoS1EosqkAMTDd8Xv34HhmTbtp-CDppDcidjnsOOIpMyjNTnHgDS-2RsmFLIWQzvZjBKd-rvdebxkBA';
const token = getCookie("accessToken");
if (!token) {
console.error('토큰을 찾을 수 없습니다.');
return;
}

const socket = new SockJS(`http://flowchat.shop:30100/ws/chat?token=${token}`);
const stompClient = Stomp.over(socket);
Expand Down Expand Up @@ -53,17 +51,4 @@ export const SocketProvider = ({ children }: Props) => {
{children}
</SocketContext.Provider>
);
};

// function getTokenFromCookie(): string | null {
// const cookies = document.cookie;
// const cookieArray = cookies.split('; ');
//
// for (const cookie of cookieArray) {
// const [name, value] = cookie.split('=');
// if (name === 'accessToken' && value && value.startsWith('ey')) {
// return value;
// }
// }
// return null;
// }
};
3 changes: 0 additions & 3 deletions src/service/feature/chat/hook/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ export const useChat = (chatId: string | undefined, onMessage: (msg: ChatMessage
const tempId = uuidv4();
const sendUrl = `/pub/message/${chatId}`;
const message = {
chatId,
content,
attachments,
createdAt: new Date().toISOString(),
tempId
};

return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion src/service/feature/chat/hook/useMessageHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export const useMessageHistory = (channelId: string | undefined) => {
queryKey: ['messages', channelId],
queryFn: () => fetchLatestMessages(channelId),
enabled: !!channelId,
staleTime: 1000*30
staleTime: 1000 * 30,
});
};
1 change: 1 addition & 0 deletions src/service/feature/chat/schema/messageSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const messageSchema = z.object({
isUpdated: z.boolean(),
isDeleted: z.boolean(),
attachments: z.array(attachmentSchema).optional(),
mentions: z.array(z.string()).optional(),
status: z.enum(['pending', 'sent', 'error']).optional(),
tempId: z.string().optional(),
});
Expand Down
28 changes: 0 additions & 28 deletions src/service/feature/chat/type/message.ts

This file was deleted.

9 changes: 9 additions & 0 deletions src/service/feature/chat/type/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface Chat {
messageId: number;
sender: Sender;
content: string;
createdAt: string;
isUpdated: boolean;
isDeleted: boolean;
attachments: any[];
}
2 changes: 1 addition & 1 deletion src/service/feature/common/axios/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getCookie } from '../../auth/lib/getCookie';
export type ServiceType = 'members' | 'teams' | 'dialog';

const API_CONFIG = {
BASE_DOMAIN: 'https://flowchat.shop:30200',
BASE_DOMAIN: 'http://flowchat.shop:30100',
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using HTTP for the base API domain may expose data in transit. Consider switching to HTTPS for production endpoints.

Suggested change
BASE_DOMAIN: 'http://flowchat.shop:30100',
BASE_DOMAIN: process.env.API_BASE_URL || 'http://localhost:30100',

Copilot uses AI. Check for mistakes.
HEADERS: {
JSON: 'application/json',
},
Expand Down
1 change: 1 addition & 0 deletions src/service/feature/member/types/memberAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface MemberInfo {
nickname: string;
avatarUrl?: string;
birth?: string;
state?: MemberState;
}

export interface UpdateMemberStatusRequest {
Expand Down
4 changes: 2 additions & 2 deletions src/service/feature/team/api/teamsServiceAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const getTeamList = async () => {
return response.data;
};

export const getTeamById = async (teamId: string) => {
export const getTeamById = async (teamId: string | undefined) => {
const response = await axios.get(`/teams/${teamId}`);
return response.data;
return response.data.data;
};

export const deleteTeam = async (teamId: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/service/feature/team/hook/query/useTeamServiceQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useTeamListQuery = () => {
});
};

export const useTeamDetailQuery = (teamId: string) => {
export const useTeamDetailQuery = (teamId: string | undefined) => {
return useQuery<Team>({
queryKey: ['teamDetail', teamId],
queryFn: () => getTeamById(teamId),
Expand Down
18 changes: 18 additions & 0 deletions src/service/feature/team/types/team.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import {Channel} from "@service/feature/channel/types/channel.ts";
import {MemberInfo} from "@service/feature/member/types/memberAPI.ts";

export interface Team {
id: string;
name: string;
iconUrl?: string;
masterId?: string;
[key: string]: any;
}

export interface CategoriesView {
category: {
id: number,
name: string,
position: number,
},
channels: Channel[],
}

export interface TeamMembers {
id: number,
role: "ADMIN",
memberInfo: MemberInfo,
}
Loading
Loading