Skip to content

Commit

Permalink
🐛 Fix: 회고 생성일 날짜 형식 수정 및 생성자 닉네임 렌더링 완료 (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongmin59 authored Apr 20, 2024
1 parent 1e3597f commit a20ebee
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/api/@types/Retrospectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface GetRetrospectiveResponseNodes {
startDate: string;
createdDate: string;
updatedDate: string;
username: string;
}

export interface GetRetrospectiveData {
Expand Down
22 changes: 11 additions & 11 deletions src/api/@types/User.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// get
export interface GetUsersRequest {
// userId: number;
}

export interface GetUsersResponse {
userId: number;
username: string;
email: string;
thumbnail: string | null;
phone: string | null;
createDate: Date;
updateDate: Date;
code: number;
data: {
userId: number;
userName: string;
email: string;
thumbnail: string | null;
phone: string | null;
createDate: Date;
updateDate: Date;
};
message: string | null;
}
2 changes: 1 addition & 1 deletion src/api/axiosConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ axiosInstance.interceptors.request.use(

// 헤더에 토큰 추가
config.headers.Authorization = `Bearer ${authToken}`;
console.log('헤더에 토큰 추가 확인', config.headers.Authorization);
// console.log('헤더에 토큰 추가 확인', config.headers.Authorization);
return config;
} catch (err) {
console.error('에러', err);
Expand Down
28 changes: 13 additions & 15 deletions src/components/RetroList/ContentsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import { IoMdPerson } from 'react-icons/io';
import { MdPeople } from 'react-icons/md';
import { RxCounterClockwiseClock } from 'react-icons/rx'; //before
import { useNavigate } from 'react-router-dom';
import { useRecoilState } from 'recoil';
import { PatchRetrospectiveRequest } from '@/api/@types/Retrospectives';
import postImageToS3 from '@/api/imageApi/postImageToS3';
import { patchRetrospective } from '@/api/retrospectivesApi/patchRetrospective';
import Thumbnail from '@/assets/Thumbnail.png';
import Modal from '@/components/RetroList/Modal';
import UserNickname from '@/components/user/UserNickname';
import { useCustomToast } from '@/hooks/useCustomToast';
import { userNicknameState } from '@/recoil/user/userAtom';
import * as S from '@/styles/RetroList/ContentsList.styles';

interface Content {
Expand All @@ -31,6 +28,7 @@ interface Content {
startDate: string;
createdDate: string;
updatedDate: string;
username: string;
}

interface ContentListProps {
Expand All @@ -42,7 +40,6 @@ interface ContentListProps {

const ContentList: React.FC<ContentListProps> = ({ data, viewMode, searchData, setBookmarkUpdate }) => {
// const [contentData, setContentData] = useState<Content[]>(data); 받아온데이터
const [userNickname, setUserNickname] = useRecoilState(userNicknameState);
const [openModalId, setOpenModalId] = useState<number | null>(null);
const toast = useCustomToast();
const [image, setImage] = useState<{ [key: number]: string }>({});
Expand Down Expand Up @@ -73,6 +70,12 @@ const ContentList: React.FC<ContentListProps> = ({ data, viewMode, searchData, s
console.log('filter', filteredData);
const navigate = useNavigate();

const convertToLocalTime = (dateString: string | number | Date) => {
const date = new Date(dateString);
const localTime = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
return localTime.toLocaleString(); // 로컬 타임존으로 변환하여 문자열로 반환
};

useEffect(() => {
const fetchThumbnailsData = async (item: Content) => {
try {
Expand Down Expand Up @@ -138,15 +141,13 @@ const ContentList: React.FC<ContentListProps> = ({ data, viewMode, searchData, s
}}
/>
</div>
<S.RetroUser>
<UserNickname setUserNickname={setUserNickname} /> {/* 생성자 이름(유저 식별 필요) */}
{userNickname}
</S.RetroUser>
<S.RetroUser>{item.username}</S.RetroUser>
<div></div>
<S.RetroDate>
{item.updatedDate && item.updatedDate !== item.startDate
? `${item.updatedDate} 수정`
: item.startDate}
{item.updatedDate !== item.createdDate
? `${convertToLocalTime(item.updatedDate)} 수정`
: convertToLocalTime(item.createdDate)}
{/* {item.updatedDate !== item.createdDate ? `${item.updatedDate} 수정` : item.createdDate} */}
</S.RetroDate>
{item.status === 'NOT_STARTED' && (
<RxCounterClockwiseClock
Expand Down Expand Up @@ -183,10 +184,7 @@ const ContentList: React.FC<ContentListProps> = ({ data, viewMode, searchData, s
<S.ListTitleBox onClick={() => navigate(`/section?retrospectiveId=${item.id}&teamId=${item.teamId}`)}>
{item.title}
</S.ListTitleBox>
<S.ListUserBox>
<UserNickname setUserNickname={setUserNickname} /> {/* 생성자이름(유저 식별 필요) */}
{userNickname}
</S.ListUserBox>
<S.ListUserBox>{item.username}</S.ListUserBox>
<S.ListTimeBox>
{item.updatedDate && item.updatedDate !== item.startDate ? `${item.updatedDate}` : item.startDate}
</S.ListTimeBox>
Expand Down
23 changes: 14 additions & 9 deletions src/components/createRetro/modal/ImageUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,21 @@ const ImageUpload: React.FC<ImageUploadProps> = ({ onChange }) => {
</Button>
</label>
</Center>

{/* 이미지 미리보기 */}
{imagePreview && (
<Center mt={4}>
<Image src={imagePreview} alt="Selected Image" maxH="200px" />
<Button variant="outline" borderColor="gray.700" size="md" width="15rem" onClick={handleRemoveImage}>
이미지 제거
</Button>
</Center>
)}
<Center>
{imagePreview && (
<Box mt={4}>
<Center>
<Image src={imagePreview} alt="Selected Image" maxH="200px" />
</Center>
<Center mt={2}>
<Button variant="outline" borderColor="gray.700" size="md" width="15rem" onClick={handleRemoveImage}>
이미지 제거
</Button>
</Center>
</Box>
)}
</Center>
</Box>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const MyPage = () => {

<S.MyPageBGContainer>
<S.MyPageContainer>
{userData?.thumbnail}
{userData?.data.thumbnail}
<ImageUploader image={image} setImage={setImage} />
<NicknameBox />
<EmailBox />
Expand Down
4 changes: 4 additions & 0 deletions src/pages/RetroListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const RetroListPage = () => {
startDate: formatDate(item.startDate),
createdDate: formatDate(item.createdDate),
updatedDate: formatDate(item.updatedDate),
username: item.username,
}));
setRetroData(rawData);
}, [data.nodes]);
Expand All @@ -104,6 +105,7 @@ const RetroListPage = () => {
startDate: formatDate(item.startDate),
createdDate: formatDate(item.createdDate),
updatedDate: formatDate(item.updatedDate),
username: item.username,
}));
setRetroData(filtered);
} else if (filterType === 'Teams') {
Expand All @@ -121,6 +123,7 @@ const RetroListPage = () => {
startDate: formatDate(item.startDate),
createdDate: formatDate(item.createdDate),
updatedDate: formatDate(item.updatedDate),
username: item.username,
}));
setRetroData(filtered);
} else if (filterType === 'ALL') {
Expand All @@ -136,6 +139,7 @@ const RetroListPage = () => {
startDate: formatDate(item.startDate),
createdDate: formatDate(item.createdDate),
updatedDate: formatDate(item.updatedDate),
username: item.username,
}));
setRetroData(rawData);
}
Expand Down

0 comments on commit a20ebee

Please sign in to comment.