Skip to content

Commit 3e62871

Browse files
authored
Merge pull request #72 from SeeATheater/dev
fix: 배포된 환경에서 카카오톡 로그인 가능하도록 수정
2 parents 7053997 + 6bf049a commit 3e62871

4 files changed

Lines changed: 55 additions & 27 deletions

File tree

src/components/Login/KakaoLoginButton.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import KaKaoLogo from '@/assets/icons/KakaoRound.svg?react';
33

44
function KakaoLoginButton() {
55
const client_id = import.meta.env.VITE_KAKAO_CLIENT_ID;
6-
// const redirect_uri = import.meta.env.VITE_KAKAO_REDIRECT_URI;
7-
const redirect_uri = 'http://localhost:5173/auth/kakao/callback';
8-
// const redirect_uri = 'https://seeatheater.site/auth/kakao/callback';
6+
const redirect_uri = import.meta.env.VITE_KAKAO_REDIRECT_URI;
97
const KAKAO_AUTH_URL = `https://kauth.kakao.com/oauth/authorize?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=code`;
108

119
const handleKakaoLogin = () => {

src/pages/production/UploadPic.jsx

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import Select from 'react-select';
66
import useAxios from '@/utils/hooks/useAxios';
77
import { getPresignedUrl } from '@/utils/apis/getPresignedUrl';
88
import { uploadImageToS3 } from '@/utils/apis/uploadImageToS3';
9-
import useCustomFetch from '@/utils/hooks/useAxios';
9+
//import useCustomFetch from '@/utils/hooks/useAxios';
10+
import useCustomFetch from '@/utils/hooks/useCustomFetch';
1011

1112
import ImageUploadBox from '@/components/ImageUploadBox2';
1213
import TopBar from '@/components/TopBar';
@@ -22,6 +23,7 @@ function UploadPic() {
2223
{ title: '킬링시저', date: '25.06.10~25.06.13' },
2324
];
2425

26+
const [file, setFile] = useState(null);
2527
const [selected, setSelected] = useState(null);
2628
const [menuOpen, setMenuOpen] = useState(false);
2729
const [showModal, setShowModal] = useState(false);
@@ -31,32 +33,47 @@ function UploadPic() {
3133
const [textContent, setTextContent] = useState('');
3234
const isFormValid = Boolean(selected?.title && selected?.date && file);
3335

34-
const baseOptions = data.map((item) => ({
35-
value: `${item.title}-${item.date}`,
36+
const searchInput = encodeURIComponent(inputValue);
37+
const {
38+
data: searchData,
39+
error: searchError,
40+
loading: searchLoading,
41+
} = useCustomFetch(`/search?keyword=${searchInput}&page=0&size=10`);
42+
//console.log('입력값:', inputValue);
43+
//console.log(searchInput);
44+
//console.log('결과:', searchData);
45+
//console.log(searchLoading);
46+
//console.log('선택된 항목:', selected)
47+
48+
const searchOptions = (searchData?.result?.content || []).map((item) => ({
49+
value: item.showId,
3650
title: item.title,
37-
date: item.date,
51+
date: item.schedule,
3852
label: (
3953
<LabelWrapper>
40-
<Title>{item.title}</Title>
41-
<Date>{item.date}</Date>
54+
{item.posterImageUrl && (
55+
<img
56+
src={item.posterImageUrl}
57+
alt={item.title}
58+
style={{ width: 30, height: 40, marginRight: 8, borderRadius: 4 }}
59+
/>
60+
)}
61+
<div>
62+
<Title>{item.title}</Title>
63+
<Date>{item.schedule}</Date>
64+
</div>
4265
</LabelWrapper>
4366
),
4467
}));
4568

4669
const options = [
47-
...baseOptions,
48-
...customOptions,
70+
...searchOptions,
4971
{
5072
value: 'custom',
5173
label: <Title>직접 입력</Title>,
5274
},
5375
];
5476

55-
const filteredOptions = baseOptions.filter(
56-
(option) =>
57-
option.title.includes(inputValue) || option.date.includes(inputValue),
58-
);
59-
6077
const handleSelectChange = (option) => {
6178
if (option.value === 'custom') {
6279
setShowModal(true);
@@ -124,26 +141,31 @@ function UploadPic() {
124141
const extension = file.name.split('.').pop().toLowerCase();
125142

126143
const { uploadUrl, publicUrl, keyName } = await getPresignedUrl(
144+
axiosClient,
127145
extension,
128146
'photoAlbum',
129147
);
130148

131-
console.log('S3 응답:', uploadUrl); // 디버깅용
132-
console.log('keyName:', keyName); // 디버깅용
133-
console.log('publicUrl:', publicUrl); // 디버깅용
149+
console.log('S3 응답:', uploadUrl); // 디버깅용
150+
console.log('keyName:', keyName); // 디버깅용
151+
console.log('publicUrl:', publicUrl); // 디버깅용
134152

135-
const url = `https://ccbucket-0528.s3.ap-northeast-2.amazonaws.com/${uploadUrl}`;
136-
await uploadImageToS3(axiosClient, extension, url);
153+
//const url = `https://ccbucket-0528.s3.ap-northeast-2.amazonaws.com/${uploadUrl}`;
154+
await uploadImageToS3(axiosClient, extension, uploadUrl);
137155

138156
const postBody = {
139-
//추후 ID 수정
140-
amateurShowId: 4,
157+
amateurShowId: selected.value,
141158
content: textContent,
142-
imageRequestDTOs: [{ keyName, imageUrl: publicUrl }],
159+
imageRequestDTOs: [{ keyName: keyName, imageUrl: publicUrl }],
143160
};
161+
console.log(postBody);
144162

145163
const res = await fetchData('/photoAlbums', 'POST', postBody);
146-
if (!res.ok) throw new Error(`서버 응답 오류: ${res.status}`);
164+
//console.log(postBody)
165+
if (res.status !== 200 && res.status !== 201) {
166+
throw new Error(`서버 응답 오류: ${res.status}`);
167+
}
168+
console.log('응답 데이터:', res.data);
147169
alert('등록 완료!');
148170
} catch (err) {
149171
console.error(err);
@@ -216,7 +238,7 @@ function UploadPic() {
216238
/>
217239
{menuOpen && (
218240
<Dropdown>
219-
{filteredOptions.map((option, idx) => (
241+
{options.map((option, idx) => (
220242
<OptionItem
221243
key={idx}
222244
onClick={() => {

src/utils/hooks/useCustomFetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const useCustomFetch = (url, method = 'GET', body = null) => {
2424
data: customBody,
2525
});
2626
setData(response.data);
27-
return response.data;
27+
return response;
2828
} catch (err) {
2929
setError(true);
3030
return { isSuccess: false, message: 'API 요청 실패', error: err };

vercel.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rewrites": [
3+
{
4+
"source": "/(.*)",
5+
"destination": "/index.html"
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)