Skip to content

Commit

Permalink
refactor(frontend): remove code to add #FMTM tag automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 31, 2024
1 parent e0e7b84 commit de02ed7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,12 @@ const ProjectDetailsForm = ({ flag }) => {
};
}, []);

const hashtagPrefix = '#FMTM ';

// Checks if hashtag value starts with hotosm-fmtm'
const handleHashtagOnChange = (e) => {
let enteredText = e.target.value;
if (!enteredText.startsWith(hashtagPrefix)) {
handleCustomChange('hashtags', hashtagPrefix);
return;
}
handleCustomChange('hashtags', enteredText);
};

// Doesn't let the user to press 'Backspace' or 'Delete' if input value is 'hotosm-fmtm '
const handleHashtagKeyPress = (e) => {
if (
((e.key === 'Backspace' || e.key === 'Delete') && values.hashtags === hashtagPrefix) ||
(e.ctrlKey && e.key === 'Backspace')
) {
e.preventDefault();
}
};
const handleInputChanges = (e) => {
handleChange(e);
dispatch(CreateProjectActions.SetIsUnsavedChanges(true));
Expand Down Expand Up @@ -165,9 +150,6 @@ const ProjectDetailsForm = ({ flag }) => {
onChange={(e) => {
handleHashtagOnChange(e);
}}
onKeyDown={(e) => {
handleHashtagKeyPress(e);
}}
fieldType="text"
required
errorMsg={errors.hashtag}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/store/slices/CreateProjectSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const initialState: CreateProjectStateTypes = {
projectDetails: {
dimension: 10,
no_of_buildings: 5,
hashtags: '#FMTM ',
hashtags: '',
name: '',
short_description: '',
odk_central_url: '',
Expand Down Expand Up @@ -70,7 +70,7 @@ const CreateProject = createSlice({
state.projectDetails = {
dimension: 10,
no_of_buildings: 5,
hashtags: '#FMTM ',
hashtags: '',
name: '',
short_description: '',
odk_central_url: '',
Expand Down

0 comments on commit de02ed7

Please sign in to comment.