Skip to content

Commit

Permalink
chore(j-s): Display case info in header (#16759)
Browse files Browse the repository at this point in the history
* Remove console.log

* Refactor

* Refactoring

* Refactoring

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
oddsson and kodiakhq[bot] authored Nov 14, 2024
1 parent e47d2b9 commit 9685529
Show file tree
Hide file tree
Showing 40 changed files with 170 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
InstitutionType,
UserRole,
} from '../../graphql/schema'
import { titleForCase } from '../../utils/titleForCase/titleForCase'
import { FormContext } from '../FormProvider/FormProvider'
import OverviewHeader from '../OverviewHeader/OverviewHeader'
import PageTitle from '../PageTitle/PageTitle'
import RestrictionTags from '../RestrictionTags/RestrictionTags'
import RulingDateLabel from '../RulingDateLabel/RulingDateLabel'
import { UserContext } from '../UserProvider/UserProvider'
Expand All @@ -30,7 +31,9 @@ const CaseTitleInfoAndTags: FC = () => {
marginBottom={3}
>
<Box>
<OverviewHeader />
<PageTitle marginBottom={1}>
{titleForCase(formatMessage, workingCase)}
</PageTitle>
{workingCase.rulingDate && (
<RulingDateLabel rulingDate={workingCase.rulingDate} />
)}
Expand Down

This file was deleted.

72 changes: 63 additions & 9 deletions apps/judicial-system/web/src/components/PageTitle/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
import { FC, PropsWithChildren } from 'react'
import { FC, PropsWithChildren, useContext } from 'react'
import { useIntl } from 'react-intl'
import { useRouter } from 'next/router'

import { Box, Text } from '@island.is/island-ui/core'
import {
Box,
Button,
ResponsiveProp,
Space,
Text,
} from '@island.is/island-ui/core'
import {
isCompletedCase,
isIndictmentCase,
} from '@island.is/judicial-system/types'
import { core } from '@island.is/judicial-system-web/messages'

const PageTitle: FC<PropsWithChildren> = ({ children }) => (
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{children}
</Text>
</Box>
)
import { FormContext } from '../FormProvider/FormProvider'
import TagCaseState from '../TagCaseState/TagCaseState'

interface Props {
marginBottom?: ResponsiveProp<Space>
previousUrl?: string
}

const PageTitle: FC<PropsWithChildren<Props>> = (props) => {
const { marginBottom, previousUrl, children } = props
const { workingCase } = useContext(FormContext)
const { formatMessage } = useIntl()
const router = useRouter()

return (
<Box
marginBottom={marginBottom ?? 7}
display="flex"
justifyContent="spaceBetween"
>
<Box>
{previousUrl && (
<Box marginBottom={2}>
<Button
variant="text"
preTextIcon="arrowBack"
onClick={() => router.push(previousUrl)}
>
{formatMessage(core.back)}
</Button>
</Box>
)}
<Text as="h1" variant="h1">
{children}
</Text>
</Box>
{isIndictmentCase(workingCase.type) &&
workingCase.indictmentRulingDecision &&
isCompletedCase(workingCase.state) && (
<TagCaseState
caseState={workingCase.state}
caseType={workingCase.type}
indictmentRulingDecision={workingCase.indictmentRulingDecision}
/>
)}
</Box>
)
}

export default PageTitle
1 change: 0 additions & 1 deletion apps/judicial-system/web/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export { default as ServiceAnnouncement } from './ServiceAnnouncement/ServiceAnn
export { strings as serviceAnnouncementStrings } from './ServiceAnnouncement/ServiceAnnouncement.strings'
export { default as ServiceInterruptionBanner } from './ServiceInterruptionBanner/ServiceInterruptionBanner'
export { default as SignedDocument } from './SignedDocument/SignedDocument'
export { default as OverviewHeader } from './OverviewHeader/OverviewHeader'
export { default as TagAppealState } from './TagAppealState/TagAppealState'
export { default as TagCaseState } from './TagCaseState/TagCaseState'
export { default as CaseTag } from './Tags/CaseTag'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
Input,
RadioButton,
Select,
Text,
} from '@island.is/island-ui/core'
import * as constants from '@island.is/judicial-system/consts'
import { isCoreUser } from '@island.is/judicial-system/types'
import {
FormContentContainer,
FormFooter,
PageTitle,
} from '@island.is/judicial-system-web/src/components'
import {
Institution,
Expand Down Expand Up @@ -136,11 +136,7 @@ export const UserForm: FC<Props> = ({
return (
<div className={styles.userFormContainer}>
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
Notandi
</Text>
</Box>
<PageTitle>Notandi</PageTitle>
<Box marginBottom={2}>
<InputMask
// eslint-disable-next-line local-rules/disallow-kennitalas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
Box,
InputFileUpload,
RadioButton,
Text,
UploadFile,
} from '@island.is/island-ui/core'
import * as constants from '@island.is/judicial-system/consts'
import { core, titles } from '@island.is/judicial-system-web/messages'
import {
BlueBox,
ConnectedCaseFilesAccordionItem,
CourtCaseInfo,
FormContentContainer,
FormContext,
FormFooter,
Expand All @@ -24,6 +24,7 @@ import {
Modal,
PageHeader,
PageLayout,
PageTitle,
SectionHeading,
useIndictmentsLawsBroken,
} from '@island.is/judicial-system-web/src/components'
Expand Down Expand Up @@ -143,11 +144,8 @@ const Completed: FC = () => {
>
<PageHeader title={formatMessage(titles.court.indictments.completed)} />
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(strings.heading)}
</Text>
</Box>
<PageTitle>{formatMessage(strings.heading)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box marginBottom={5} component="section">
<InfoCardClosedIndictment />
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
FormFooter,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
PoliceRequestAccordionItem,
RulingAccordionItem,
Expand Down Expand Up @@ -129,11 +130,7 @@ const Confirmation: FC = () => {
title={formatMessage(titles.court.investigationCases.conclusion)}
/>
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(strings.title)}
</Text>
</Box>
<PageTitle>{formatMessage(strings.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box marginBottom={9}>
<Accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
HideableText,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
} from '@island.is/judicial-system-web/src/components'
import {
Expand Down Expand Up @@ -233,11 +234,7 @@ const CourtRecord: FC = () => {
title={formatMessage(titles.court.investigationCases.courtRecord)}
/>
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(m.sections.title)}
</Text>
</Box>
<PageTitle>{formatMessage(m.sections.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={3}>
<BlueBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Modal,
PageHeader,
PageLayout,
PageTitle,
useCourtArrangements,
} from '@island.is/judicial-system-web/src/components'
import {
Expand Down Expand Up @@ -150,11 +151,7 @@ const HearingArrangements = () => {
/>
</Box>
)}
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(m.title)}
</Text>
</Box>
<PageTitle>{formatMessage(m.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={8}>
<Box marginBottom={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
InfoCard,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
UserContext,
} from '@island.is/judicial-system-web/src/components'
Expand Down Expand Up @@ -101,11 +102,7 @@ const Overview = () => {
/>
</Box>
)}
<Box marginBottom={7}>
<Text as="h1" variant="h1">
Yfirlit kröfu um rannsóknarheimild
</Text>
</Box>
<PageTitle>Yfirlit kröfu um rannsóknarheimild</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
{workingCase.state === CaseState.RECEIVED &&
workingCase.arraignmentDate?.date &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
FormFooter,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
PoliceRequestAccordionItem,
RulingInput,
Expand Down Expand Up @@ -123,11 +124,7 @@ const Ruling = () => {
title={formatMessage(titles.court.investigationCases.ruling)}
/>
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(m.title)}
</Text>
</Box>
<PageTitle>{formatMessage(m.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={5}>
<Accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
FormFooter,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
PoliceRequestAccordionItem,
RulingAccordionItem,
Expand Down Expand Up @@ -129,11 +130,7 @@ const Confirmation: FC = () => {
title={formatMessage(titles.court.restrictionCases.conclusion)}
/>
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(strings.title)}
</Text>
</Box>
<PageTitle>{formatMessage(strings.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box marginBottom={9}>
<Accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
HideableText,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
} from '@island.is/judicial-system-web/src/components'
import {
Expand Down Expand Up @@ -249,11 +250,7 @@ export const CourtRecord: FC = () => {
title={formatMessage(titles.court.restrictionCases.courtRecord)}
/>
<FormContentContainer>
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(m.sections.title)}
</Text>
</Box>
<PageTitle>{formatMessage(m.sections.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={3}>
<BlueBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Modal,
PageHeader,
PageLayout,
PageTitle,
useCourtArrangements,
} from '@island.is/judicial-system-web/src/components'
import {
Expand Down Expand Up @@ -155,11 +156,7 @@ export const HearingArrangements = () => {
/>
</Box>
)}
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(m.title)}
</Text>
</Box>
<PageTitle>{formatMessage(m.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={8}>
<Box marginBottom={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
InfoCard,
PageHeader,
PageLayout,
PageTitle,
PdfButton,
UserContext,
} from '@island.is/judicial-system-web/src/components'
Expand Down Expand Up @@ -108,13 +109,11 @@ export const JudgeOverview = () => {
/>
</Box>
)}
<Box marginBottom={7}>
<Text as="h1" variant="h1">
{formatMessage(rcCourtOverview.sections.title, {
caseType: workingCase.type,
})}
</Text>
</Box>
<PageTitle>
{formatMessage(rcCourtOverview.sections.title, {
caseType: workingCase.type,
})}
</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
{workingCase.state === CaseState.RECEIVED &&
workingCase.arraignmentDate?.date &&
Expand Down
Loading

0 comments on commit 9685529

Please sign in to comment.