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

Fix numerical person properties turning to strings on save #3202

Merged
merged 3 commits into from Feb 5, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/scenes/persons/PersonV2.tsx
Expand Up @@ -147,7 +147,7 @@ function _PersonV2(): JSX.Element {
</Card>
</Col>
</Row>
{mergeModalOpen && (
{mergeModalOpen && person && (
paolodamico marked this conversation as resolved.
Show resolved Hide resolved
<MergePerson person={person} onPersonChange={setPerson} closeModal={() => setMergeModalOpen(false)} />
)}
</div>
Expand Down
18 changes: 14 additions & 4 deletions frontend/src/scenes/persons/personsLogic.ts
Expand Up @@ -47,10 +47,20 @@ export const personsLogic = kea<personsLogicType<PersonPaginatedResponse>>({
},
editProperty: async ({ key, newValue }) => {
const person = values.person
person.properties[key] = newValue
actions.setPerson(person) // To update the UI immediately while the request is being processed
const response = await api.update(`api/person/${person.id}`, person)
actions.setPerson(response)
if (person) {
let parsedValue = newValue

// If the property is a number, store it as a number
const attemptedParsedNumber = Number(newValue)
if (!Number.isNaN(attemptedParsedNumber)) {
parsedValue = attemptedParsedNumber
}

person.properties[key] = parsedValue
actions.setPerson(person) // To update the UI immediately while the request is being processed
const response = await api.update(`api/person/${person.id}`, person)
actions.setPerson(response)
}
},
}),
loaders: ({ values, actions }) => ({
Expand Down