Skip to content

Commit

Permalink
remove unnecessary validations
Browse files Browse the repository at this point in the history
  • Loading branch information
kurund committed Nov 24, 2023
1 parent 9f4b693 commit f25a2a1
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/containers/Template/Form/Template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ const Template = ({
const [label, setLabel] = useState('');
const [body, setBody] = useState(EditorState.createEmpty());
const [example, setExample] = useState(EditorState.createEmpty());
const [filterLabel, setFilterLabel] = useState('');
const [shortcode, setShortcode] = useState('');
const [language, setLanguageId] = useState<any>({});
const [type, setType] = useState<any>(null);
Expand Down Expand Up @@ -479,12 +478,6 @@ const Template = ({
}
}, [languages]);

useEffect(() => {
if (filterLabel && language && language.id) {
getSessionTemplates();
}
}, [filterLabel, language, getSessionTemplates]);

useEffect(() => {
setShortcode(getShortcode);
}, [getShortcode]);
Expand Down Expand Up @@ -543,28 +536,6 @@ const Template = ({
return <Loading />;
}

const validateTitle = (value: any) => {
let error;
if (value) {
setFilterLabel(value);
let found = [];
if (sessionTemplates) {
if (getSessionTemplatesCallBack) {
getSessionTemplatesCallBack(sessionTemplates);
}
// need to check exact title
found = sessionTemplates.sessionTemplates.filter((search: any) => search.label === value);
if (params.id && found.length > 0) {
found = found.filter((search: any) => search.id !== params.id);
}
}
if (found.length > 0) {
error = t('Title already exists.');
}
}
return error;
};

const updateTranslation = (value: any) => {
const translationId = value.id;
// restore if selected language is same as template
Expand Down Expand Up @@ -709,7 +680,6 @@ const Template = ({
component: Input,
name: 'label',
placeholder: `${t('Title')}*`,
validate: validateTitle,
disabled: !!(defaultAttribute.isHsm && params.id),
helperText: defaultAttribute.isHsm
? t('Define what use case does this template serve eg. OTP, optin, activity preference')
Expand Down

0 comments on commit f25a2a1

Please sign in to comment.