@arkitektbedriftene/fe-lib 0.2.18 → 0.2.19

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/dist/oidc.es.js CHANGED
@@ -2650,7 +2650,13 @@ const Ee = ue(
2650
2650
  };
2651
2651
  function It(e) {
2652
2652
  return JSON.parse(e).map((r) => {
2653
- const [i, n, o, c, l] = r.split("|"), h = c.split(",");
2653
+ const [
2654
+ i,
2655
+ n,
2656
+ o,
2657
+ c,
2658
+ l
2659
+ ] = r.split("|"), h = c.split(",");
2654
2660
  return {
2655
2661
  CustomerExternalId: i,
2656
2662
  CustomerFirmId: n,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkitektbedriftene/fe-lib",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.es.js",
package/src/App.tsx CHANGED
@@ -3,28 +3,39 @@ import reactLogo from './assets/react.svg'
3
3
  import './App.css'
4
4
  import { ProductExternalIdToIcon } from './lib/icons/icons'
5
5
  import { colors } from './lib/colors/colors'
6
+ import { parseUserProfileFCString } from './lib/oidc/firmAccess'
6
7
 
7
8
  function App() {
8
9
  const [count, setCount] = useState(0)
9
10
 
11
+
12
+
13
+
14
+
10
15
  return (
11
16
  <div className="App">
12
17
  <div>
18
+ <h1>Arkitektbedriftene lib</h1>
13
19
 
14
- <a href="https://reactjs.org" target="_blank">
15
- <img src={reactLogo} className="logo react" alt="React logo" />
16
- </a>
17
20
  </div>
18
- <h1>Vite + React</h1>
21
+
19
22
  <div className="card">
20
23
  <button onClick={() => setCount((count) => count + 1)}>
21
24
  count is {count}
22
25
  </button>
23
- <p>
24
- Edit <code>src/App.tsx</code> and save to test HMR
25
- </p>
26
+
26
27
  </div>
27
- <ProductExternalIdToIcon ExternalId='M_MEDLEM'></ProductExternalIdToIcon>
28
+ <div>
29
+ <b>Ikoner</b>
30
+ <ProductExternalIdToIcon ExternalId='M_MEDLEM'></ProductExternalIdToIcon>
31
+ </div>
32
+ <div>
33
+ <b>Parse av claim fc i token</b>
34
+ <pre>
35
+ {JSON.stringify(parseUserProfileFCString('["121487|910209205|ASPLAN VIAK AS, TROMSØ|Ansatt,Arkitekt,Teknisk ansatt|False","151|910209211105|Aannet|Ansatt,Arkitekt,Teknisk ansatt|False" ]'), null, 2)}
36
+ </pre>
37
+ </div>
38
+
28
39
  <div style={{ backgroundColor: colors.forestGreen }}>forestGreen</div>
29
40
  </div>
30
41
  )
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  /*
4
2
  fc string format:
5
3
  ["121487|910209205|ASPLAN VIAK AS, TROMSØ|Ansatt,Arkitekt,Teknisk ansatt|False","151|910209211105|Aannet|Ansatt,Arkitekt,Teknisk ansatt|False" ]
@@ -13,22 +11,27 @@ export interface FirmAccess {
13
11
  CustomerUserRoles: string[];
14
12
  CustomerUserIsAdmin: boolean;
15
13
  }
16
-
14
+ /// tar en fc claim i token og returnerer en FirmAccess[]
17
15
  export function parseUserProfileFCString(fc: string): FirmAccess[] {
18
- const firmsData: string[] = JSON.parse(fc);
19
- const firmAccesses: FirmAccess[] = firmsData.map(firmData => {
20
- const [CustomerExternalId, CustomerFirmId, CustomerFirmName, CustomerUserRolesStr, CustomerUserIsAdminStr] = firmData.split("|");
21
- const CustomerUserRoles = CustomerUserRolesStr.split(",");
22
- const CustomerUserIsAdmin = CustomerUserIsAdminStr === "True";
23
- const firmAccess: FirmAccess = {
24
- CustomerExternalId,
25
- CustomerFirmId,
26
- CustomerFirmName,
27
- CustomerUserRoles,
28
- CustomerUserIsAdmin,
29
- };
30
- return firmAccess;
31
- });
32
- return firmAccesses;
33
- }
34
-
16
+ const firmsData: string[] = JSON.parse(fc);
17
+ const firmAccesses: FirmAccess[] = firmsData.map((firmData) => {
18
+ const [
19
+ CustomerExternalId,
20
+ CustomerFirmId,
21
+ CustomerFirmName,
22
+ CustomerUserRolesStr,
23
+ CustomerUserIsAdminStr,
24
+ ] = firmData.split("|");
25
+ const CustomerUserRoles = CustomerUserRolesStr.split(",");
26
+ const CustomerUserIsAdmin = CustomerUserIsAdminStr === "True";
27
+ const firmAccess: FirmAccess = {
28
+ CustomerExternalId,
29
+ CustomerFirmId,
30
+ CustomerFirmName,
31
+ CustomerUserRoles,
32
+ CustomerUserIsAdmin,
33
+ };
34
+ return firmAccess;
35
+ });
36
+ return firmAccesses;
37
+ }