Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ const dropdownStyle = (props: DropdownProps, backgroundColor: string) => {
}
}

export default DropdownMenu
export default DropdownMenu
17 changes: 7 additions & 10 deletions frontend/src/components/ImageDropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState} from "react";
import {colors, ListItemIcon, ListItemText, MenuItem, Select} from "@mui/material";
import {ListItemText, MenuItem, Select} from "@mui/material";
import KeyboardDoubleArrowDownRoundedIcon from "@mui/icons-material/KeyboardDoubleArrowDownRounded";
import {ImageDropdownProps} from "../utilities/interfaces/ImageDropdownProps";

Expand All @@ -24,25 +24,22 @@ const ImageDropDown: React.FunctionComponent<ImageDropdownProps> = (props: Image
currentValue = e.target.value;
props.localStorageItemKey ? localStorage.setItem(props.localStorageItemKey, currentValue) : gotImageURLs = gotImageURLs /* Do nothing */;
currentIndex = props.values.indexOf(currentValue);
setText(props.texts[currentIndex]);
const currText = props.texts[currentIndex]
setText(currText);
props.imageURLs ? setImageURL(props.imageURLs[currentIndex]) : setImageURL("");
props.colors ? setBackgroundColor(props.colors[currentIndex]) : setBackgroundColor(currentBackgroundColor);
props.onSelectionChange?.(currText, currentValue)
}

return (
<Select
sx={imageDropDownStyle(currentBackgroundColor)}
IconComponent={KeyboardDoubleArrowDownRoundedIcon}
onChange={handleChange}
value={props.texts}
renderValue={() => (
<MenuItem sx={menuItemStyle} value={currentValue}>
<ListItemText sx={visibleElement(!showImagesOnly)} style={{textAlign:"left"}} primary={currentText}/>
</MenuItem>
)}
value={currentValue}
>
{props.texts.map((value) => (
<MenuItem sx={menuItemStyle} value={props.values[props.texts.indexOf(value)]}>
{props.texts.map((value, index) => (
<MenuItem key={value} sx={menuItemStyle} value={props.values[index]}>
<ListItemText sx={visibleElement(!showImagesOnly)} style={{textAlign:"left"}} primary={value}/>
</MenuItem>
))}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/LoginBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const LoginBox: React.FunctionComponent = () => {
username: username,
password: password,
keepMeLoggedIn: stayLoggedIn,
}).then(navigateAfterLogin).catch(() => {
}).then(reloadPage).catch(() => {
notification.error(localization.notificationMessage.incorrectLogin)
})
} else {
Expand All @@ -50,7 +50,7 @@ const LoginBox: React.FunctionComponent = () => {
}
}

const navigateAfterLogin = () => {
const reloadPage = () => {
window.location.reload();
}

Expand All @@ -64,6 +64,7 @@ const LoginBox: React.FunctionComponent = () => {
imagesOnly={false}
localStorageItemKey={localStorageItemKeys.selectedLanguage}
defaultIndex={defaultLanguageIndex != -1 ? defaultLanguageIndex : 0}
onSelectionChange={reloadPage}
/>
</Stack>
<Stack sx={headlineContainer}>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utilities/interfaces/ImageDropdownProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ export interface ImageDropdownProps {
* Show images only (no text)
*/
imagesOnly?: boolean
/**
* Triggered whenever the selection changes
*/
onSelectionChange?: (text: string, value: string) => void
}
Loading