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
12 changes: 12 additions & 0 deletions src/components/Auth/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@ const Register = () => {
isRequired
/>
</Grid>
<Grid item xs={12}>
<PasswordField
label="Confirm Password"
placeholder="Confirm your password"
value={formData.confirmPassword}
onChange={(e) =>
setFormData({ ...formData, confirmPassword: e.target.value })
}
errorMessage={errors.confirmPassword}
isRequired
/>
</Grid>
<Grid item xs={12}>
<FormControl>
<Button
Expand Down
84 changes: 33 additions & 51 deletions src/components/TermEditor/newTerm/FirstStepContent.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from "prop-types";
import { useState, useCallback, useContext } from "react";
import { useState, useContext } from "react";
import {
Box,
Divider,
Expand All @@ -9,6 +9,7 @@ import {
TextField,
Chip
} from "@mui/material";
import { useNavigate } from "react-router-dom";
import { GlobalDataContext } from "../../../contexts/DataContext";
import CustomSingleSelect from "../../common/CustomSingleSelect";
import CustomFormField from "../../common/CustomFormField";
Expand All @@ -19,17 +20,27 @@ import { vars } from "../../../theme/variables";
import { TYPES, DEFAULT_TYPE } from "../../../constants/types";
import { useTermSearch } from "../../../hooks/useTermSearch";

const { white, gray300, gray400, gray600, gray700 } = vars;
const { white, gray300, gray400, gray500, gray600 } = vars;

const styles = {
contentBox: {
px: "3.25rem",
pt: "1.75rem",
pb: "2.5rem",
flex: 1,
overflowY: "auto",
display: "flex",
flexDirection: "column",
gap: "2.75rem",
},
autocomplete: {
"& .MuiOutlinedInput-root": {
background: white,
borderColor: gray300,
padding: "0.5rem 0.75rem !important"
},
"& .MuiOutlinedInput-root .MuiAutocomplete-input": {
color: gray700,
color: gray500,
fontWeight: 400,
},
"& .MuiAutocomplete-popupIndicator": {
Expand All @@ -52,71 +63,43 @@ const styles = {
"& .MuiChip-deleteIcon": {
color: `${gray400} !important`,
},
}
},
},
contentBox: {
px: "3.25rem",
pt: "1.75rem",
pb: "2.5rem",
flex: 1,
overflowY: "auto",
display: "flex",
flexDirection: "column",
gap: "2.75rem",
}
};

const FirstStepContent = ({
term,
type,
hasExactMatch,
existingIds,
synonyms,
isEditing,
handleTermChange,
handleTypeChange,
handleExactMatchChange,
handleExistingIdChange,
handleSynonymChange,
onTermSelect,
}) => {
const [openSidebar, setOpenSidebar] = useState(true)
const { user } = useContext(GlobalDataContext)
const FirstStepContent = ({ term, type, existingIds, synonyms, isEditing, handleTermChange, handleTypeChange, handleExistingIdChange, handleSynonymChange, handleExactMatchChange, handleDialogClose }) => {
const [openSidebar, setOpenSidebar] = useState(true);
const { user, updateStoredSearchTerm } = useContext(GlobalDataContext);
const navigate = useNavigate();

const { loading, searchResults } = useTermSearch({
term,
type,
synonyms,
isEditing,
onExactMatchChange: handleExactMatchChange,
})

const handleSidebarToggle = useCallback(() => {
setOpenSidebar((prev) => !prev)
}, [])
});

const handleResultSelect = useCallback(
(result) => {
if (!result?.label) return
const handleSidebarToggle = () => setOpenSidebar(!openSidebar);

handleTermChange(result.label)
if (onTermSelect) {
onTermSelect(result)
}
},
[handleTermChange, onTermSelect],
)
const handleResultSelect = (searchResult) => {
updateStoredSearchTerm(searchResult?.label);
const groupName = user?.groupname || 'base';
navigate(`/${groupName}/${searchResult?.ilx}/overview`);
handleDialogClose();
};

const renderChips = useCallback((values, getTagProps, chipStyles) =>
values.map((option, index) => (
const renderChips = (values, getTagProps, chipStyles) => {
return values.map((option, index) => (
<Chip
key={index}
label={option}
deleteIcon={<CloseIcon />}
sx={chipStyles}
{...getTagProps({ index })}
/>
)), []);
));
};

return (
<Box display="flex" height={1}>
Expand Down Expand Up @@ -152,7 +135,6 @@ const FirstStepContent = ({
value={term}
onChange={handleTermChange}
isEndAdornmentVisible
errorMessage={hasExactMatch ? "Your label has an exact match." : null}
/>
</Stack>

Expand Down Expand Up @@ -217,7 +199,6 @@ const FirstStepContent = ({
FirstStepContent.propTypes = {
term: PropTypes.string,
type: PropTypes.oneOf(TYPES),
hasExactMatch: PropTypes.bool,
existingIds: PropTypes.arrayOf(PropTypes.string),
synonyms: PropTypes.arrayOf(PropTypes.string),
isEditing: PropTypes.bool,
Expand All @@ -226,15 +207,16 @@ FirstStepContent.propTypes = {
handleExactMatchChange: PropTypes.func.isRequired,
handleExistingIdChange: PropTypes.func.isRequired,
handleSynonymChange: PropTypes.func.isRequired,
handleDialogClose: PropTypes.func.isRequired,
onTermSelect: PropTypes.func,
}

FirstStepContent.defaultProps = {
term: "",
type: DEFAULT_TYPE,
hasExactMatch: false,
existingIds: [],
synonyms: [],
isEditing: false,
}

export default FirstStepContent
Loading