Files
mtdb_movie/resources/client/user-lists/user-list-link.tsx
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

49 lines
1023 B
TypeScript
Executable File

import React, {useMemo} from 'react';
import {
BaseMediaLink,
BaseMediaLinkProps,
getBaseMediaLink,
} from '@app/base-media-link';
import {Channel} from '@common/channels/channel';
import {Trans} from '@common/i18n/trans';
interface Props extends Omit<BaseMediaLinkProps, 'link'> {
list: Channel;
}
export function UserListLink({list, children, ...linkProps}: Props) {
const link = useMemo(() => {
return getUserListLink(list);
}, [list]);
let content;
if (children) {
content = children;
} else if (list.internal && list.name === 'watchlist') {
return <Trans message="Watchlist" />;
} else {
content = list.name;
}
return (
<BaseMediaLink {...linkProps} link={link}>
{content}
</BaseMediaLink>
);
}
interface Options {
absolute?: boolean;
season?: number | string;
episode?: number | string;
}
export function getUserListLink(
list: Channel,
{absolute}: Options = {}
): string {
return getBaseMediaLink(`/lists/${list.id}`, {
absolute,
});
}