Skip to content

Commit

Permalink
docs: TimeAgo 함수 utils로 이관
Browse files Browse the repository at this point in the history
  • Loading branch information
Byukchong committed Jul 16, 2024
1 parent 34d9690 commit b1dc2ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/NavigationDropdown/NotificationDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import StatusIndicator from '../StatusIndicator/StatusIndicator';
import useDeleteNotification from '@/hooks/useDeleteNotification';
import { useInView } from 'react-intersection-observer';
import useGetNotificationList from '@/hooks/useGetNotificationList';
import getTimeAgoString from '@/hooks/useGetTimeAgo';
import formatTimeAgo from '@/utils/formatTimeAgo';

export default function NotificationDropdown({
data,
Expand Down Expand Up @@ -87,7 +87,7 @@ export default function NotificationDropdown({
<div className="w-[298px] h-[44px] mb-[4px]">
<p>{ContentWithHighlights(notification.content)}</p>
</div>
<p>{getTimeAgoString(notification.updatedAt)}</p>
<p>{formatTimeAgo(notification.updatedAt)}</p>
</div>
))}
{hasNextPage && <div ref={ref} />}
Expand Down
7 changes: 6 additions & 1 deletion components/ReservationListCard/ReservationListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { apiEditMyReservation } from '@/pages/api/myReservations/apiMyReservatio
import { useUserData } from '@/hooks/useUserData';
import { formatCurrency } from '@/utils/formatCurrency';
import Link from 'next/link';
import Spinner from '../Spinner/Spinner';

const ReservationListCard = ({ reservationData }: ReservationCardProps) => {
const { openModal, closeModal } = useModal();
Expand All @@ -23,7 +24,7 @@ const ReservationListCard = ({ reservationData }: ReservationCardProps) => {
};

const { openPopup } = usePopup();
const userData = useUserData();
const { userData, isLoading } = useUserData();
const queryClient = useQueryClient();

const EditMyReservationMutation = useMutation({
Expand All @@ -47,6 +48,10 @@ const ReservationListCard = ({ reservationData }: ReservationCardProps) => {
});
};

if (isLoading) {
return <Spinner />;
}

return (
<div className="h-[212px] relative flex rounded-3xl shadow-card overflow-hidden">
<div className="min-w-[204px] h-[204px] relative">
Expand Down
2 changes: 1 addition & 1 deletion hooks/useReservationList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const INITIAL_SIZE = 4;
const REFETCH_SIZE = 1;

export const useReservationList = (filterOption: statusType | undefined) => {
const userData = useUserData();
const { userData } = useUserData();

const { data, fetchNextPage, hasNextPage, isLoading, isFetchingNextPage } =
useInfiniteQuery<MyReservationListResponse>({
Expand Down
2 changes: 1 addition & 1 deletion hooks/useGetTimeAgo.ts → utils/formatTimeAgo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function getTimeAgoString(updatedAt: string): string {
export default function formatTimeAgo(updatedAt: string): string {
const updatedAtUTC = Date.parse(updatedAt);
const now = new Date();
const diff = now.getTime() - updatedAtUTC;
Expand Down

0 comments on commit b1dc2ed

Please sign in to comment.