Skip to content

Commit

Permalink
fix(j-s): Show correct loading indicators in modal (#16962)
Browse files Browse the repository at this point in the history
Co-authored-by: unakb <una@kolibri.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent cd5a0ac commit e0596d3
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ import { isCourtHearingArrangemenstStepValidRC } from '@island.is/judicial-syste

import { rcHearingArrangements as m } from './HearingArrangements.strings'

enum ModalButtonLoading {
PRIMARY = 'PRIMARY',
SECONDARY = 'SECONDARY',
}

export const HearingArrangements = () => {
const {
workingCase,
Expand All @@ -43,6 +48,8 @@ export const HearingArrangements = () => {
} = useContext(FormContext)

const [navigateTo, setNavigateTo] = useState<keyof stepValidationsType>()
const [modalButtonLoading, setModalButtonLoading] =
useState<ModalButtonLoading>()

const {
setAndSendCaseToServer,
Expand Down Expand Up @@ -209,13 +216,23 @@ export const HearingArrangements = () => {
courtDateHasChanged,
},
)}
isPrimaryButtonLoading={isSendingNotification}
isPrimaryButtonLoading={
isSendingNotification &&
modalButtonLoading === ModalButtonLoading.PRIMARY
}
isSecondaryButtonLoading={
isSendingNotification &&
modalButtonLoading === ModalButtonLoading.SECONDARY
}
onSecondaryButtonClick={() => {
sendNotification(workingCase.id, NotificationType.COURT_DATE, true)
setModalButtonLoading(ModalButtonLoading.SECONDARY)

sendNotification(workingCase.id, NotificationType.COURT_DATE, true)
router.push(`${navigateTo}/${workingCase.id}`)
}}
onPrimaryButtonClick={async () => {
setModalButtonLoading(ModalButtonLoading.PRIMARY)

const notificationSent = await sendNotification(
workingCase.id,
NotificationType.COURT_DATE,
Expand Down

0 comments on commit e0596d3

Please sign in to comment.