@ossy/consultancy 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/consultancy",
|
|
3
3
|
"description": "Consultancy feature package — schemas for employees, contracts, opportunities, and proposals",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.9.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@ossy/router-react": "*",
|
|
31
31
|
"react": "*"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "f404be69becb27a1fd853a6ff1903554e76e7d17"
|
|
34
34
|
}
|
|
@@ -3,6 +3,24 @@ import { Button, useLocale } from '@ossy/design-system'
|
|
|
3
3
|
import { useRouter } from '@ossy/router-react'
|
|
4
4
|
import { location } from './locations.js'
|
|
5
5
|
|
|
6
|
+
function currentReturnTo (href) {
|
|
7
|
+
const raw = typeof href === 'string' && href
|
|
8
|
+
? href
|
|
9
|
+
: (typeof window !== 'undefined' ? `${window.location.pathname}${window.location.search}` : '')
|
|
10
|
+
if (!raw || raw.startsWith('//')) return null
|
|
11
|
+
try {
|
|
12
|
+
const url = /^[a-z][a-z0-9+.-]*:/i.test(raw)
|
|
13
|
+
? new URL(raw)
|
|
14
|
+
: new URL(raw, 'http://ossy.invalid')
|
|
15
|
+
const path = `${url.pathname}${url.search}`
|
|
16
|
+
if (!path.startsWith('/') || path.startsWith('//')) return null
|
|
17
|
+
return path
|
|
18
|
+
} catch {
|
|
19
|
+
if (!raw.startsWith('/') || raw.startsWith('//')) return null
|
|
20
|
+
return raw
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
6
24
|
/**
|
|
7
25
|
* Add CTA that opens the generic create-document form for consultancy schemas.
|
|
8
26
|
* @param {{ schemaId?: string }} [props]
|
|
@@ -12,12 +30,8 @@ export function CreateConsultancyButton ({ schemaId, ...props }) {
|
|
|
12
30
|
const router = useRouter()
|
|
13
31
|
const params = new URLSearchParams({ location, category: 'Consultancy' })
|
|
14
32
|
if (schemaId) params.set('schemaId', schemaId)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (returnTo.startsWith('/') && !returnTo.startsWith('//')) {
|
|
18
|
-
params.set('returnTo', returnTo)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
33
|
+
const returnTo = currentReturnTo(router.href)
|
|
34
|
+
if (returnTo) params.set('returnTo', returnTo)
|
|
21
35
|
|
|
22
36
|
return (
|
|
23
37
|
<Button
|