Skip to content

Commit

Permalink
reset: main 브랜치 커밋 되돌리기
Browse files Browse the repository at this point in the history
  • Loading branch information
jongse7 committed Oct 22, 2024
1 parent d3b6013 commit b44c394
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 74 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
23 changes: 11 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { QueryClient, QueryCache, QueryClientProvider } from '@tanstack/react-qu
import { APIResponseError } from 'endpoint-client';
import './style.css';
import ScrollToTop from './components/ScrollTop/ScrollTop';
import { useEffect } from 'react';

const queryClient = new QueryClient({
queryCache: new QueryCache({
Expand All @@ -28,17 +27,17 @@ const queryClient = new QueryClient({
});

function App() {
/* 총학 홈페이지 접근 시 ssuketch로 리다이렉트 되도록 임시 설정 */
useEffect(() => {
if (window.location.pathname !== '/beta') {
if (window.location.pathname === '/auth/callback') {
console.log('카카오');
} else {
window.location.href = 'https://ssuketch60.cafe24.com/';
console.log('카카오 아님');
}
}
}, []);
// /* 총학 홈페이지 접근 시 ssuketch로 리다이렉트 되도록 임시 설정 */
// useEffect(() => {
// if (window.location.pathname !== '/beta') {
// if (window.location.pathname === '/auth/callback') {
// console.log('카카오');
// } else {
// window.location.href = 'https://ssuketch60.cafe24.com/';
// console.log('카카오 아님');
// }
// }
// }, []);

return (
<QueryClientProvider client={queryClient}>
Expand Down
1 change: 0 additions & 1 deletion src/apis/getBoardPostSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const getBoardPostSearch = async ({
q: q,
},
});
console.log(response);

return response.data;
};
2 changes: 1 addition & 1 deletion src/containers/common/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function Header({ state = State.Onboarding, onLogout = () => {} }: Header
/>
<div className={cn(styles.headerItemStyle, 'xs:px-0.5 sm:px-0.5 md:px-0.5 lg:px-0.5')}>
{/* 임시로 메인 라우팅 /beta로 변경 */}
<Link to="/beta">
<Link to="/">
<div className="flex items-center gap-4">
<Logo size={isSmall ? '23px' : '46px'} fill={styles.fillColor} />
<span className={cn(styles.textColor, 'min-w-fit text-[20px] text-lg font-bold')}>US:SUM</span>
Expand Down
1 change: 1 addition & 0 deletions src/containers/common/Header/const/pathData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const menuItems = {
학생자치기구: [
// { name: '산하기구', path: '/affiliated_organization' },
// { name: '특별기구', path: '/special_organization' },
{ name: 'passu', path: '/register/redirect' },
{ name: '감사기구', path: '/audit?category=all' },
],
소통: [
Expand Down
2 changes: 1 addition & 1 deletion src/pages/general/containers/GeneralRegisterSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function GeneralRegisterSection({ subSection1, buttonSection }: LoginForm
localStorage.setItem('accessToken', response.data?.data?.accessToken);
}
// 임시로 메인 라우팅 /beta로 변경
navigate('/beta');
navigate('/');
setLoginState(true);
} else {
alert('로그인 정보가 일치하지 않습니다. 다시 시도해주세요.');
Expand Down
2 changes: 1 addition & 1 deletion src/pages/general/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useParams } from 'react-router-dom';
import { GeneralRegisterSection } from '@/pages/general/containers/GeneralRegisterSection';
import { CertifyErrorSection } from '@/pages/general/containers/CertifyErrorSection'; // CertifyErrorSection 컴포넌트 임포트
import { CertifyErrorSection } from '@/pages/general/containers/CertifyErrorSection';
import { CertifyApplySection } from './containers/CertifyApplySection';
import { Header } from '@/containers/common/Header/Header';
import { State } from '@/containers/common/Header/const/state';
Expand Down
20 changes: 17 additions & 3 deletions src/pages/kakao/containers/KakaoRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const KakaoRedirect = () => {
const setLoginState = useSetRecoilState(LoginState);
const AUTHORIZE_CODE: string = new URLSearchParams(window.location.search).get('code')!;

const urlParams = new URLSearchParams(window.location.search);

const redirect_url = urlParams.get('subServiceUrl');
console.log(redirect_url);

const navigate = useNavigate();

useEffect(() => {
Expand All @@ -24,9 +29,18 @@ const KakaoRedirect = () => {
if (res.data.isFirst) {
navigate('/register/tos'); // 최초 회원가입 유저는 약관 동의 화면으로 이동
} else {
// 임시로 메인 라우팅 /beta로 변경
window.location.href = 'https://stu.ssu.ac.kr/beta'; // 이미 가입된 유저는 메인 화면으로 이동
setLoginState(true);
// 외부 학생 서비스에서 카카오로그인 이용 시 redirection 처리
if (redirect_url!) {
// redirect_url에 accessToken 심기
const separator = redirect_url.includes('?') ? '&' : '?';
const new_redirect_url = `${redirect_url}${separator}accessToken=${accessToken}`;
// 토큰이 심어진 redirect_url로 이동
window.location.href = new_redirect_url;
} else {
// 임시로 메인 라우팅 /beta로 변경
window.location.href = 'https://stu.ssu.ac.kr/'; // 이미 가입된 유저는 메인 화면으로 이동
setLoginState(true);
}
}
} else {
alert('로그인에 실패했습니다');
Expand Down
40 changes: 40 additions & 0 deletions src/pages/kakao/redirect/containers/RegisterButtonSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { KakaoButton } from '@/components/Logo/KakaoButton';

const rest_api_key = import.meta.env.VITE_REST_API_KEY;
const redirect_uri = import.meta.env.VITE_REDIRECT_URI;
const baseUrl = `${window.location.protocol}//${window.location.host}/`;
const TAG = ['ussum_001', 'ussum_002', 'ussum_003'];

interface type {
subServiceUrl: string;
}

export function RegisterButtonSection({ subServiceUrl }: type) {
const KAKAO_AUTH_URL = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${rest_api_key}&redirect_uri=${baseUrl}${redirect_uri}&service_terms=${TAG}&subServiceUrl=${subServiceUrl}`;

console.log(KAKAO_AUTH_URL);

const handleLogin = () => {
window.location.href = KAKAO_AUTH_URL;
};

return (
<div
style={{
minHeight: '0vh',
display: 'flex',
flexDirection: 'column',
justifyContent: 'flex-end',
overflowY: 'hidden',
}}
>
<div className="flex flex-col items-center text-center">
<h1 className="mb-[-10px] text-xs font-normal">제64대 총학생회</h1>
<h1 className="text-[56px] font-bold">US:SUM</h1>
<div onClick={handleLogin}>
<KakaoButton />
</div>
</div>
</div>
);
}
30 changes: 30 additions & 0 deletions src/pages/kakao/redirect/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { State } from '@/containers/common/Header/const/state';
import { Header } from '@/containers/common/Header/Header';
import { RegisterTextSection } from '@/pages/kakao/containers/RegisterTextSection';
import { RegisterButtonSection } from './containers/RegisterButtonSection';
import { useParams } from 'react-router-dom';

export function KakaoRegisterRedirectPage() {
let { redirect_url } = useParams();

if (redirect_url === undefined) {
redirect_url = 'https://ssuketch60.cafe24.com/';
}

return (
<>
<Header state={State.Onboarding} />
<div className="relative h-screen overflow-hidden">
<div className="top-1/5 pointer-events-none absolute left-1/2 mt-[100px] -translate-x-1/2 -translate-y-1/2 transform">
<RegisterTextSection />
</div>
<div className="z-99 absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform">
<RegisterButtonSection subServiceUrl={redirect_url} />
</div>
<div className="pointer-events-none absolute left-1/2 top-full mt-[-100px] -translate-x-1/2 -translate-y-1/2 transform">
<RegisterTextSection />
</div>
</div>
</>
);
}
78 changes: 27 additions & 51 deletions src/pages/main/containers/NoticeSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ const NoticeSection = () => {
memberCode: selectedSubcategories === '전체' ? '' : selectedSubcategories,
});

interface NoticeListProps {
slice: number;
}

const NoticeList = ({ slice }: NoticeListProps) => {
return data?.data.postListResDto.slice(0, slice).map((notice) => {
let thumbnail = notice.thumbNail || undefined;
if (notice.status === '긴급공지' && thumbnail === undefined) {
thumbnail = `image/default/thumbnail/thumbnail_299px.png`;
}
return (
<PostCardNotice
key={notice.postId}
onClick={() => navigate(`/notice/${notice.postId}`, { state: { postId: notice.postId } })}
badgeType={notice.status}
imgUrl={thumbnail ? thumbnail : `image/default/thumbnail/default_thumbnail.png`}
title={notice.title}
date={formatYYYYMMDD(notice.date)}
profileName={notice.author}
/>
);
});
};

return (
<section className="w-full whitespace-nowrap">
<div className="flex items-center">
Expand Down Expand Up @@ -57,69 +81,21 @@ const NoticeSection = () => {
{/* xs, sm, md */}
{width < 1080 && (
<div className="flex w-[calc(100dvw-3.125rem)] items-start justify-start gap-[1.063rem] overflow-x-scroll pl-0 pr-[1.063rem] pt-[0.625rem] scrollbar-hide lg:px-[11.0rem] xl:px-[11.0rem] xxl:px-[11.0rem]">
{data?.data.postListResDto.slice(0, 2).map((notice) => {
let thumbnail = notice.thumbNail || undefined;
if (notice.status === '긴급공지' && thumbnail === undefined) {
thumbnail = `image/default/thumbnail/thumbnail_299px.png`;
}
return (
<PostCardNotice
key={notice.postId}
onClick={() => navigate(`/notice/${notice.postId}`, { state: { postId: notice.postId } })}
badgeType={notice.status}
imgUrl={thumbnail}
title={notice.title}
date={formatYYYYMMDD(notice.date)}
profileName={notice.author}
/>
);
})}
<NoticeList slice={2} />
</div>
)}

{/* lg */}
{width >= 1080 && width < 1440 && (
<div className="flex w-[calc(100dvw-3.125rem)] items-start justify-start gap-[1.063rem] overflow-x-scroll pl-0 pr-[1.063rem] pt-[0.625rem] scrollbar-hide lg:px-[11.0rem] xl:px-[11.0rem] xxl:px-[11.0rem]">
{data?.data.postListResDto.slice(0, 3).map((notice) => {
let thumbnail = notice.thumbNail || undefined;
if (notice.status === '긴급공지' && thumbnail === undefined) {
thumbnail = `image/default/thumbnail/thumbnail_299px.png`;
}
return (
<PostCardNotice
key={notice.postId}
onClick={() => navigate(`/notice/${notice.postId}`, { state: { postId: notice.postId } })}
badgeType={notice.status}
imgUrl={thumbnail}
title={notice.title}
date={formatYYYYMMDD(notice.date)}
profileName={notice.author}
/>
);
})}
<NoticeList slice={3} />
</div>
)}

{/* xl, xxl */}
{width >= 1440 && (
<div className="flex w-[calc(100dvw-3.125rem)] items-start justify-start gap-[1.063rem] overflow-x-scroll pl-0 pr-[1.063rem] pt-[0.625rem] scrollbar-hide lg:px-[11.0rem] xl:px-[11.0rem] xxl:px-[11.0rem]">
{data?.data.postListResDto.slice(0, 4).map((notice) => {
let thumbnail = notice.thumbNail || undefined;
if (notice.status === '긴급공지' && thumbnail === undefined) {
thumbnail = `image/default/thumbnail/thumbnail_299px.png`;
}
return (
<PostCardNotice
key={notice.postId}
onClick={() => navigate(`/notice/${notice.postId}`, { state: { postId: notice.postId } })}
badgeType={notice.status}
imgUrl={thumbnail}
title={notice.title}
date={formatYYYYMMDD(notice.date)}
profileName={notice.author}
/>
);
})}
<NoticeList slice={4} />
</div>
)}
<Spacing size={68} direction="vertical" />
Expand Down
3 changes: 0 additions & 3 deletions src/pages/notice/hooks/useNoticeToday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,15 @@ export function useTodayPosts(boardCode: string, category: string, subCategory:
let count = 0;
let stopLoading = false;

// 긴급 공지 먼저 처리
for (const post of posts) {
if (post.status === '긴급공지' && isPostToday(post.date)) {
count++;
} else if (post.status === '긴급공지' && !isPostToday(post.date)) {
// 오늘 날짜가 아닌 긴급 공지가 있으면 중단
stopLoading = true;
break;
}
}

// 일반 공지 처리
for (const post of posts) {
if (post.status !== '긴급공지' && isPostToday(post.date)) {
count++;
Expand Down
1 change: 1 addition & 0 deletions src/pages/notice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function NoticePage() {
);
const { todayPostCount, isLoading: isPostsLoading } = useTodayPosts(boardCode, category, subCategory);

console.log(data);
return (
<>
<HeadLayout
Expand Down
4 changes: 3 additions & 1 deletion src/pages/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import { LostDetailPage } from './lost-article/detail/page';
import { LostPatchPage } from './lost-article/patch/page';
import PersonalDataPage from './personal-data/page';
import { Layout } from './layout/headerLayout';
import { KakaoRegisterRedirectPage } from './kakao/redirect/page';

export function MainRouter() {
return (
<Routes>
<Route path="/" element={<Layout />}>
<Route path="/beta" element={<MainPage />} />
<Route path="/" element={<MainPage />} />
{/*소개*/}
<Route path="/intro" element={<IntroPage />} />
<Route path="/intro/edit" element={<IntroEditPage />} />
Expand Down Expand Up @@ -72,6 +73,7 @@ export function MainRouter() {
</Route>
{/*온보딩*/}
<Route path="/register" element={<KakaoRegisterPage />} />
<Route path="/register/redirect" element={<KakaoRegisterRedirectPage />} />
<Route path="/register/:sort" element={<GeneralRegisterPage />} />
<Route path="/auth/callback" element={<KakaoRedirect />} />
</Routes>
Expand Down

0 comments on commit b44c394

Please sign in to comment.