Skip to content

Commit b9f7579

Browse files
authored
Merge branch 'main' into j-s/signed-court-record-police
2 parents a27a612 + 5c8c1b9 commit b9f7579

File tree

8 files changed

+54
-13
lines changed

8 files changed

+54
-13
lines changed

apps/portals/my-pages/src/components/Loaders/AuthOverlay/AuthOverlay.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { Text } from '@island.is/island-ui/core'
22
import { useLocale } from '@island.is/localization'
33
import { m } from '@island.is/portals/my-pages/core'
44

5-
import { useBff } from '@island.is/react-spa/bff'
5+
import { useAuth } from '@island.is/react-spa/bff'
66
import * as styles from './AuthOverlay.css'
77

88
const AuthOverlay = () => {
9-
const { authState } = useBff()
9+
const { authState } = useAuth()
1010
const { formatMessage } = useLocale()
1111

1212
if (authState === 'switching')

apps/services/bff/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ Runs tests with Jest and outputs coverage to `coverage/apps/services/bff`.
3737
## Code owners and maintainers
3838

3939
- [Aranja](https://github.com/orgs/island-is/teams/aranja/members)
40+
41+
## Troubleshooting
42+
43+
If you encounter any issues while setting up or running the BFF service, please refer to the [Troubleshooting Guide](TROUBLESHOOT_GUIDE.md)
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# BFF Service Troubleshooting Guide
2+
3+
## Common Issues and Solutions
4+
5+
- Make sure that you are running the `dev` script and not `start` script. For example when running the service portal you should run:
6+
`yarn dev service-portal` and not `yarn start service-portal`.
7+
8+
- Make sure to install dependencies and run code generation with the following command:
9+
`yarn install && yarn codegen`.
10+
11+
- Make sure to login to the correct AWS account and region:
12+
13+
- Run `aws sso login --profile islandis-dev` to login to the correct AWS account.
14+
15+
- Not necessary but a nice to have is to have Redis server running:
16+
17+
- Run `yarn dev-services services-bff` to start Redis server.
18+
- This is necessary if you want the sessions to persist.
19+
20+
- Make sure that you are not running the same service twice, since you could already be running a service like API.
21+
Lets take `yarn dev application-system-form` as an example. This script starts the following services:
22+
23+
- `yarn get-secrets application-system-api`
24+
- `yarn nx run application-system-api:dev-services`
25+
- `yarn nx run application-system-api:migrate`
26+
- `yarn nx codegen/backend-schema api`
27+
- `yarn nx run services-user-profile:dev-init`
28+
- `yarn nx run service-portal:start-bff`
29+
- `yarn start application-system-form`
30+
So make sure that you are not running the same service twice.
31+
32+
- If you are running the service on Windows, we recommend using [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) for running the services within the repo.
33+
This is because all of the scripts generated by the `infra` package are not tested on Windows and may not work as expected.
34+
35+
- On macOS, the AirPlay Receiver is listening on the same port as the Redis server, e.g. 7000. Either change the port or disable the AirPlay Receiver.
36+
37+
- If everything fails, then a good old computer restart might do the trick.

libs/application/ui-shell/src/components/DelegationsScreen.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
Text,
1717
} from '@island.is/island-ui/core'
1818
import { useLocale } from '@island.is/localization'
19-
import { useBff } from '@island.is/react-spa/bff'
19+
import { useAuth } from '@island.is/react-spa/bff'
2020
import { useFeatureFlagClient } from '@island.is/react/feature-flags'
2121
import * as kennitala from 'kennitala'
2222
import { format as formatKennitala } from 'kennitala'
@@ -50,7 +50,7 @@ export const DelegationsScreen = ({
5050
})
5151
const { formatMessage } = useLocale()
5252
const type = getTypeFromSlug(slug)
53-
const { switchUser, userInfo: user } = useBff()
53+
const { switchUser, userInfo: user } = useAuth()
5454
const featureFlagClient: FeatureFlagClient = useFeatureFlagClient()
5555
const navigate = useNavigate()
5656

libs/react-spa/bff/src/lib/BffPoller.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BffUser } from '@island.is/shared/types'
33
import { ReactNode, useCallback, useEffect, useMemo } from 'react'
44
import {
55
BffBroadcastEvents,
6-
useBff,
6+
useAuth,
77
useBffBroadcaster,
88
useUserInfo,
99
} from './bff.hooks'
@@ -43,7 +43,7 @@ export const BffPoller = ({
4343
newSessionCb,
4444
pollIntervalMS = 10000,
4545
}: BffPollerProps) => {
46-
const { signIn, bffUrlGenerator } = useBff()
46+
const { signIn, bffUrlGenerator } = useAuth()
4747
const userInfo = useUserInfo()
4848
const { postMessage } = useBffBroadcaster()
4949

libs/react-spa/bff/src/lib/bff.hooks.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { BffContext, BffContextType } from './BffContext'
88
/**
99
* This hook is used to get the BFF authentication context.
1010
*/
11-
export const useBff = () => {
11+
export const useAuth = () => {
1212
const bffContext = useContext(BffContext)
1313

1414
if (!bffContext) {
15-
throw new Error('useBff must be used within a BffProvider')
15+
throw new Error('useAuth must be used within a BffProvider')
1616
}
1717

1818
return bffContext
@@ -24,7 +24,7 @@ export const useBff = () => {
2424
export const useDynamicBffHook = <Key extends keyof BffContextType>(
2525
returnField: Key,
2626
): NonNullable<BffContextType[Key]> => {
27-
const bffContext = useBff()
27+
const bffContext = useAuth()
2828

2929
if (!isDefined(bffContext[returnField])) {
3030
throw new Error(`The field ${returnField} does not exist in the BffContext`)

libs/shared/components/src/auth/UserMenu/UserDelegations.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box, Stack } from '@island.is/island-ui/core'
22
import { useLocale } from '@island.is/localization'
3-
import { useBff, useUserInfo } from '@island.is/react-spa/bff'
3+
import { useAuth, useUserInfo } from '@island.is/react-spa/bff'
44
import { userMessages } from '@island.is/shared/translations'
55
import { UserDropdownItem } from './UserDropdownItem'
66
import { UserTopicCard } from './UserTopicCard'
@@ -16,7 +16,7 @@ export const UserDelegations = ({
1616
}: UserDelegationsProps) => {
1717
const user = useUserInfo()
1818
const { formatMessage } = useLocale()
19-
const { switchUser } = useBff()
19+
const { switchUser } = useAuth()
2020
const actor = user.profile.actor
2121

2222
return (

libs/shared/components/src/auth/UserMenu/UserMenu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Box, Hidden } from '@island.is/island-ui/core'
2-
import { useBff } from '@island.is/react-spa/bff'
2+
import { useAuth } from '@island.is/react-spa/bff'
33
import { useEffect, useState } from 'react'
44
import { UserButton } from './UserButton'
55
import { UserDropdown } from './UserDropdown'
@@ -29,7 +29,7 @@ export const UserMenu = ({
2929
const [dropdownState, setDropdownState] = useState<'closed' | 'open'>(
3030
'closed',
3131
)
32-
const { signOut, switchUser, userInfo: user } = useBff()
32+
const { signOut, switchUser, userInfo: user } = useAuth()
3333

3434
const handleClick = () => {
3535
setDropdownState(dropdownState === 'open' ? 'closed' : 'open')

0 commit comments

Comments
 (0)