From 2973c67eaff50d609985f4a21fe3afe785065a84 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Mon, 26 Aug 2024 12:19:00 +0200 Subject: [PATCH] fix: resolve type errors --- .../Discover/DiscoverTvUpcoming.tsx | 4 +- .../OverrideRule/OverrideRuleTile.tsx | 322 +++++++++--------- src/i18n/locale/en.json | 3 +- 3 files changed, 170 insertions(+), 159 deletions(-) diff --git a/src/components/Discover/DiscoverTvUpcoming.tsx b/src/components/Discover/DiscoverTvUpcoming.tsx index 182cd1a54..a6a3be170 100644 --- a/src/components/Discover/DiscoverTvUpcoming.tsx +++ b/src/components/Discover/DiscoverTvUpcoming.tsx @@ -7,7 +7,9 @@ import defineMessages from '@app/utils/defineMessages'; import type { TvResult } from '@server/models/Search'; import { useIntl } from 'react-intl'; -const messages = defineMessages('components.DiscoverTvUpcoming', {}); +const messages = defineMessages('components.DiscoverTvUpcoming', { + upcomingtv: 'Upcoming Series', +}); const DiscoverTvUpcoming = () => { const intl = useIntl(); diff --git a/src/components/Settings/OverrideRule/OverrideRuleTile.tsx b/src/components/Settings/OverrideRule/OverrideRuleTile.tsx index 474708137..c5c0451a7 100644 --- a/src/components/Settings/OverrideRule/OverrideRuleTile.tsx +++ b/src/components/Settings/OverrideRule/OverrideRuleTile.tsx @@ -89,171 +89,179 @@ const OverrideRuleTile = ({ })(); }, [rules]); - return rules - ?.filter( - (rule) => - (rule.radarrServiceId !== null && - rule.radarrServiceId === radarr?.id) || - (rule.sonarrServiceId !== null && rule.sonarrServiceId === sonarr?.id) - ) - .map((rule) => ( -
  • -
    -
    - - {intl.formatMessage(messages.conditions)} - - {rule.users && ( -

    - - {intl.formatMessage(messages.users)} + return ( + <> + {rules + .filter( + (rule) => + (rule.radarrServiceId !== null && + rule.radarrServiceId === radarr?.id) || + (rule.sonarrServiceId !== null && + rule.sonarrServiceId === sonarr?.id) + ) + .map((rule) => ( +

  • +
    +
    + + {intl.formatMessage(messages.conditions)} -
    - {rule.users.split(',').map((userId) => { - return ( - - { - users?.find((user) => user.id === Number(userId)) - ?.displayName - } - - ); - })} -
    -

    - )} - {rule.genre && ( -

    - - {intl.formatMessage(messages.genre)} - -

    - {rule.genre.split(',').map((genreId) => ( - - {genres?.find((g) => g.id === Number(genreId))?.name} + {rule.users && ( +

    + + {intl.formatMessage(messages.users)} - ))} -

    -

    - )} - {rule.language && ( -

    - - {intl.formatMessage(messages.language)} +

    + {rule.users.split(',').map((userId) => { + return ( + + { + users?.find((user) => user.id === Number(userId)) + ?.displayName + } + + ); + })} +
    +

    + )} + {rule.genre && ( +

    + + {intl.formatMessage(messages.genre)} + +

    + {rule.genre.split(',').map((genreId) => ( + + {genres?.find((g) => g.id === Number(genreId))?.name} + + ))} +
    +

    + )} + {rule.language && ( +

    + + {intl.formatMessage(messages.language)} + +

    + {rule.language + .split('|') + .filter((languageId) => languageId !== 'server') + .map((languageId) => { + const language = languages?.find( + (language) => language.iso_639_1 === languageId + ); + if (!language) return null; + const languageName = + intl.formatDisplayName(language.iso_639_1, { + type: 'language', + fallback: 'none', + }) ?? language.english_name; + return {languageName}; + })} +
    +

    + )} + {rule.keywords && ( +

    + + {intl.formatMessage(messages.keywords)} + +

    + {rule.keywords.split(',').map((keywordId) => { + return ( + + { + keywords?.find( + (keyword) => keyword.id === Number(keywordId) + )?.name + } + + ); + })} +
    +

    + )} + + {intl.formatMessage(messages.settings)} -
    - {rule.language - .split('|') - .filter((languageId) => languageId !== 'server') - .map((languageId) => { - const language = languages?.find( - (language) => language.iso_639_1 === languageId - ); - if (!language) return null; - const languageName = - intl.formatDisplayName(language.iso_639_1, { - type: 'language', - fallback: 'none', - }) ?? language.english_name; - return {languageName}; - })} + {rule.profileId && ( +

    + + {intl.formatMessage(messages.qualityprofile)} + + { + testResponse.profiles.find( + (profile) => rule.profileId === profile.id + )?.name + } +

    + )} + {rule.rootFolder && ( +

    + + {intl.formatMessage(messages.rootfolder)} + + {rule.rootFolder} +

    + )} + {rule.tags && rule.tags.length > 0 && ( +

    + + {intl.formatMessage(messages.tags)} + +

    + {rule.tags.split(',').map((tag) => ( + + { + testResponse.tags?.find((t) => t.id === Number(tag)) + ?.label + } + + ))} +
    +

    + )} +
    +
    +
    +
    +
    +
    -

    - )} - {rule.keywords && ( -

    - - {intl.formatMessage(messages.keywords)} - -

    - {rule.keywords.split(',').map((keywordId) => { - return ( - +
    +
    -

    - )} - - {intl.formatMessage(messages.settings)} - - {rule.profileId && ( -

    - - {intl.formatMessage(messages.qualityprofile)} - - { - testResponse.profiles.find( - (profile) => rule.profileId === profile.id - )?.name - } -

    - )} - {rule.rootFolder && ( -

    - - {intl.formatMessage(messages.rootfolder)} - - {rule.rootFolder} -

    - )} - {rule.tags && rule.tags.length > 0 && ( -

    - - {intl.formatMessage(messages.tags)} - -

    - {rule.tags.split(',').map((tag) => ( - - { - testResponse.tags?.find((t) => t.id === Number(tag)) - ?.label - } - - ))} + ); + if (!res.ok) throw new Error(); + revalidate(); + }} + className="focus:ring-blue relative inline-flex w-0 flex-1 items-center justify-center rounded-br-lg border border-transparent py-4 text-sm font-medium leading-5 text-gray-200 transition duration-150 ease-in-out hover:text-white focus:z-10 focus:border-gray-500 focus:outline-none" + > + + {intl.formatMessage(globalMessages.delete)} +
    -

    - )} -
    -
    -
    -
    -
    - -
    -
    - +
    -
    -
    -
  • - )); + + ))} + + ); }; export default OverrideRuleTile; diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index e3a0254bc..32ba2180a 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -89,6 +89,7 @@ "components.Discover.StudioSlider.studios": "Studios", "components.Discover.TvGenreList.seriesgenres": "Series Genres", "components.Discover.TvGenreSlider.tvgenres": "Series Genres", + "components.DiscoverTvUpcoming.upcomingtv": "Upcoming Series", "components.Discover.createnewslider": "Create New Slider", "components.Discover.customizediscover": "Customize Discover", "components.Discover.discover": "Discover", @@ -1091,7 +1092,7 @@ "components.Setup.finishing": "Finishing…", "components.Setup.servertype": "Choose Server Type", "components.Setup.setup": "Setup", - "components.Setup.signin": "Sign in to your account", + "components.Setup.signin": "Sign In", "components.Setup.signinMessage": "Get started by signing in", "components.Setup.signinWithEmby": "Enter your Emby details", "components.Setup.signinWithJellyfin": "Enter your Jellyfin details",