Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/profile/src/pages/ProfilePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Global } from '@emotion/react';
import Header from '~/components/Header';
import Styled, { bottomSheetOverrides } from './ProfilePage.styles';
import Layout from '~/components/Layout';
import { useUserByUserCodeV2 } from '@boolti/api';
import { useUserByUserCodeV2, useYoutubeVideoDuration } from '@boolti/api';
import {
formatDateTimeWithWeekday,
formatDateWithWeekday,
Expand All @@ -18,7 +18,6 @@ import {
import { Meta } from '~/components/Meta';
import { PROFILE_URL } from '~/constants/url';
import { EXTERNAL_URL } from '~/constants/external';
import { useYoutubeVideoDuration } from '~/hooks/useYoutubeVideoDuration';

interface VideoCardProps {
videoUrl: string;
Expand Down
3 changes: 1 addition & 2 deletions apps/profile/src/pages/ProfileVideosPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import Styled from './ProfileVideosPage.styles';
import { BooltiIcon } from '@boolti/icon';
import Header from '~/components/Header';
import Layout from '~/components/Layout';
import { useUserVideos } from '@boolti/api';
import { useUserVideos, useYoutubeVideoDuration } from '@boolti/api';
import { getYoutubeVideoId, getYoutubeThumbnailUrl, formatYoutubeDuration } from '~/utils';
import { useYoutubeVideoDuration } from '~/hooks/useYoutubeVideoDuration';

interface VideoItemProps {
videoUrl: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import useAdminSalesTicketList from './useAdminSalesTicketList';
import useAdminReservationSummaryV2 from './useAdminReservationSummaryV2';
import usePopup from './usePopup';
import useSuperAdminShowSettlementStatement from './useSuperAdminShowSettlementStatement';
import useYoutubeVideoDuration from './useYoutubeVideoDuration';

export {
useCastTeamList,
Expand Down Expand Up @@ -100,4 +101,5 @@ export {
useSuperAdminInvitationCodeList,
usePopup,
useSuperAdminShowSettlementStatement,
useYoutubeVideoDuration,
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface YouTubeVideoData {
duration: string | null;
}

export const useYoutubeVideoDuration = (
const useYoutubeVideoDuration = (
videoId: string | null,
): UseQueryResult<YouTubeVideoData, Error> => {
return useQuery({
Expand All @@ -26,7 +26,6 @@ export const useYoutubeVideoDuration = (

const apiKey = import.meta.env.VITE_YOUTUBE_API_KEY;
if (!apiKey) {
console.warn('YouTube API key is not configured');
return { title: null, duration: null };
}

Expand All @@ -45,12 +44,13 @@ export const useYoutubeVideoDuration = (
duration: data.items?.[0]?.contentDetails?.duration ?? null,
};
} catch (error) {
console.error('Error fetching YouTube video data:', error);
return { title: null, duration: null };
}
},
enabled: !!videoId,
staleTime: 1000 * 60 * 60 * 24, // 24시간 캐싱
staleTime: 1000 * 60 * 60 * 24,
retry: 1,
});
};

export default useYoutubeVideoDuration;
1 change: 1 addition & 0 deletions packages/api/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface ImportMetaEnv {
readonly VITE_KAKAO_REST_API_KEY: string;
readonly VITE_BASE_API_URL: string;
readonly VITE_IS_SUPER_ADMIN: string;
readonly VITE_YOUTUBE_API_KEY: string;
}

interface ImportMeta {
Expand Down
Loading