-
- {data.title}
-
-
- {data.status && data.status.id !== 'released' && (
- {data.status.text}
- )}
- {data.type.name}
- {data.releaseYear && (
- {releaseTime}
- )}
- {data.ceritficate && (
- {data.ceritficate}
- )}
- {data.runtime && (
- {formatTime(data.runtime)}
- )}
-
-
- {data.ratings.avg && (
- <>
-
- {data.ratings.avg}
-
-
-
- Avg. rating
-
-
-
- {formatNumber(data.ratings.numVotes)}
-
-
-
-
- No. of votes
-
- >
- )}
- {data.ranking && (
+
{data.type.name}
+ {data.releaseYear &&
{releaseTime} }
+ {data.ceritficate &&
{data.ceritficate} }
+ {data.runtime &&
{formatTime(data.runtime)} }
+
+
+ {data.ratings.avg && (
+ <>
-
- {formatNumber(data.ranking.position)}
-
+ {data.ratings.avg}
-
+
-
- {' '}
- Popularity (
-
- {data.ranking.direction === 'UP'
- ? `\u2191${formatNumber(data.ranking.change)}`
- : data.ranking.direction === 'DOWN'
- ? `\u2193${formatNumber(data.ranking.change)}`
- : ''}
-
- )
-
+ Avg. rating
- )}
-
-
- {!!data.genres.length && (
-
- Genres:
- {data.genres.map((genre, i) => (
-
- {i > 0 && ', '}
-
- {genre.text}
-
-
- ))}
+
+ {formatNumber(data.ratings.numVotes)}
+
+
+
+ No. of votes
+
+ >
+ )}
+ {data.ranking && (
+
+ {formatNumber(data.ranking.position)}
+
+
+
+
+ {' '}
+ Popularity (
+
+ {data.ranking.direction === 'UP'
+ ? `\u2191${formatNumber(data.ranking.change)}`
+ : data.ranking.direction === 'DOWN'
+ ? `\u2193${formatNumber(data.ranking.change)}`
+ : ''}
+
+ )
+
)}
- {
-
- Plot:
- {data.plot || '-'}
-
- }
- {data.primaryCrew.map(crewType => (
-
-
- {`${crewType.type.category}: `}
-
- {crewType.crew.map((crew, i) => (
-
- {i > 0 && ', '}
-
- {crew.name}
-
-
- ))}
-
- ))}
-
+
+ {!!data.genres.length && (
+
+ Genres:
+ {data.genres.map((genre, i) => (
+
+ {i > 0 && ', '}
+
+ {genre.text}
+
+
+ ))}
+
+ )}
+
+ Plot:
+ {data.plot || '-'}
+
+ {data.primaryCrew.map(crewType => (
+
+ {`${crewType.type.category}: `}
+ {crewType.crew.map((crew, i) => (
+
+ {i > 0 && ', '}
+
+ {crew.name}
+
+
+ ))}
+
+ ))}
+
);
};
diff --git a/src/components/title/Cast.tsx b/src/components/title/Cast.tsx
index 563da35..2e6b9c9 100644
--- a/src/components/title/Cast.tsx
+++ b/src/components/title/Cast.tsx
@@ -1,7 +1,5 @@
-import Image from 'next/future/image';
-import Link from 'next/link';
+import { CardCast } from 'src/components/card';
import { Cast } from 'src/interfaces/shared/title';
-import { modifyIMDbImg } from 'src/utils/helpers';
import styles from 'src/styles/modules/components/title/cast.module.scss';
type Props = {
@@ -10,46 +8,25 @@ type Props = {
};
const Cast = ({ className, cast }: Props) => {
- if (!cast.length) return <>>;
+ if (!cast.length) return null;
return (
);
};
+
export default Cast;
diff --git a/src/components/title/MoreLikeThis.tsx b/src/components/title/MoreLikeThis.tsx
index 60bc726..5364d21 100644
--- a/src/components/title/MoreLikeThis.tsx
+++ b/src/components/title/MoreLikeThis.tsx
@@ -1,7 +1,5 @@
-import Image from 'next/future/image';
-import Link from 'next/link';
+import { CardTitle } from 'src/components/card';
import { MoreLikeThis } from 'src/interfaces/shared/title';
-import { formatNumber, modifyIMDbImg } from 'src/utils/helpers';
import styles from 'src/styles/modules/components/title/more-like-this.module.scss';
type Props = {
@@ -10,52 +8,22 @@ type Props = {
};
const MoreLikeThis = ({ className, data }: Props) => {
- if (!data.length) return <>>;
+ if (!data.length) return null;
return (
diff --git a/src/components/title/index.tsx b/src/components/title/index.tsx
index 55ea4bf..8e391d9 100644
--- a/src/components/title/index.tsx
+++ b/src/components/title/index.tsx
@@ -1,9 +1,6 @@
-import Basic from './Basic';
-import Cast from './Cast';
-import DidYouKnow from './DidYouKnow';
-import Info from './Info';
-import Media from './Media';
-import MoreLikeThis from './MoreLikeThis';
-import Reviews from './Reviews';
-
-export { Basic, Cast, DidYouKnow, Info, Media, MoreLikeThis, Reviews };
+export { default as Basic } from './Basic';
+export { default as Cast } from './Cast';
+export { default as DidYouKnow } from './DidYouKnow';
+export { default as Info } from './Info';
+export { default as MoreLikeThis } from './MoreLikeThis';
+export { default as Reviews } from './Reviews';
diff --git a/src/context/theme-context.tsx b/src/context/theme-context.tsx
index 0724496..d959da1 100644
--- a/src/context/theme-context.tsx
+++ b/src/context/theme-context.tsx
@@ -5,9 +5,9 @@ const getInitialTheme = () => {
// for server-side rendering, as window isn't availabe there
if (typeof window === 'undefined') return 'light';
- const userPrefersTheme = isLocalStorageAvailable()
- ? window.localStorage.getItem('theme')
- : null;
+ const userPrefersTheme = (
+ isLocalStorageAvailable() ? window.localStorage.getItem('theme') : null
+ ) as 'light' | 'dark' | null;
const browserPrefersDarkTheme = window.matchMedia(
'(prefers-color-scheme: dark)'
).matches;
@@ -28,7 +28,7 @@ const updateMetaTheme = () => {
const initialContext = {
theme: '',
- setTheme: (theme: string) => {},
+ setTheme: (theme: ReturnType
) => { },
};
export const themeContext = createContext(initialContext);
@@ -36,7 +36,7 @@ export const themeContext = createContext(initialContext);
const ThemeProvider = ({ children }: { children: ReactNode }) => {
const [curTheme, setCurTheme] = useState(getInitialTheme);
- const setTheme = (theme: string) => {
+ const setTheme = (theme: typeof curTheme) => {
setCurTheme(theme);
if (isLocalStorageAvailable()) window.localStorage.setItem('theme', theme);
document.documentElement.dataset.theme = theme;
diff --git a/src/interfaces/shared/index.ts b/src/interfaces/shared/index.ts
new file mode 100644
index 0000000..779c9b0
--- /dev/null
+++ b/src/interfaces/shared/index.ts
@@ -0,0 +1,3 @@
+import type Name from './name';
+
+export type Media = Name['media']; // exactly the same in title and name
diff --git a/src/interfaces/shared/title.ts b/src/interfaces/shared/title.ts
index 4380a77..2490570 100644
--- a/src/interfaces/shared/title.ts
+++ b/src/interfaces/shared/title.ts
@@ -1,8 +1,6 @@
import cleanTitle from 'src/utils/cleaners/title';
import title from 'src/utils/fetchers/title';
-export type AxiosTitleRes = Awaited>;
-
// for full title
type Title = ReturnType;
export type { Title as default };
diff --git a/src/layouts/Footer.tsx b/src/layouts/Footer.tsx
index 5001a86..2db0f3f 100644
--- a/src/layouts/Footer.tsx
+++ b/src/layouts/Footer.tsx
@@ -2,35 +2,32 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import styles from '../styles/modules/layout/footer.module.scss';
+const links = [
+ { path: '/about', text: 'About' },
+ { path: '/find', text: 'Find' },
+ { path: '/privacy', text: 'Privacy' },
+ { path: '/contact', text: 'Contact' },
+] as const;
+
const Footer = () => {
const { pathname } = useRouter();
- const className = (link: string) =>
- pathname === link ? styles.nav__linkActive : styles.nav__link;
return (