Skip to content

Commit

Permalink
feat(menu): rename constant
Browse files Browse the repository at this point in the history
  • Loading branch information
CarinaDraganJW committed Sep 17, 2024
1 parent ffc127e commit 5f55cb1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const EPG_TYPE = {
viewNexa: 'viewnexa',
} as const;

export const APP_CONTENT_TYPE = {
export const APP_CONFIG_ITEM_TYPE = {
playlist: 'playlist',
continue_watching: 'continue_watching',
favorites: 'favorites',
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/utils/urlFormatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AppMenuType } from '@jwp/ott-common/types/config';
import type { PlaylistItem } from '../../types/playlist';
import { PATH_MEDIA, PATH_PLAYLIST, PATH_CONTENT_LIST } from '../paths';
import { logWarn } from '../logger';
import { APP_CONTENT_TYPE } from '../constants';
import { APP_CONFIG_ITEM_TYPE } from '../constants';

import { getLegacySeriesPlaylistIdFromEpisodeTags, getSeriesPlaylistIdFromCustomParams } from './media';

Expand Down Expand Up @@ -134,11 +134,11 @@ export const contentListURL = (id: string, title?: string) => {

export const determinePath = ({ type, contentId }: { type: AppMenuType | undefined; contentId: string }) => {
switch (type) {
case APP_CONTENT_TYPE.content_list:
case APP_CONFIG_ITEM_TYPE.content_list:
return contentListURL(contentId);
case APP_CONTENT_TYPE.media:
case APP_CONFIG_ITEM_TYPE.media:
return singleMediaURL(contentId);
case APP_CONTENT_TYPE.playlist:
case APP_CONFIG_ITEM_TYPE.playlist:
return playlistURL(contentId);
default:
return '';
Expand Down
4 changes: 2 additions & 2 deletions packages/common/types/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APP_CONTENT_TYPE } from '../src/constants';
import type { APP_CONFIG_ITEM_TYPE } from '../src/constants';

import type { AdScheduleUrls, AdDeliveryMethod } from './ad-schedule';

Expand Down Expand Up @@ -43,7 +43,7 @@ export type Drm = {
defaultPolicyId: string;
};

export type AppContentType = keyof typeof APP_CONTENT_TYPE;
export type AppContentType = keyof typeof APP_CONFIG_ITEM_TYPE;
export type AppMenuType = Extract<AppContentType, 'playlist' | 'content_list' | 'media'>;
export type AppShelfType = Extract<AppContentType, 'playlist' | 'content_list' | 'continue_watching' | 'favorites'>;

Expand Down
8 changes: 4 additions & 4 deletions packages/hooks-react/src/usePlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isScheduledOrLiveMedia } from '@jwp/ott-common/src/utils/liveEvent';
import { isTruthyCustomParamValue } from '@jwp/ott-common/src/utils/common';
import type { ApiError } from '@jwp/ott-common/src/utils/api';
import type { AppMenuType } from '@jwp/ott-common/types/config';
import { APP_CONTENT_TYPE } from '@jwp/ott-common/src/constants';
import { APP_CONFIG_ITEM_TYPE } from '@jwp/ott-common/src/constants';
import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore';

const placeholderData = generatePlaylistPlaceholder(30);
Expand Down Expand Up @@ -35,7 +35,7 @@ export const getPlaylistQueryOptions = ({
enabled: !!contentId && enabled,
queryKey: ['playlist', type, contentId, params],
queryFn: async () => {
if (type === APP_CONTENT_TYPE.playlist) {
if (type === APP_CONFIG_ITEM_TYPE.playlist) {
const playlist = await apiService.getPlaylistById(contentId, params);

// This pre-caches all playlist items and makes navigating a lot faster.
Expand All @@ -44,7 +44,7 @@ export const getPlaylistQueryOptions = ({
});

return playlist;
} else if (type === APP_CONTENT_TYPE.content_list) {
} else if (type === APP_CONFIG_ITEM_TYPE.content_list) {
const contentList = await apiService.getContentList({ siteId, id: contentId });

return contentList;
Expand All @@ -67,7 +67,7 @@ export default function usePlaylist(
params: GetPlaylistParams = {},
enabled: boolean = true,
usePlaceholderData: boolean = true,
type: AppMenuType = APP_CONTENT_TYPE.playlist,
type: AppMenuType = APP_CONFIG_ITEM_TYPE.playlist,
) {
const queryClient = useQueryClient();
const siteId = useConfigStore((state) => state.config.siteId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useParams } from 'react-router';
import { useTranslation } from 'react-i18next';
import type { Playlist } from '@jwp/ott-common/types/playlist';
import { APP_CONTENT_TYPE, PLAYLIST_CONTENT_TYPE } from '@jwp/ott-common/src/constants';
import { APP_CONFIG_ITEM_TYPE, PLAYLIST_CONTENT_TYPE } from '@jwp/ott-common/src/constants';
import { ScreenMap } from '@jwp/ott-common/src/utils/ScreenMap';
import usePlaylist from '@jwp/ott-hooks-react/src/usePlaylist';
import type { AppMenuType } from '@jwp/ott-common/types/config';
Expand Down Expand Up @@ -43,7 +43,7 @@ const PlaylistScreenRouter = ({ type }: { type: AppMenuType }) => {
return <ErrorPage title={t('empty_shelves_heading')} message={t('empty_shelves_description')} />;
}

const Screen = type === APP_CONTENT_TYPE.content_list ? contentScreenMap.getScreen(data) : playlistScreenMap.getScreen(data);
const Screen = type === APP_CONFIG_ITEM_TYPE.content_list ? contentScreenMap.getScreen(data) : playlistScreenMap.getScreen(data);

return <Screen data={data} isLoading={isFetching} />;
};
Expand Down
6 changes: 3 additions & 3 deletions platforms/web/src/containers/AppRoutes/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MediaScreenRouter from '@jwp/ott-ui-react/src/pages/ScreenRouting/MediaSc
import PlaylistScreenRouter from '@jwp/ott-ui-react/src/pages/ScreenRouting/PlaylistScreenRouter';
import Layout from '@jwp/ott-ui-react/src/containers/Layout/Layout';
import { PATH_ABOUT, PATH_CONTENT_LIST, PATH_LEGACY_SERIES, PATH_MEDIA, PATH_PLAYLIST, PATH_SEARCH, PATH_USER } from '@jwp/ott-common/src/paths';
import { APP_CONTENT_TYPE } from '@jwp/ott-common/src/constants';
import { APP_CONFIG_ITEM_TYPE } from '@jwp/ott-common/src/constants';

import RoutesContainer from '#src/containers/RoutesContainer/RoutesContainer';

Expand All @@ -24,8 +24,8 @@ export default function AppRoutes() {
<Route element={<RoutesContainer />}>
<Route element={<Layout />} errorElement={<RootErrorPage />}>
<Route index element={<Home />} />
<Route path={PATH_PLAYLIST} element={<PlaylistScreenRouter type={APP_CONTENT_TYPE.playlist} />} />
<Route path={PATH_CONTENT_LIST} element={<PlaylistScreenRouter type={APP_CONTENT_TYPE.content_list} />} />
<Route path={PATH_PLAYLIST} element={<PlaylistScreenRouter type={APP_CONFIG_ITEM_TYPE.playlist} />} />
<Route path={PATH_CONTENT_LIST} element={<PlaylistScreenRouter type={APP_CONFIG_ITEM_TYPE.content_list} />} />
<Route path={PATH_MEDIA} element={<MediaScreenRouter />} />
<Route path={PATH_LEGACY_SERIES} element={<LegacySeries />} />
<Route path={PATH_SEARCH} element={<Search />} />
Expand Down

0 comments on commit 5f55cb1

Please sign in to comment.