From d556c022fa7285f0874ee2ce9c45986d2a100950 Mon Sep 17 00:00:00 2001 From: Henry Orozco Date: Thu, 7 Mar 2024 15:48:28 -0600 Subject: [PATCH 1/3] feat: add playlist player page --- package-lock.json | 6 +- public/compiled-lang/br.json | 12 ++-- public/compiled-lang/de.json | 12 ++-- public/compiled-lang/en.json | 12 ++-- public/compiled-lang/es.json | 12 ++-- public/compiled-lang/fr.json | 12 ++-- public/compiled-lang/ja.json | 12 ++-- public/compiled-lang/ru.json | 12 ++-- public/compiled-lang/zh.json | 12 ++-- public/lang/br.json | 13 ++-- public/lang/de.json | 6 +- public/lang/en.json | 6 +- public/lang/es.json | 6 +- public/lang/fr.json | 6 +- public/lang/ja.json | 6 +- public/lang/ru.json | 6 +- public/lang/zh.json | 6 +- src/components/molecules/card/playlist.tsx | 16 +---- src/components/molecules/player.tsx | 4 +- .../molecules/playlistTypeLockup.tsx | 25 +++++++ src/components/molecules/teaseRecording.tsx | 2 +- src/components/organisms/recording.tsx | 72 +++++++++++++------ .../library/playlist/detail.graphql | 2 + src/containers/library/playlist/detail.tsx | 32 +++++---- src/containers/playlist/item.graphql | 16 +++++ src/containers/playlist/item.tsx | 51 +++++++++++++ src/containers/song/books/track.tsx | 12 ++-- src/lib/routes/index.ts | 2 + src/lib/routes/library.ts | 2 +- src/lib/routes/playlists.ts | 11 +++ .../library/{playlist => playlists}/[id].ts | 0 .../playlists/{[id].ts => [playlist].ts} | 6 +- .../[playlist]/items/[id]/[[...slugs]].tsx | 34 +++++++++ 33 files changed, 300 insertions(+), 144 deletions(-) create mode 100644 src/components/molecules/playlistTypeLockup.tsx create mode 100644 src/containers/playlist/item.graphql create mode 100644 src/containers/playlist/item.tsx create mode 100644 src/lib/routes/playlists.ts rename src/pages/[language]/library/{playlist => playlists}/[id].ts (100%) rename src/pages/[language]/playlists/{[id].ts => [playlist].ts} (89%) create mode 100644 src/pages/[language]/playlists/[playlist]/items/[id]/[[...slugs]].tsx diff --git a/package-lock.json b/package-lock.json index bbe7cefd8..239574d15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13892,9 +13892,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001588", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001588.tgz", - "integrity": "sha512-+hVY9jE44uKLkH0SrUTqxjxqNTOWHsbnQDIKjwkZ3lNTzUUVdBLBGXtj/q5Mp5u98r3droaZAewQuEDzjQdZlQ==", + "version": "1.0.30001596", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001596.tgz", + "integrity": "sha512-zpkZ+kEr6We7w63ORkoJ2pOfBwBkY/bJrG/UZ90qNb45Isblu8wzDgevEOrRL1r9dWayHjYiiyCMEXPn4DweGQ==", "funding": [ { "type": "opencollective", diff --git a/public/compiled-lang/br.json b/public/compiled-lang/br.json index 5c77943a1..420818901 100644 --- a/public/compiled-lang/br.json +++ b/public/compiled-lang/br.json @@ -901,12 +901,6 @@ "value": " ensinamentos" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "Playlist" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -3767,6 +3761,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "Outros itens na Playlist" + } + ], "organism-recording__readAlongLabel": [ { "type": 0, diff --git a/public/compiled-lang/de.json b/public/compiled-lang/de.json index 5338ad93c..0d2ec28ba 100644 --- a/public/compiled-lang/de.json +++ b/public/compiled-lang/de.json @@ -381,12 +381,6 @@ "value": " Lehren" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "Playlist" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -2679,6 +2673,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "Andere Elemente in der Playlist" + } + ], "organism-recording__readByLabel": [ { "type": 0, diff --git a/public/compiled-lang/en.json b/public/compiled-lang/en.json index 68187325d..18a377939 100644 --- a/public/compiled-lang/en.json +++ b/public/compiled-lang/en.json @@ -871,12 +871,6 @@ "value": " teachings" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "Playlist" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -3865,6 +3859,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "Other items in Playlist" + } + ], "organism-recording__readAlongLabel": [ { "type": 0, diff --git a/public/compiled-lang/es.json b/public/compiled-lang/es.json index c06a6cbdc..afcd85176 100644 --- a/public/compiled-lang/es.json +++ b/public/compiled-lang/es.json @@ -381,12 +381,6 @@ "value": " lecciones" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "Lista de reproducción" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -2687,6 +2681,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "Otros elementos en la lista de reproducción" + } + ], "organism-recording__readByLabel": [ { "type": 0, diff --git a/public/compiled-lang/fr.json b/public/compiled-lang/fr.json index 18c7a520d..d7add10db 100644 --- a/public/compiled-lang/fr.json +++ b/public/compiled-lang/fr.json @@ -381,12 +381,6 @@ "value": " enseignements" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "Playlist" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -2659,6 +2653,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "Autres éléments dans la liste de lecture" + } + ], "organism-recording__readByLabel": [ { "type": 0, diff --git a/public/compiled-lang/ja.json b/public/compiled-lang/ja.json index e74ae2d76..84cc0bb2f 100644 --- a/public/compiled-lang/ja.json +++ b/public/compiled-lang/ja.json @@ -389,12 +389,6 @@ "value": "個" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "プレイリスト" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -2671,6 +2665,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "プレイリスト内のその他のアイテム" + } + ], "organism-recording__readByLabel": [ { "type": 0, diff --git a/public/compiled-lang/ru.json b/public/compiled-lang/ru.json index 68532b025..52d20e958 100644 --- a/public/compiled-lang/ru.json +++ b/public/compiled-lang/ru.json @@ -381,12 +381,6 @@ "value": " темы" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "Список воспроизведений" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -2667,6 +2661,12 @@ "value": "index" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "Другие элементы в плейлисте" + } + ], "organism-recording__readByLabel": [ { "type": 0, diff --git a/public/compiled-lang/zh.json b/public/compiled-lang/zh.json index 415648368..e8ad9a7e5 100644 --- a/public/compiled-lang/zh.json +++ b/public/compiled-lang/zh.json @@ -385,12 +385,6 @@ "value": "篇证道" } ], - "cardPlaylist__typeLabel": [ - { - "type": 0, - "value": "播放清单" - } - ], "cardPost__readingDuration": [ { "type": 1, @@ -2691,6 +2685,12 @@ "value": "部分" } ], + "organism-recording__playlistTitle": [ + { + "type": 0, + "value": "播放清單中的其他項目" + } + ], "organism-recording__readByLabel": [ { "type": 0, diff --git a/public/lang/br.json b/public/lang/br.json index 42232463b..9957da018 100644 --- a/public/lang/br.json +++ b/public/lang/br.json @@ -1332,15 +1332,6 @@ }, - "cardPlaylist__typeLabel": { - - - "string": "Playlist" - - - }, - - "cardPost__readingDuration": { @@ -5312,6 +5303,10 @@ }, + "organism-recording__playlistTitle": { + "string": "Outros itens na Playlist" + }, + "organism-recording__readAlongLabel": { diff --git a/public/lang/de.json b/public/lang/de.json index 87338c042..cd73eb54b 100644 --- a/public/lang/de.json +++ b/public/lang/de.json @@ -137,9 +137,6 @@ "comment": "Card person teachings count label", "string": "{count} Lehren" }, - "cardPlaylist__typeLabel": { - "string": "Playlist" - }, "cardPost__readingDuration": { "comment": "Card post reading duration", "string": "{duration} lesen" @@ -929,6 +926,9 @@ "comment": "recording part info", "string": "Teil {index}" }, + "organism-recording__playlistTitle": { + "string": "Andere Elemente in der Playlist" + }, "organism-recording__readByLabel": { "string": "Lesen nach {name}" }, diff --git a/public/lang/en.json b/public/lang/en.json index d2231c755..d43974cef 100644 --- a/public/lang/en.json +++ b/public/lang/en.json @@ -421,9 +421,6 @@ "comment": "Card person teachings count label", "string": "{count} teachings" }, - "cardPlaylist__typeLabel": { - "string": "Playlist" - }, "cardPost__readingDuration": { "comment": "Card post reading duration", "string": "{duration} read" @@ -1826,6 +1823,9 @@ "comment": "recording part info", "string": "Part {index}" }, + "organism-recording__playlistTitle": { + "string": "Other items in Playlist" + }, "organism-recording__readAlongLabel": { "string": "Read Along" }, diff --git a/public/lang/es.json b/public/lang/es.json index 9a41b31c1..1751fe894 100644 --- a/public/lang/es.json +++ b/public/lang/es.json @@ -137,9 +137,6 @@ "comment": "Tarjeta persona enseñanzas contar etiqueta", "string": "{count} lecciones" }, - "cardPlaylist__typeLabel": { - "string": "Lista de reproducción" - }, "cardPost__readingDuration": { "comment": "Duración de la lectura del poste de la tarjeta", "string": "{duration} leer" @@ -929,6 +926,9 @@ "comment": "grabación de información de la pieza", "string": "Parte {index}" }, + "organism-recording__playlistTitle": { + "string": "Otros elementos en la lista de reproducción" + }, "organism-recording__readByLabel": { "string": "Leído por {name}" }, diff --git a/public/lang/fr.json b/public/lang/fr.json index ccc062d7b..14103335e 100644 --- a/public/lang/fr.json +++ b/public/lang/fr.json @@ -137,9 +137,6 @@ "comment": "Card person teachings count label", "string": "{count} enseignements" }, - "cardPlaylist__typeLabel": { - "string": "Playlist" - }, "cardPost__readingDuration": { "comment": "Card post reading duration", "string": "{duration} de lecture" @@ -929,6 +926,9 @@ "comment": "recording part info", "string": "Partie {index}" }, + "organism-recording__playlistTitle": { + "string": "Autres éléments dans la liste de lecture" + }, "organism-recording__readByLabel": { "string": "Lu par {name}" }, diff --git a/public/lang/ja.json b/public/lang/ja.json index c1d453695..e95eb3b49 100644 --- a/public/lang/ja.json +++ b/public/lang/ja.json @@ -137,9 +137,6 @@ "comment": "Card person teachings count label", "string": "レッスン{count}個" }, - "cardPlaylist__typeLabel": { - "string": "プレイリスト" - }, "cardPost__readingDuration": { "comment": "Card post reading duration", "string": "{duration}分" @@ -929,6 +926,9 @@ "comment": "recording part info", "string": "パート{index}" }, + "organism-recording__playlistTitle": { + "string": "プレイリスト内のその他のアイテム" + }, "organism-recording__readByLabel": { "string": "語り手{name}" }, diff --git a/public/lang/ru.json b/public/lang/ru.json index 28bfe592a..42f896e83 100644 --- a/public/lang/ru.json +++ b/public/lang/ru.json @@ -137,9 +137,6 @@ "comment": "Card person teachings count label", "string": "{count} темы" }, - "cardPlaylist__typeLabel": { - "string": "Список воспроизведений" - }, "cardPost__readingDuration": { "comment": "Card post reading duration", "string": "{duration} прочитано" @@ -929,6 +926,9 @@ "comment": "recording part info", "string": "Часть {index}" }, + "organism-recording__playlistTitle": { + "string": "Другие элементы в плейлисте" + }, "organism-recording__readByLabel": { "string": "Прочитано (кем-то) {name}" }, diff --git a/public/lang/zh.json b/public/lang/zh.json index f261f9a9a..3d1fb2247 100644 --- a/public/lang/zh.json +++ b/public/lang/zh.json @@ -137,9 +137,6 @@ "comment": "Card person teachings count label", "string": "{count}篇证道" }, - "cardPlaylist__typeLabel": { - "string": "播放清单" - }, "cardPost__readingDuration": { "comment": "Card post reading duration", "string": "{duration} 朗读" @@ -929,6 +926,9 @@ "comment": "recording part info", "string": "第 {index}部分" }, + "organism-recording__playlistTitle": { + "string": "播放清單中的其他項目" + }, "organism-recording__readByLabel": { "string": "由{name}朗读" }, diff --git a/src/components/molecules/card/playlist.tsx b/src/components/molecules/card/playlist.tsx index 71042f335..b093dc98f 100644 --- a/src/components/molecules/card/playlist.tsx +++ b/src/components/molecules/card/playlist.tsx @@ -4,12 +4,10 @@ import { FormattedMessage } from 'react-intl'; import Heading2 from '~components/atoms/heading2'; import Heading6 from '~components/atoms/heading6'; -import { BaseColors } from '~lib/constants'; import root from '~lib/routes'; import useLanguageRoute from '~lib/useLanguageRoute'; -import ListIcon from '~public/img/icons/fa-list.svg'; -import TypeLockup from '../typeLockup'; +import PlaylistTypeLockup from '../playlistTypeLockup'; import { CardPlaylistFragment } from './__generated__/playlist'; import CardWithTheme from './base/withTheme'; import styles from './playlist.module.scss'; @@ -30,17 +28,7 @@ export default function CardPlaylist({ playlist }: Props): JSX.Element { >
- - } - textColor={BaseColors.DARK} - /> + {title}
diff --git a/src/components/molecules/player.tsx b/src/components/molecules/player.tsx index 67d4e8f46..6b4037550 100644 --- a/src/components/molecules/player.tsx +++ b/src/components/molecules/player.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx'; import Image from 'next/legacy/image'; -import React, { useEffect, useState } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; import { useGetWithAuthGuardDataQuery } from '~components/HOCs/__generated__/withAuthGuard'; @@ -25,6 +25,7 @@ import IconFullscreen from '~public/img/icons/icon-fullscreen.svg'; import IconPause from '~public/img/icons/icon-pause-large.svg'; import IconPlay from '~public/img/icons/icon-play-large.svg'; +import { PlaybackContext } from '../templates/andPlaybackContext'; import { PlayerFragment } from './__generated__/player'; import ButtonDownloadBlank from './buttonDownloadBlank'; import CircleButton from './circleButton'; @@ -48,6 +49,7 @@ const Player = ({ prefersAudio, compact, }: PlayerProps): JSX.Element => { + useContext(PlaybackContext); const intl = useIntl(); const session = usePlaybackSession(recording, { playlistRecordings, diff --git a/src/components/molecules/playlistTypeLockup.tsx b/src/components/molecules/playlistTypeLockup.tsx new file mode 100644 index 000000000..322f13ec7 --- /dev/null +++ b/src/components/molecules/playlistTypeLockup.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { FormattedMessage } from 'react-intl'; + +import { BaseColors } from '~lib/constants'; +import ListIcon from '~public/img/icons/fa-list.svg'; + +import TypeLockup from './typeLockup'; + +type Props = { + unpadded?: boolean; +}; + +export default function PlaylistTypeLockup({ unpadded }: Props): JSX.Element { + return ( + + } + iconColor={BaseColors.SALMON} + textColor={BaseColors.DARK} + unpadded={unpadded} + /> + ); +} diff --git a/src/components/molecules/teaseRecording.tsx b/src/components/molecules/teaseRecording.tsx index df8329a65..be1b607ab 100644 --- a/src/components/molecules/teaseRecording.tsx +++ b/src/components/molecules/teaseRecording.tsx @@ -95,7 +95,7 @@ export default function TeaseRecording({ const inner = ( <> - {recording.recordingContentType !== RecordingContentType.BibleChapter && ( + {!playlistRecordings && (
{index && count ? ( ( + const makeHat = (typeLockup: ReactElement, title: string, href: string) => ( - + {typeLockup}

{title}

@@ -327,16 +325,31 @@ export function Recording({

{recording.sequence?.title}

+ ) : overrideSequence && overrideSequence.playlistId ? ( + makeHat( + , + startCase(overrideSequence.title), + root + .lang(languageRoute) + .playlists.playlist(overrideSequence.playlistId) + .get() + ) ) : overrideSequence ? ( makeHat( - SequenceContentType.MusicAlbum, - startCase(overrideSequence.book), - root.lang(languageRoute).songs.book(overrideSequence.book).get() + , + startCase(overrideSequence.title), + root.lang(languageRoute).songs.book(overrideSequence.title).get() ) ) : ( recording.sequence && makeHat( - recording.sequence.contentType, + , recording.sequence.title, recording.sequence.canonicalPath ) @@ -420,7 +433,12 @@ export function Recording({ {...{ recording, playlistRecordings: playlistRecordings?.slice( - Math.max((recording.sequenceIndex || 0) - 1, 0) + Math.max( + playlistRecordings.findIndex( + (item) => item.id === recording.id + ) || 0, + 0 + ) ), backgroundColor, }} @@ -504,7 +522,7 @@ export function Recording({ )}
- {seriesItems?.length && ( + {items?.length && (
+ ) : overrideSequence?.playlistId ? ( + ) : (
    - {seriesItems.map((r) => ( + {items.map((r) => (
  1. item.id === recording.id + ) || 0, + 0 + ) )} theme={theme} unpadded diff --git a/src/containers/library/playlist/detail.graphql b/src/containers/library/playlist/detail.graphql index 264d108fb..af6c1c26d 100644 --- a/src/containers/library/playlist/detail.graphql +++ b/src/containers/library/playlist/detail.graphql @@ -2,6 +2,7 @@ query getLibraryPlaylistPageData($id: ID!) { me { user { playlist(id: $id) { + id title createdAt summary @@ -20,6 +21,7 @@ query getLibraryPlaylistPageData($id: ID!) { query getPlaylistPageData($id: ID!) { playlist(id: $id) { + id title createdAt summary diff --git a/src/containers/library/playlist/detail.tsx b/src/containers/library/playlist/detail.tsx index 7cc0e740e..aebbec137 100644 --- a/src/containers/library/playlist/detail.tsx +++ b/src/containers/library/playlist/detail.tsx @@ -12,10 +12,11 @@ import DefinitionList, { IDefinitionListTerm, } from '~components/molecules/definitionList'; import Tease from '~components/molecules/tease'; -import TypeLockup from '~components/molecules/typeLockup'; import { BaseColors } from '~lib/constants'; import { formatLongDateTime } from '~lib/date'; -import ListIcon from '~public/img/icons/fa-list.svg'; +import PlaylistTypeLockup from '~src/components/molecules/playlistTypeLockup'; +import root from '~src/lib/routes'; +import useLanguageRoute from '~src/lib/useLanguageRoute'; import { Must } from '~src/types/types'; import { GetLibraryPlaylistPageDataQuery } from './__generated__/detail'; @@ -30,7 +31,8 @@ export type ILibraryPlaylistDetailProps = { function LibraryPlaylistDetail({ playlist, }: Must): JSX.Element { - const { title, recordings, createdAt, summary } = playlist; + const { title, recordings, createdAt, summary, id } = playlist; + const languageRoute = useLanguageRoute(); const details: IDefinitionListTerm[] = []; if (summary) { @@ -60,17 +62,7 @@ function LibraryPlaylistDetail({ return ( - - } - iconColor={BaseColors.SALMON} - textColor={BaseColors.DARK} - /> + {title}
    @@ -89,7 +81,17 @@ function LibraryPlaylistDetail({ {recordings.nodes?.length ? ( {recordings.nodes.map((recording) => ( - + ))} ) : null} diff --git a/src/containers/playlist/item.graphql b/src/containers/playlist/item.graphql new file mode 100644 index 000000000..7f79a791b --- /dev/null +++ b/src/containers/playlist/item.graphql @@ -0,0 +1,16 @@ +query getPlaylistItemDetailData($id: ID!, $playlistId: ID!) { + playlist(id: $playlistId) { + id + title + summary + recordings(first: 1000) { + nodes { + ...teaseRecording + } + } + } + recording(id: $id) { + ...recording + language + } +} diff --git a/src/containers/playlist/item.tsx b/src/containers/playlist/item.tsx new file mode 100644 index 000000000..fddc98211 --- /dev/null +++ b/src/containers/playlist/item.tsx @@ -0,0 +1,51 @@ +import React from 'react'; + +import withFailStates from '~components/HOCs/withFailStates'; +import { Recording } from '~components/organisms/recording'; +import root from '~lib/routes'; +import useLanguageRoute from '~lib/useLanguageRoute'; +import { Must } from '~src/types/types'; + +import { GetPlaylistItemDetailDataQuery } from './__generated__/item'; + +export interface PlaylistItemProps { + playlist: GetPlaylistItemDetailDataQuery['playlist']; + recording: GetPlaylistItemDetailDataQuery['recording']; +} + +function PlaylistItem({ + playlist, + recording, +}: Must): JSX.Element { + const languageRoute = useLanguageRoute(); + const items = (playlist.recordings.nodes || []).map((r) => ({ + ...r, + canonicalPath: root + .lang(languageRoute) + .playlists.playlist(playlist.id) + .items(r.canonicalPath) + .get(), + })); + const currentRecordingIndex = + items.findIndex((r) => r.id === recording.id) || 0; + const sequencePreviousRecording = items[currentRecordingIndex - 1]; + const sequenceNextRecording = items[currentRecordingIndex + 1]; + return ( + + ); +} + +export default withFailStates(PlaylistItem, { + useShould404: (props) => !props.playlist || !props.recording, +}); diff --git a/src/containers/song/books/track.tsx b/src/containers/song/books/track.tsx index 0f3f17269..bbed1e8cf 100644 --- a/src/containers/song/books/track.tsx +++ b/src/containers/song/books/track.tsx @@ -22,7 +22,7 @@ function SongBookTrack({ recordings, }: Must): JSX.Element { const languageRoute = useLanguageRoute(); - const seriesItems = (recordings.nodes || []).map((r) => ({ + const items = (recordings.nodes || []).map((r) => ({ ...r, canonicalPath: root .lang(languageRoute) @@ -31,9 +31,9 @@ function SongBookTrack({ .get(), })); const currentRecordingIndex = - seriesItems.findIndex((r) => r.id === recording.id) || 0; - const sequencePreviousRecording = seriesItems[currentRecordingIndex - 1]; - const sequenceNextRecording = seriesItems[currentRecordingIndex + 1]; + items.findIndex((r) => r.id === recording.id) || 0; + const sequencePreviousRecording = items[currentRecordingIndex - 1]; + const sequenceNextRecording = items[currentRecordingIndex + 1]; return ( ); diff --git a/src/lib/routes/index.ts b/src/lib/routes/index.ts index 4d8441f94..5d17eb206 100644 --- a/src/lib/routes/index.ts +++ b/src/lib/routes/index.ts @@ -7,6 +7,7 @@ import contact from './contact'; import discover from './discover'; import egwbooks from './egwbooks'; //egw import library from './library'; +import playlists from './playlists'; import presenters from './presenters'; import node from './primatives/node'; import paginatedNode from './primatives/paginatedNode'; @@ -41,6 +42,7 @@ const namespaces = (r: string) => ({ teachings: node(`${r}/teachings`, teachings), testimonies: paginatedNode(`${r}/testimonies`), topics: paginatedNode(`${r}/topics`, topics), + playlists: node(`${r}/playlists`, playlists), }); const root = { diff --git a/src/lib/routes/library.ts b/src/lib/routes/library.ts index 56433a87e..96a0aa031 100644 --- a/src/lib/routes/library.ts +++ b/src/lib/routes/library.ts @@ -4,7 +4,7 @@ import node from './primatives/node'; const library = (r: string) => ({ playlist: (playlistId: Scalars['ID']['output']) => - node(`${r}/playlist/${playlistId}`), + node(`${r}/playlists/${playlistId}`), playlists: node(`${r}/playlists`), history: node(`${r}/history`), }); diff --git a/src/lib/routes/playlists.ts b/src/lib/routes/playlists.ts new file mode 100644 index 000000000..f4db3f6b2 --- /dev/null +++ b/src/lib/routes/playlists.ts @@ -0,0 +1,11 @@ +import node from './primatives/node'; + +const playlists = (r: string) => ({ + playlist: (playlistId: string | number) => + node(`${r}/${playlistId}`, (r) => ({ + items: (canonicalPath: string) => + node(`${r}/items/${canonicalPath.split('/').slice(3).join('/')}`), + })), +}); + +export default playlists; diff --git a/src/pages/[language]/library/playlist/[id].ts b/src/pages/[language]/library/playlists/[id].ts similarity index 100% rename from src/pages/[language]/library/playlist/[id].ts rename to src/pages/[language]/library/playlists/[id].ts diff --git a/src/pages/[language]/playlists/[id].ts b/src/pages/[language]/playlists/[playlist].ts similarity index 89% rename from src/pages/[language]/playlists/[id].ts rename to src/pages/[language]/playlists/[playlist].ts index d9d1c3da0..202b10a91 100644 --- a/src/pages/[language]/playlists/[id].ts +++ b/src/pages/[language]/playlists/[playlist].ts @@ -13,12 +13,12 @@ export async function getServerSideProps({ params, }: GetServerSidePropsContext<{ language: string; - id: string; + playlist: string; }>): Promise> { storeRequest(req); - const { playlist } = params?.id + const { playlist } = params?.playlist ? await getPlaylistPageData({ - id: params.id, + id: params.playlist, }).catch(() => ({ playlist: null, })) diff --git a/src/pages/[language]/playlists/[playlist]/items/[id]/[[...slugs]].tsx b/src/pages/[language]/playlists/[playlist]/items/[id]/[[...slugs]].tsx new file mode 100644 index 000000000..149c3f2e7 --- /dev/null +++ b/src/pages/[language]/playlists/[playlist]/items/[id]/[[...slugs]].tsx @@ -0,0 +1,34 @@ +import { GetServerSidePropsContext, GetServerSidePropsResult } from 'next'; + +import PlaylistItem, { PlaylistItemProps } from '~containers/playlist/item'; +import { storeRequest } from '~lib/api/storeRequest'; +import { getPlaylistItemDetailData } from '~src/containers/playlist/__generated__/item'; + +export default PlaylistItem; + +export async function getServerSideProps({ + req, + params, +}: GetServerSidePropsContext<{ + language: string; + id: string; + playlist: string; +}>): Promise> { + storeRequest(req); + const id = params?.id as string; + const playlistId = params?.playlist as string; + const { playlist, recording } = await getPlaylistItemDetailData({ + id, + playlistId, + }).catch(() => ({ + playlist: null, + recording: null, + })); + + return { + props: { + playlist, + recording, + }, + }; +} From 53acd6aea453a6460db995a62a25e4086bb6c322 Mon Sep 17 00:00:00 2001 From: Henry Orozco Date: Thu, 7 Mar 2024 16:01:40 -0600 Subject: [PATCH 2/3] fix: audit-ci.json --- audit-ci.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audit-ci.json b/audit-ci.json index 8d682be20..88da7da34 100644 --- a/audit-ci.json +++ b/audit-ci.json @@ -13,6 +13,7 @@ "GHSA-3rfm-jhwj-7488", // Not used at runtime because this is only used in dev ci "GHSA-hjrf-2m68-5959", // Not used at runtime because this is only used in dev ci "GHSA-prr3-c3m5-p7q2", // Not used at runtime - "GHSA-67hx-6x53-jw92" // Not used at runtime + "GHSA-67hx-6x53-jw92", // Not used at runtime + "GHSA-hhhv-q57g-882q" // Not used at runtime ] } From 95f248ca6d33ff8db67a70f1464d3829a88de874 Mon Sep 17 00:00:00 2001 From: Henry Orozco Date: Thu, 7 Mar 2024 16:02:55 -0600 Subject: [PATCH 3/3] chore: update codeowners file --- .github/CODEOWNERS | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4713436a5..b7d81e1b7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1 @@ -* @narthur @jlaverde77 -package.json @narthur -package-lock.json @narthur \ No newline at end of file +* @alangumer