2022-01-30 00:27:26 +03:00
|
|
|
import escapeHtml from 'escape-html';
|
2022-01-05 19:43:40 +03:00
|
|
|
import React, { FunctionComponent } from 'react';
|
|
|
|
import globalize from '../../../scripts/globalize';
|
|
|
|
|
2022-02-18 14:27:39 +03:00
|
|
|
const createSelectElement = ({ className, label, option }: { className?: string, label: string, option: string }) => ({
|
2022-01-05 19:43:40 +03:00
|
|
|
__html: `<select
|
|
|
|
class="${className}"
|
|
|
|
is="emby-select"
|
|
|
|
label="${label}"
|
|
|
|
>
|
|
|
|
<option value=''></option>
|
|
|
|
${option}
|
|
|
|
</select>`
|
|
|
|
});
|
|
|
|
|
2022-01-22 19:20:09 +03:00
|
|
|
type RatingsArr = {
|
|
|
|
Name: string;
|
|
|
|
Value: number;
|
|
|
|
}
|
|
|
|
|
2022-01-05 19:43:40 +03:00
|
|
|
type IProps = {
|
|
|
|
className?: string;
|
|
|
|
label?: string;
|
2022-01-22 19:20:09 +03:00
|
|
|
parentalRatings: RatingsArr[];
|
2022-01-05 19:43:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const SelectMaxParentalRating: FunctionComponent<IProps> = ({ className, label, parentalRatings }: IProps) => {
|
2022-01-22 19:20:09 +03:00
|
|
|
const renderOption = () => {
|
2022-01-05 19:43:40 +03:00
|
|
|
let content = '';
|
2022-01-22 19:20:09 +03:00
|
|
|
for (const rating of parentalRatings) {
|
2022-01-30 00:27:26 +03:00
|
|
|
content += `<option value='${rating.Value}'>${escapeHtml(rating.Name)}</option>`;
|
2022-01-05 19:43:40 +03:00
|
|
|
}
|
|
|
|
return content;
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
dangerouslySetInnerHTML={createSelectElement({
|
|
|
|
className: className,
|
|
|
|
label: globalize.translate(label),
|
2022-01-22 19:20:09 +03:00
|
|
|
option: renderOption()
|
2022-01-05 19:43:40 +03:00
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SelectMaxParentalRating;
|