|
|
@ -45,11 +45,13 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
|
|
|
|
|
|
|
|
const languages = useEnabledLanguages();
|
|
|
|
const languages = useEnabledLanguages();
|
|
|
|
|
|
|
|
|
|
|
|
const [current, setProfile] = useState(profile ?? createDefaultProfile());
|
|
|
|
const [current, setProfile] = useState(createDefaultProfile);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (profile) {
|
|
|
|
if (profile) {
|
|
|
|
setProfile(profile);
|
|
|
|
setProfile(profile);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setProfile(createDefaultProfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [profile]);
|
|
|
|
}, [profile]);
|
|
|
|
|
|
|
|
|
|
|
@ -71,9 +73,9 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
key: K,
|
|
|
|
key: K,
|
|
|
|
value: Profile.Languages[K]
|
|
|
|
value: Profile.Languages[K]
|
|
|
|
) => {
|
|
|
|
) => {
|
|
|
|
const object = { ...current };
|
|
|
|
const newProfile = { ...current };
|
|
|
|
object[key] = value;
|
|
|
|
newProfile[key] = value;
|
|
|
|
setProfile(object);
|
|
|
|
setProfile(newProfile);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[current]
|
|
|
|
[current]
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -140,14 +142,15 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
Cell: ({ value, row, externalUpdate }) => {
|
|
|
|
Cell: ({ value, row, externalUpdate }) => {
|
|
|
|
const code = value;
|
|
|
|
const code = value;
|
|
|
|
const item = row.original;
|
|
|
|
const item = row.original;
|
|
|
|
const lang = useMemo(() => languages.find((l) => l.code2 === code), [
|
|
|
|
const lang = useMemo(
|
|
|
|
code,
|
|
|
|
() => languages.find((l) => l.code2 === code) ?? null,
|
|
|
|
]);
|
|
|
|
[code]
|
|
|
|
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div style={{ width: "8rem" }}>
|
|
|
|
<div style={{ width: "8rem" }}>
|
|
|
|
<LanguageSelector
|
|
|
|
<LanguageSelector
|
|
|
|
options={languages}
|
|
|
|
options={languages}
|
|
|
|
defaultValue={lang}
|
|
|
|
value={lang}
|
|
|
|
onChange={(l) => {
|
|
|
|
onChange={(l) => {
|
|
|
|
if (l) {
|
|
|
|
if (l) {
|
|
|
|
item.language = l.code2;
|
|
|
|
item.language = l.code2;
|
|
|
@ -168,7 +171,7 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
<Form.Check
|
|
|
|
<Form.Check
|
|
|
|
custom
|
|
|
|
custom
|
|
|
|
id={`${item.language}-forced`}
|
|
|
|
id={`${item.language}-forced`}
|
|
|
|
defaultChecked={value === "True"}
|
|
|
|
checked={value === "True"}
|
|
|
|
onChange={(v) => {
|
|
|
|
onChange={(v) => {
|
|
|
|
item.forced = v.target.checked ? "True" : "False";
|
|
|
|
item.forced = v.target.checked ? "True" : "False";
|
|
|
|
externalUpdate && externalUpdate(row, item);
|
|
|
|
externalUpdate && externalUpdate(row, item);
|
|
|
@ -186,7 +189,7 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
<Form.Check
|
|
|
|
<Form.Check
|
|
|
|
custom
|
|
|
|
custom
|
|
|
|
id={`${item.language}-hi`}
|
|
|
|
id={`${item.language}-hi`}
|
|
|
|
defaultChecked={value === "True"}
|
|
|
|
checked={value === "True"}
|
|
|
|
onChange={(v) => {
|
|
|
|
onChange={(v) => {
|
|
|
|
item.hi = v.target.checked ? "True" : "False";
|
|
|
|
item.hi = v.target.checked ? "True" : "False";
|
|
|
|
externalUpdate && externalUpdate(row, item);
|
|
|
|
externalUpdate && externalUpdate(row, item);
|
|
|
@ -204,7 +207,7 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
<Form.Check
|
|
|
|
<Form.Check
|
|
|
|
custom
|
|
|
|
custom
|
|
|
|
id={`${item.language}-audio`}
|
|
|
|
id={`${item.language}-audio`}
|
|
|
|
defaultChecked={value === "True"}
|
|
|
|
checked={value === "True"}
|
|
|
|
onChange={(v) => {
|
|
|
|
onChange={(v) => {
|
|
|
|
item.audio_exclude = v.target.checked ? "True" : "False";
|
|
|
|
item.audio_exclude = v.target.checked ? "True" : "False";
|
|
|
|
externalUpdate && externalUpdate(row, item);
|
|
|
|
externalUpdate && externalUpdate(row, item);
|
|
|
@ -235,7 +238,7 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
<Form.Control
|
|
|
|
<Form.Control
|
|
|
|
type="text"
|
|
|
|
type="text"
|
|
|
|
placeholder="Name"
|
|
|
|
placeholder="Name"
|
|
|
|
value={current?.name}
|
|
|
|
value={current.name}
|
|
|
|
onChange={(v) => {
|
|
|
|
onChange={(v) => {
|
|
|
|
updateProfile("name", v.target.value);
|
|
|
|
updateProfile("name", v.target.value);
|
|
|
|
}}
|
|
|
|
}}
|
|
|
@ -245,7 +248,7 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
<SimpleTable
|
|
|
|
<SimpleTable
|
|
|
|
responsive={false}
|
|
|
|
responsive={false}
|
|
|
|
columns={columns}
|
|
|
|
columns={columns}
|
|
|
|
data={current?.items ?? []}
|
|
|
|
data={current.items}
|
|
|
|
externalUpdate={updateRow}
|
|
|
|
externalUpdate={updateRow}
|
|
|
|
></SimpleTable>
|
|
|
|
></SimpleTable>
|
|
|
|
<Button block variant="light" onClick={addItem}>
|
|
|
|
<Button block variant="light" onClick={addItem}>
|
|
|
@ -256,7 +259,7 @@ const LanguagesProfileModal: FunctionComponent<Props & BaseModalProps> = (
|
|
|
|
<Selector
|
|
|
|
<Selector
|
|
|
|
clearable
|
|
|
|
clearable
|
|
|
|
options={cutoff}
|
|
|
|
options={cutoff}
|
|
|
|
value={current?.cutoff}
|
|
|
|
value={current.cutoff}
|
|
|
|
onChange={(num) => updateProfile("cutoff", num)}
|
|
|
|
onChange={(num) => updateProfile("cutoff", num)}
|
|
|
|
></Selector>
|
|
|
|
></Selector>
|
|
|
|
<Message>Ignore others if existing</Message>
|
|
|
|
<Message>Ignore others if existing</Message>
|
|
|
|