Skip to content

Commit

Permalink
fix: #259 deduplicate creators and contributors during import from DOI
Browse files Browse the repository at this point in the history
  • Loading branch information
dmijatovic committed Sep 13, 2022
1 parent 28503c0 commit dbb481c
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 214 deletions.
1 change: 0 additions & 1 deletion frontend/components/software/edit/contributors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
getAvatarUrl, getContributorsForSoftware,
prepareContributorData, updateContributorInDb
} from '~/utils/editContributors'
import useOnUnsaveChange from '~/utils/useOnUnsavedChange'
import {getDisplayName} from '~/utils/getDisplayName'
import {sortOnStrProp} from '~/utils/sortFn'
import {getPropsFromObject} from '~/utils/getPropsFromObject'
Expand Down
19 changes: 14 additions & 5 deletions frontend/components/software/edit/information/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function SoftwareInformation({slug}: {slug: string}) {
id: initalState.id,
slug: initalState.slug,
brand_name: initalState.brand_name,
concept_doi: initalState.concept_doi
concept_doi: initalState.concept_doi,
})
setLoading(false)
}
Expand Down Expand Up @@ -110,11 +110,20 @@ export default function SoftwareInformation({slug}: {slug: string}) {
})
// if OK
if (resp.status === 200) {
showSuccessMessage(`${formData?.brand_name} saved`)
// reload software from api (confirm all changes saved and retreive new ids)
const updated = await getSoftwareInfoForEdit({slug,token})
// update local state (useEffect will then reset form to new values)
setEditSoftware(updated)
const updated = await getSoftwareInfoForEdit({slug, token})
if (updated) {
// update local state (useEffect will then reset form to new values)
setEditSoftware(updated)
// update shared software info
setSoftwareInfo({
id: updated.id,
slug: updated.slug,
brand_name: updated.brand_name,
concept_doi: updated.concept_doi,
})
}
showSuccessMessage(`${formData?.brand_name} saved`)
} else {
showErrorMessage(`Failed to save. ${resp.message}`)
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/software/edit/organisations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default function SoftwareOganisations() {
// if it has id
if (organisation?.id) {
const resp = await deleteOrganisationFromSoftware({
software: software?.id,
software: software?.id ?? undefined,
organisation: organisation.id,
token
})
Expand Down
Loading

0 comments on commit dbb481c

Please sign in to comment.