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
12 changes: 10 additions & 2 deletions app/routes/rooms/api/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export interface ChatAttachmentUploadResponse {
createdAt: string;
}

export interface ChatAttachment {
attachmentId: number;
attachmentType: "IMAGE" | "FILE";
contentType: string;
originalName: string;
fileSize: number;
accessUrl: string; // 서버가 메시지 응답에 주는 경우에만
}

/**
* 주의:
* - fetch를 쓸 때 Content-Type을 직접 multipart/form-data로 세팅하지 마세요.
Expand Down Expand Up @@ -40,12 +49,11 @@ export async function uploadAttachment(params: {
body: form,
});

// 실패시 throw
if (!res.ok) {
const text = await res.text().catch(() => "");
throw new Error(`Attachment upload failed: ${res.status} ${text}`);
}

const data = (await res.json()) as ChatAttachmentUploadResponse;
return data;
}
}
4 changes: 2 additions & 2 deletions app/routes/rooms/api/rooms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { axiosInstance } from "../../../api/axios";


//채팅룸 생성 및 조회
type CreateOrGetDirectRoomResponse = {
isSuccess: boolean;
code: string;
Expand Down Expand Up @@ -188,4 +188,4 @@ export async function getChatMessages({
}
);
return res.data;
}
}
20 changes: 6 additions & 14 deletions app/routes/rooms/chatting-room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";

import NavigationHeader from "../../components/common/NavigateHeader";
import ChatComposer from "./components/ChatComposer";
import AttachmentSheet, {
type AttachmentAction,
} from "./components/AttachmentSheet";
import AttachmentSheet, { type AttachmentAction } from "./components/AttachmentSheet";
import useKeyboardOffset from "../../hooks/KeyboardOffset";
import MessageRenderer from "./components/MessageRender";
import { formatKoreanDateTime } from "../../utils/dateTime";
Expand Down Expand Up @@ -51,8 +49,7 @@ export default function ChattingRoom({ brandId }: Props) {

const collabTitle = detail?.campaignSummary?.campaignTitle ?? "";
const collabSubtitle = detail?.campaignSummary?.brandName ?? "";
const collabThumb =
detail?.campaignSummary?.campaignImageUrl ?? partnerAvatarUrl;
const collabThumb = detail?.campaignSummary?.campaignImageUrl ?? partnerAvatarUrl;
const summaryBarHeight = isCollaborating ? 64 : 0;

const createdAt = useMemo(() => {
Expand All @@ -74,10 +71,7 @@ export default function ChattingRoom({ brandId }: Props) {

const run = async () => {
try {
const result = await createOrGetDirectRoom({
brandId,
creatorId: myUserId,
});
const result = await createOrGetDirectRoom({ brandId, creatorId: myUserId });
setRoomId(result.roomId);
} catch (e) {
console.error("createOrGetDirectRoom failed:", e);
Expand Down Expand Up @@ -195,6 +189,7 @@ export default function ChattingRoom({ brandId }: Props) {
};

const handlePickImage = async (e: React.ChangeEvent<HTMLInputElement>) => {
if (!roomId) return;
const file = e.target.files?.[0];
e.target.value = "";
if (!file) return;
Expand Down Expand Up @@ -231,6 +226,7 @@ export default function ChattingRoom({ brandId }: Props) {
};

const handlePickFile = async (e: React.ChangeEvent<HTMLInputElement>) => {
if (!roomId) return;
const file = e.target.files?.[0];
e.target.value = "";
if (!file) return;
Expand Down Expand Up @@ -313,11 +309,7 @@ export default function ChattingRoom({ brandId }: Props) {
<NavigationHeader title={partnerName} onBack={() => history.back()} />

{detail?.campaignSummary && (
<CollaborationSummaryBar
thumbnailUrl={collabThumb}
title={collabTitle}
subtitle={collabSubtitle}
/>
<CollaborationSummaryBar thumbnailUrl={collabThumb} title={collabTitle} subtitle={collabSubtitle} />
)}

<div
Expand Down
Loading