Skip to content

Commit

Permalink
Issue 919- Duplicate tag creation without selcting from dropdown (rea…
Browse files Browse the repository at this point in the history
…ctplay#920)

* Handled manual duplcate tag creation

* lint fix
  • Loading branch information
koustov committed Feb 2, 2023
1 parent 66b7b1b commit 9b11157
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/common/components/PlayForms.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ const PlayForm = ({ fields, formDataObj, onSubmit, isEditPlay }) => {
if (_.isObject(v)) {
updatedval.push(v);
} else {
const findEntry = _.find(field.options, function (opt) {
return opt.name.toLowerCase() === v.toLowerCase();
});
updatedval.push({
[field.fieldName || 'name']: v,
[field.fieldValue || 'value']: ''
[field.fieldValue || 'value']: findEntry
? findEntry[field.fieldValue || 'value']
: ''
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/common/createplay/CreatePlay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const CreatePlay = () => {
const res = await Plays.createPlay(rest);
navigate(`/plays/created/${res}`);
} catch (err) {
alert(`Something Error Occured: ${err}`);
setState({ errorMessage: err });
} finally {
setState({ isDataLoading: false, loadingText: '' });
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/plays.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const createPlay = (playObject) => {

return res?.[0]?.id;
})
.catch(() => Promise.reject(new Error('Error Updating play informations')));
.catch((err) => Promise.reject(new Error(`Error Updating play information: ${err}`)));
};

const associateTag = (tag, play) => {
Expand Down
5 changes: 4 additions & 1 deletion src/common/services/tags.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { submit, submitMutation } from './request';
import { createATagQuery, fetchAllTags } from './request/query';
import * as _ from 'lodash';
// get all tags
const getAllTags = () => {
return submit(fetchAllTags);
return submit(fetchAllTags).then((res) => {
return _.orderBy(res, [(tag) => tag.name.toLowerCase()], ['asc']);
});
};

const createATag = (tagObject) => {
Expand Down

0 comments on commit 9b11157

Please sign in to comment.