Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indexCustomField to obtain the utm_course from custom_fields #389

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Changes from 3 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
6 changes: 4 additions & 2 deletions src/app/views/leads/leads-form/NewLead.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const NewLead = () => {
const createLead = (event) => {
setNewLead({ ...newLead, [event.target.name]: event.target.value });
};

const selectTypeLead = (event) => {
setNewLead({
...newLead, lead_type: event.target.value,
Expand Down Expand Up @@ -116,6 +116,7 @@ const NewLead = () => {
});
};


const languages = [
{
value: 'es',
Expand All @@ -133,6 +134,7 @@ const NewLead = () => {
if (id) {
bc.marketing().getAcademySingleLead(id)
.then(({ data }) => {
const indexCustomField = availableCourses.map((c) => c.slug).indexOf(data.custom_fields?.utm_course);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the find method, and if you find something, then you shouldn't do the find of the next line.

const index = availableCourses.map((c) => c.slug).indexOf(data.course);
setNewLead({
...data,
Expand All @@ -141,7 +143,7 @@ const NewLead = () => {
longitude: data.longitude || 0,
zip_code: data.zip_code || 0,
lead_type: data.lead_type || '',
course: { ...availableCourses[index] }
course: { ...availableCourses[indexCustomField !== -1 ? indexCustomField : index] }
});
})
.catch((e) => console.log(e))
Expand Down