Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”₯ remove : μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” μ½”λ“œ μ‚­μ œ #183

Merged
merged 2 commits into from
Jan 19, 2024
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
23 changes: 13 additions & 10 deletions api/chat/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const accessToken = nookies.get(null)['accessToken'];
const ACCESSTOKEN = '6231025e-0347-4ae3-9fdd-dd4e6cbb5abe';

// 1. 참여쀑인 μ±„νŒ…λ°© 리슀트 보기
export const loadedChatList = async (userId: string) => {
const res = await fetch(`/v1/chat/room/${userId}`, {
export const loadedChatList = async () => {
const res = await fetch('https://catchroom.xyz/v1/chat/room/list', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand All @@ -23,7 +23,7 @@ export const creatChatRoom = async (
sellerId: string,
productId: string,
) => {
const res = await fetch(`/v1/chat/room/create`, {
const res = await fetch(`https://catchroom.xyz/v1/chat/room/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -38,7 +38,7 @@ export const creatChatRoom = async (

// 3. μ±„νŒ… λ‚΄μš© 뢈러였기
export const loadedChatMessage = async (roomId: string) => {
const res = await fetch(`/v1/chat/find?id=${roomId}`, {
const res = await fetch(`http://catchroom.xyz/v1/chat/find?id=${roomId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand All @@ -52,13 +52,16 @@ export const loadedChatMessage = async (roomId: string) => {

// 4. μ±„νŒ…λ°© λ‚΄λΆ€ 정보 뢈러였기
export const loadedChatInfo = async (roomId: string) => {
const res = await fetch(`/v1/chat/room?roomId=${roomId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
const res = await fetch(
`https://catchroom.xyz/v1/chat/room?roomId=${roomId}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
},
});
);

const data = await res.json();
console.log(data);
Expand Down
22 changes: 11 additions & 11 deletions app/chat/chatRoom/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Header from '@/components/common/header';
import MessageList from '@/components/chat/chatRoom/messageList';
import WebSocketConnection from '@/components/chat/chatRoom/WebSocketConnection/WebSocketConnection';
import { MessageProps } from '@/types/chat/chatRoom/types';
import { loadedChatMessage, loadedChatInfo } from '@/api/chat/api';
import { loadedChatMessage } from '@/api/chat/api';

const ROOMID = '02d6b08d-60f8-4c21-b5b2-0ba7af752e29';

Expand All @@ -25,16 +25,16 @@ const Page = () => {
// };
// ChatInfo();

// //μ±„νŒ… λ‚΄μš© 뢈러였기
// const chatMessage = async () => {
// try {
// const result = await loadedChatMessage(ROOMID);
// console.log(result);
// } catch (error) {
// console.error('failed:', error);
// }
// };
// chatMessage();
//μ±„νŒ… λ‚΄μš© 뢈러였기
const chatMessage = async () => {
try {
const result = await loadedChatMessage(ROOMID);
console.log(result);
} catch (error) {
console.error('failed:', error);
}
};
chatMessage();

const onMessageReceived = (newMessage: MessageProps) => {
setMessage((prev) => [...prev, newMessage]);
Expand Down
42 changes: 22 additions & 20 deletions app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@ import { useRouter } from 'next/navigation';
import Modal from '@/components/common/modal';
import { useRecoilState } from 'recoil';
import { isModalState } from '@/atoms/chat/leaveButton';
import axios from 'axios';

import { useMutation } from '@tanstack/react-query';
import SimpleButton from '@/components/common/sheetsButtons/simpleButton';
import { creatChatRoom, loadedChatList } from '@/api/chat/api';

const ACCESSTOKEN = '6231025e-0347-4ae3-9fdd-dd4e6cbb5abe';

// μ±„νŒ…λ°© μƒμ„±ν•˜κΈ°
const createRoom = async () => {
const data = await axios.post(
'http://localhost:3000/v1/chat/room/create',
{
buyerId: 'buyer1',
sellerId: 'seller1',
productId: 'product1',
},
{
headers: {
Authorization: `Bearer ${ACCESSTOKEN}`,
},
},
);
console.log(data);
console;
return data;
try {
const result = await creatChatRoom('buyer1', 'seller1', 'product1');
console.log(result);
} catch (error) {
console.error('failed:', error);
}
};
createRoom();

//μ±„νŒ…λ°© 리슀트 뢈러였기
const chatLists = async () => {
try {
const result = await loadedChatList();
console.log(result);
} catch (error) {
console.error('failed:', error);
}
};
chatLists();

const MakeButton = () => {
const mutation = useMutation({
Expand Down Expand Up @@ -64,7 +66,7 @@ const Page = () => {
};
const onConfirm = () => {
handleModalOpen();
router.push('/login');
router.push('/chat');
};

return (
Expand Down
2 changes: 1 addition & 1 deletion app/stomp/sock/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import SockJS from 'sockjs-client';
import { CompatClient, Stomp } from '@stomp/stompjs';
import { loadedChatMessage } from '@/api/chat/api';
// import { loadedChatMessage } from '@/api/chat/api';
// test μ™„λ£Œλ˜λ©΄ μ§€μš°λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€

const ROOMID = '02d6b08d-60f8-4c21-b5b2-0ba7af752e29';
Expand Down