Skip to content

Commit

Permalink
Merge branch 'develop' into feature/application
Browse files Browse the repository at this point in the history
  • Loading branch information
happytaeyoon authored Nov 26, 2024
2 parents e930eaf + 6fd009c commit 41acc47
Show file tree
Hide file tree
Showing 65 changed files with 1,397 additions and 345 deletions.
8 changes: 4 additions & 4 deletions src/app/(pages)/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import Header from '@/widgets/layout/ui/Header';
import { Admin } from '@/views/admin';

const admin = () => {
const page = () => {
return (
<div>
<Header />
<Admin />
</div>
);
};

export default admin;
export default page;
40 changes: 40 additions & 0 deletions src/app/api/admin/[admin_id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function PATCH(
request: NextRequest,
{ params }: { params: { admin_id: number } },
) {
const { admin_id } = params;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
console.log(admin_id);
console.log(accessToken);

try {
const response = await apiClient.patch(
`/admin/${admin_id}`,
{},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
);

return NextResponse.json(response.data);
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status;
const message = error.response?.data?.message || 'Unknown error';
return NextResponse.json({ error: message }, { status: status || 500 });
} else {
return NextResponse.json(
{ error: 'Internal Server Error' },
{ status: 500 },
);
}
}
}
26 changes: 26 additions & 0 deletions src/app/api/admin/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function GET() {
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;

try {
const response = await apiClient.get('/admin', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return NextResponse.json(response.data);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;

const status = axiosError.response?.status || 500;
const message =
axiosError.response?.data?.message || 'request signup failed';

return NextResponse.json({ error: message }, { status });
}
}
32 changes: 30 additions & 2 deletions src/app/api/expo/[expo_id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { AxiosError } from 'axios';
import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function GET(
request: Request,
request: NextRequest,
{ params }: { params: { expo_id: number } },
) {
const { expo_id } = params;
Expand All @@ -17,3 +18,30 @@ export async function GET(
return NextResponse.json({ error: message }, { status });
}
}

export async function DELETE(
request: NextRequest,
{ params }: { params: { expo_id: number } },
) {
const { expo_id } = params;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
console.log(accessToken);

try {
const response = await apiClient.delete(`/expo/${expo_id}`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

return NextResponse.json(response.data);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;

const status = axiosError.response?.status || 500;
const message = axiosError.response?.data?.message || 'expo delete failed';

return NextResponse.json({ error: message }, { status });
}
}
22 changes: 22 additions & 0 deletions src/app/api/expo/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,25 @@ export async function GET() {
return NextResponse.json({ error: message }, { status });
}
}

export async function POST(request: Request) {
const body = await request.json();
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;

try {
const response = await apiClient.post('/expo', body, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return NextResponse.json(response.data);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;

const status = axiosError.response?.status;
const message = axiosError.response?.data?.message;

return NextResponse.json({ error: message }, { status });
}
}
27 changes: 27 additions & 0 deletions src/app/api/image/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function POST(request: Request) {
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;

try {
const formData = await request.formData();
const response = await apiClient.post('/image', formData, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `Bearer ${accessToken}`,
},
});
return NextResponse.json(response.data);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;

const status = axiosError.response?.status || 500;
const message = axiosError.response?.data?.message || 'image upload failed';

return NextResponse.json({ error: message }, { status });
}
}
34 changes: 34 additions & 0 deletions src/app/api/map/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import axios from 'axios';
import { NextResponse } from 'next/server';

const KAKAO_REST_API_KEY = process.env.NEXT_PUBLIC_KAKAO_REST_API_KEY;

export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const address = searchParams.get('address');

if (!address) {
return NextResponse.json(
{ error: 'Address parameter is required' },
{ status: 400 },
);
}

const url = `https://dapi.kakao.com/v2/local/search/address.json?query=${encodeURIComponent(address)}`;

try {
const response = await axios.get(url, {
headers: {
Authorization: `KakaoAK ${KAKAO_REST_API_KEY}`,
},
});

return NextResponse.json(response.data);
} catch (error) {
console.error('Error fetching address data:', error);
return NextResponse.json(
{ error: 'Failed to fetch address data' },
{ status: 500 },
);
}
}
37 changes: 37 additions & 0 deletions src/app/api/standard/list/[expo_id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function POST(
request: NextRequest,
{ params }: { params: { expo_id: number } },
) {
const body = await request.json();
const { expo_id } = params;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
console.log(expo_id);
console.log(accessToken);

try {
const response = await apiClient.post(`/standard/list/${expo_id}`, body, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

return NextResponse.json(response.data);
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status;
const message = error.response?.data?.message || 'Unknown error';
return NextResponse.json({ error: message }, { status: status || 500 });
} else {
return NextResponse.json(
{ error: 'Internal Server Error' },
{ status: 500 },
);
}
}
}
26 changes: 26 additions & 0 deletions src/app/api/standard/program/[expo_id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function GET(
request: NextRequest,
{ params }: { params: { expo_id: number } },
) {
const { expo_id } = params;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
try {
const response = await apiClient.get(`/standard/program/${expo_id}`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return NextResponse.json(response.data);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;
const status = axiosError.response?.status || 500;
const message = axiosError.response?.data?.message || 'expoDetail failed';
return NextResponse.json({ error: message }, { status });
}
}
37 changes: 37 additions & 0 deletions src/app/api/training/list/[expo_id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function POST(
request: NextRequest,
{ params }: { params: { expo_id: number } },
) {
const body = await request.json();
const { expo_id } = params;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
console.log(expo_id);
console.log(accessToken);

try {
const response = await apiClient.post(`/training/list/${expo_id}`, body, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

return NextResponse.json(response.data);
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status;
const message = error.response?.data?.message || 'Unknown error';
return NextResponse.json({ error: message }, { status: status || 500 });
} else {
return NextResponse.json(
{ error: 'Internal Server Error' },
{ status: 500 },
);
}
}
}
26 changes: 26 additions & 0 deletions src/app/api/training/program/[expo_id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { AxiosError } from 'axios';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
import { apiClient } from '@/shared/libs/apiClient';

export async function GET(
request: NextRequest,
{ params }: { params: { expo_id: number } },
) {
const { expo_id } = params;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
try {
const response = await apiClient.get(`/training/program/${expo_id}`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return NextResponse.json(response.data);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;
const status = axiosError.response?.status || 500;
const message = axiosError.response?.data?.message || 'expoDetail failed';
return NextResponse.json({ error: message }, { status });
}
}
1 change: 1 addition & 0 deletions src/entities/admin/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as AdminProfile } from './ui/AdminProfile';
29 changes: 29 additions & 0 deletions src/entities/admin/ui/AdminProfile/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Image from 'next/image';
import React from 'react';
import { Setting } from '@/shared/assets/icons';
import Profile from '@/shared/assets/png/Profile.png';

const ProfileInfo = ({ label, value }: { label: string; value: string }) => (
<div className="flex gap-[30px]">
<p className="w-fit text-body2 text-gray-500">{label}</p>
<p className="w-fit text-body2 text-black">{value}</p>
</div>
);

const AdminProfile = () => {
return (
<div className="mx-auto my-0 flex w-fit">
<div className="flex items-center gap-[124px] mobile:flex-col mobile:gap-[30px]">
<Image src={Profile} alt="관리자 프로필" />
<div className="space-y-[32px]">
<ProfileInfo label="이름" value="김진원" />
<ProfileInfo label="아이디" value="jin1234" />
<ProfileInfo label="이메일" value="jin12345@gmail.com" />
</div>
</div>
<Setting />
</div>
);
};

export default AdminProfile;
1 change: 0 additions & 1 deletion src/entities/create-exhibition/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as ExpoInput } from './ui/ExpoInput';
export { default as ImageInput } from './ui/ImageInput';
export { default as TrainingModule } from './ui/TrainingModule';
export { default as SearchAddress } from './ui/SearchAddress';
Loading

0 comments on commit 41acc47

Please sign in to comment.