Skip to content

Commit

Permalink
fix: use rsd_path for link and close unit modal only on successful en…
Browse files Browse the repository at this point in the history
…try.
  • Loading branch information
dmijatovic committed Sep 16, 2022
1 parent 2bd37c6 commit 0f3eb5d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function EditOrganisationModal({
const {isValid, isDirty, errors} = formState
const formData = watch()

useEffect(() => {
useEffect(() => {
if (typeof location != 'undefined') {
const baseUrl = location.href.split('?')
// baseUrl is current location without params
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/organisation/units/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type EditOrganisationModal = {
export default function ResearchUnits({organisation}: OrganisationComponentsProps) {
const {token,user} = useSession()
const {showErrorMessage} = useSnackbar()
const {units, setUnits,loading} = useOrganisationUnits({
const {units, setUnits, loading} = useOrganisationUnits({
organisation: organisation.id,
token
})
Expand Down Expand Up @@ -116,7 +116,6 @@ export default function ResearchUnits({organisation}: OrganisationComponentsProp

async function saveOrganisation({data, pos}:{data: EditOrganisation, pos?: number }) {
try {
closeModals()
if (typeof pos != 'undefined' && data.id) {
// update existing organisation
const resp = await updateOrganisation({
Expand All @@ -135,6 +134,7 @@ export default function ResearchUnits({organisation}: OrganisationComponentsProp
} else {
updateUnitInList(data,pos)
}
closeModals()
}
} else {
// create new organisation
Expand All @@ -148,6 +148,7 @@ export default function ResearchUnits({organisation}: OrganisationComponentsProp
id: resp.message
})
addUnitToCollection(newUnit)
closeModals()
} else {
showErrorMessage(resp.message)
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/projects/ProjectFunding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export default function ProjectFunding({grant_id, fundingOrganisations=[]}:
<h4 className="text-primary py-4">Funded by</h4>
<ul>
{fundingOrganisations.map(item => {
const link = `/organisations/${item.slug}`
const link = `/organisations/${item.rsd_path}`
return (
<Link
key={link}
href={link}
passHref
>
<a target="_blank">
<a target="_self">
<li className="text-sm py-1">
{item.name}
</li>
Expand Down
2 changes: 2 additions & 0 deletions frontend/utils/getSlugFromString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export function sanitizeSlugValue(slug: string, separator: string = '-') {
.replace(/[^a-z0-9\-]/g, '')
.trim()
.replace(/[-\s]+/g, separator)
// remove first and last -
.replace(/^-+|-+$/g, '')
}

0 comments on commit 0f3eb5d

Please sign in to comment.