Skip to content

Commit

Permalink
Merge pull request #1559 from 42organization/agenda
Browse files Browse the repository at this point in the history
[test-deploy] 배포 전 마지막 테스트
  • Loading branch information
cweedlee authored Sep 8, 2024
2 parents 3b42838 + d79dce4 commit 5af8f9b
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 63 deletions.
2 changes: 1 addition & 1 deletion components/agenda/Home/AgendaList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const AgendaListItem = ({
${className && className}`}
style={{
background: `linear-gradient(180deg, #fff 5rem, rgba(0, 0, 0, 0) 10rem), url(${
agendaInfo.agendaPosterUrl || '/image/agenda/42.jpg'
agendaInfo.agendaPosterUrl || 'var(--default-bg)'
}) lightgray 50% / cover no-repeat`,
}}
key={idx}
Expand Down
2 changes: 1 addition & 1 deletion components/agenda/Ticket/Ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface TicketProps {
const Ticket = ({ type }: { type: string }) => {
const { data } = useFetchGet<TicketProps>({ url: '/ticket' });
const { openModal } = useModal();

console.log(data);
return (
<>
{type === 'page' ? (
Expand Down
2 changes: 1 addition & 1 deletion components/agenda/agendaDetail/AgendaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function AgendaInfo({
className={`${styles.infoContainer} ${containerSize}`}
style={{
background: `linear-gradient(0deg, #fff 7rem, rgba(0, 0, 0, 0) 10rem), url(${
agendaData.agendaPosterUrl || '/image/agenda/42.jpg'
agendaData.agendaPosterUrl || 'var(--color-bg)'
}) lightgray 50% / cover no-repeat`,
}}
>
Expand Down
2 changes: 1 addition & 1 deletion components/agenda/utils/PageController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const PageController = ({
className={styles.agendaInfoContainer}
style={{
background: `linear-gradient(180deg, #fff 7rem, rgba(0, 0, 0, 0) 10rem), url(${
data[current]?.agendaPosterUrl || '/image/agenda/42.jpg'
data[current]?.agendaPosterUrl || 'var(--color-bg)'
}) lightgray 50% / cover no-repeat`,
}}
>
Expand Down
2 changes: 1 addition & 1 deletion components/takgu/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function Header() {
<FiMenu className={styles.menuIcon} onClick={openMenuBarHandler} />
)}
</div>
<Link className={styles.logoWrap} href={'/takgu'}>
<Link className={styles.logoWrap} href={'/'}>
42GG
</Link>
<div className={styles.headerRight}>
Expand Down
6 changes: 5 additions & 1 deletion components/toastmsg/toastmsg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export default function CustomizedSnackbars() {
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Snackbar open={clicked} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity={severity} sx={{ width: '100%' }}>
<Alert
onClose={handleClose}
severity={severity}
sx={{ width: '100%', color: 'white' }}
>
{message}
</Alert>
</Snackbar>
Expand Down
4 changes: 2 additions & 2 deletions hooks/agenda/useFetchGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const useFetchGet = <T>({ url, isReady = true, params }: FetchGetProps) => {
console.error(error);
setError('get error');
}
}, [url, params]);
}, [url, isReady, params]);

useEffect(() => {
if (url) {
getData(); // 조건에 맞을 때만 getData 호출
}
}, [url, JSON.stringify(params)]);
}, [url, isReady, JSON.stringify(params)]);

return { data, status, error, getData };
};
Expand Down
108 changes: 56 additions & 52 deletions pages/agenda/profile/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,78 @@ import usePageNation from 'hooks/agenda/usePageNation';
import styles from 'styles/agenda/Profile/AgendaProfile.module.scss';

const AgendaProfile = () => {
const intraId = useIntraId(); // 쿼리의 id
const userIntraId = useUser()?.intraId; // 현재 나의 intraId
const queryIntraId = useIntraId(); // 쿼리의 id
const myIntraId = useUser()?.intraId; // 현재 나의 intraId
const [profileUrl, setProfileUrl] = useState<string>('/profile');
const [myProfileCheck, setMyProfileCheck] = useState<boolean | null>(null);
const isIntraId = useRef(false); // 인트라 아이디가 42에 있는지 확인
const isAgendaId = useRef(false); // 인트라 아이디가 agenda에 있는지 확인
const isMyProfile = useRef(false); // 내 프로필 페이지인지 아닌지 확인
const [isIntraId, setIsIntraId] = useState<boolean>(false); // 인트라 아이디가 42에 있는지 확인
const [isAgendaId, setIsAgendaId] = useState<boolean>(false); // 인트라 아이디가 agenda에 있는지 확인

useEffect(() => {
if (intraId && userIntraId) {
if (intraId === userIntraId) {
setMyProfileCheck(true);
} else {
setProfileUrl(`/profile/${intraId}`);
setMyProfileCheck(false);
}
}
}, [intraId, userIntraId]);
const { data: intraData, getData: getIntraData } =
useFetchGet<IntraProfileDataProps>({
url: `/profile/intra/${intraId}`,
isReady: Boolean(intraId),
});

/** Agenda API GET */
/** API GET */
// GET: intraData (42 인트라 데이터 가져오기)
const { data: intraData } = useFetchGet<IntraProfileDataProps>({
url: `/profile/intra/${queryIntraId}`,
isReady: Boolean(queryIntraId),
});
// GET: agendaProfileData (GG 아젠다 유저 데이터 가져오기)
const { data: agendaProfileData, getData: getAgendaProfileData } =
useFetchGet<AgendaProfileDataProps>({
url: profileUrl,
// 본인이거나 42에 아이디가 있는 경우에만 데이터 요청
isReady: Boolean(
intraId === userIntraId || (intraId && isIntraId.current)
),
isReady: isIntraId,
});

// useEffect(() => {
// if (intraId) {
// getProfileData();
// }
// }, [intraId]);

// host current
// GET: host current
const {
content: hostCurrentListData,
PagaNationElementProps: PagaNationHostCurrent,
} = usePageNation<MyTeamDataProps>({
url: `/host/current/list/${intraId}`,
isReady: Boolean(intraId && isAgendaId.current),
url: `/host/current/list/${queryIntraId}`,
isReady: isAgendaId,
});

// current team
// GET: current team
const currentListData = useFetchGet<MyTeamDataProps[]>({
url: '/profile/current/list',
isReady: isAgendaId,
}).data;

// host history
// GET: host history
const {
content: hostHistoryListData,
PagaNationElementProps: PagaNationHostHistory,
} = usePageNation<HistoryItemProps>({
url: `/host/history/list/${intraId}`,
isReady: Boolean(intraId && isAgendaId.current),
url: `/host/history/list/${queryIntraId}`,
isReady: isAgendaId,
});

// history
// GET: history
const {
content: historyListData,
PagaNationElementProps: PagaNationHistory,
} = usePageNation<HistoryItemProps>({
url: `/profile/history/list/${intraId}`,
isReady: Boolean(intraId && isAgendaId.current),
url: `/profile/history/list/${queryIntraId}`,
isReady: isAgendaId,
});

if (!intraId || !userIntraId) {
/** useEffect */
useEffect(() => {
// 1. queryIntraId와 myIntraId가 있을 때 프로필 URL 설정
if (queryIntraId && myIntraId) {
if (queryIntraId === myIntraId) {
isMyProfile.current = true;
} else {
isMyProfile.current = false;
setProfileUrl(`/profile/${queryIntraId}`); // 다른 유저 프로필 URL 설정
}
}
// 2. intraData가 있으면 인트라 아이디가 42에 있다는 뜻이므로 isIntraId = true
if (intraData) {
setIsIntraId(true);
}
// 3. agendaProfileData가 있으면 아젠다에 등록된 사용자이므로 isAgendaId = true
if (agendaProfileData) {
setIsAgendaId(true);
}
}, [queryIntraId, myIntraId, intraData, agendaProfileData]);

/** UI Rendering */
if (!queryIntraId || !myIntraId) {
return <AgendaLoading />;
}
return (
Expand All @@ -101,9 +101,9 @@ const AgendaProfile = () => {
<AgendaUserSearchBar />
</div>
{/* ProfileCard */}
{intraData && intraId && (
{intraData && (
<ProfileCard
userIntraId={intraId}
userIntraId={queryIntraId}
userContent={
agendaProfileData?.userContent ||
'GG에 가입하지 않은 사용자입니다.'
Expand All @@ -112,11 +112,15 @@ const AgendaProfile = () => {
imageUrl={intraData.imageUrl}
achievements={intraData.achievements}
getProfileData={getAgendaProfileData}
isMyProfile={myProfileCheck}
isMyProfile={isMyProfile.current}
/>
)}
{/* Ticket */}
{myProfileCheck ? <Ticket type='component' /> : ''}
{isMyProfile.current && agendaProfileData ? (
<Ticket type='component' />
) : (
''
)}
{/* Host Current List */}
{hostCurrentListData && hostCurrentListData.length > 0 ? (
<>
Expand All @@ -127,7 +131,7 @@ const AgendaProfile = () => {
''
)}
{/* Current List */}
{myProfileCheck && currentListData ? (
{isMyProfile.current && currentListData ? (
<CurrentList currentListData={currentListData} isHost={false} />
) : (
''
Expand Down
2 changes: 1 addition & 1 deletion styles/agenda/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $bg-color-deadline-finish: rgba(102, 58, 142, 0.8);
$bg-color-deadline-cancel: rgba(18, 18, 18, 0.8);

$agenda-list-bg: linear-gradient(180deg, #fff 65px, rgba(0, 0, 0, 0) 100%),
url('/image/agenda/42.jpg') lightgray 50% / cover no-repeat;
var(--color-bg) lightgray 50% / cover no-repeat;

// font-family
$font-text-bold: '11StreetGothicBold';
Expand Down
1 change: 0 additions & 1 deletion styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ h4,
h5,
h6,
span,
div,
li,
ul,
ol,
Expand Down
2 changes: 1 addition & 1 deletion types/agenda/profile/profileCardTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export interface ProfileCardProps {
imageUrl: string;
achievements: AchievementProps[];
getProfileData: () => void;
isMyProfile: boolean | null;
isMyProfile: boolean;
}

0 comments on commit 5af8f9b

Please sign in to comment.