Skip to content

Commit

Permalink
Merge pull request #58 from Opetushallitus/OK-674-henkilo-suorita-val…
Browse files Browse the repository at this point in the history
…intalaskenta

OK-674: Henkilöittäin-näkymän valintalaskenta
  • Loading branch information
pretseli authored Jan 7, 2025
2 parents 5cb8c61 + de64617 commit d5e254e
Show file tree
Hide file tree
Showing 55 changed files with 2,148 additions and 1,104 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VIRKAILIJA_URL=https://virkailija.untuvaopintopolku.fi
NEXT_TELEMETRY_DISABLED=1
11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FlatCompat } from '@eslint/eslintrc';
import ts from 'typescript-eslint';
import playwright from 'eslint-plugin-playwright';
import eslintConfigPrettier from 'eslint-config-prettier';
import vitest from '@vitest/eslint-plugin';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down Expand Up @@ -46,6 +47,16 @@ const config = ts.config(
'playwright/no-conditional-expect': 'off',
},
},
{
files: ['src/**/*.test.ts*'], // or any other pattern
plugins: {
vitest,
},
rules: {
...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
'vitest/max-nested-describe': ['error', { max: 2 }], // you can also modify rules' behavior using option like this
},
},
);

export default config;
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const nextConfig = {
env: {
VIRKAILIJA_URL: process.env.VIRKAILIJA_URL,
APP_URL: process.env.APP_URL,
XSTATE_INSPECT: process.env.XSTATE_INSPECT,
},
output: isStandalone ? 'standalone' : undefined,
async redirects() {
Expand Down
793 changes: 490 additions & 303 deletions package-lock.json

Large diffs are not rendered by default.

49 changes: 26 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,68 +27,71 @@
"dependencies": {
"@date-fns/tz": "^1.2.0",
"@ebay/nice-modal-react": "^1.2.13",
"@emotion/cache": "^11.13.5",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@mui/icons-material": "^6.1.10",
"@mui/material": "^6.1.10",
"@mui/material-nextjs": "^6.1.9",
"@opetushallitus/oph-design-system": "github:opetushallitus/oph-design-system#v0.1.7",
"@tanstack/react-query": "^5.62.3",
"@tanstack/react-query-devtools": "^5.62.3",
"@emotion/cache": "^11.14.0",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^6.2.1",
"@mui/material": "^6.2.1",
"@mui/material-nextjs": "^6.2.1",
"@opetushallitus/oph-design-system": "github:opetushallitus/oph-design-system#v0.1.8",
"@tanstack/react-query": "^5.62.8",
"@tanstack/react-query-devtools": "^5.62.8",
"@xstate/react": "^5.0.0",
"date-fns": "^4.1.0",
"i18next": "^24.0.5",
"i18next": "^24.2.0",
"i18next-fetch-backend": "^6.0.0",
"next": "^15.0.4",
"next": "^15.1.2",
"nextjs-toploader": "^3.7.15",
"nuqs": "^2.2.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-error-boundary": "^4.1.2",
"react-i18next": "^15.1.3",
"remeda": "^2.17.4",
"react-i18next": "^15.2.0",
"remeda": "^2.18.0",
"xstate": "^5.19.0"
},
"devDependencies": {
"@axe-core/playwright": "^4.10.1",
"@axe-core/react": "^4.10.1",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.16.0",
"@next/eslint-plugin-next": "^15.0.4",
"@playwright/test": "^1.49.0",
"@eslint/js": "^9.17.0",
"@next/eslint-plugin-next": "^15.1.2",
"@opentelemetry/api": "^1.9.0",
"@playwright/test": "^1.49.1",
"@statelyai/inspect": "^0.4.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/css.escape": "^1.5.2",
"@types/eslint__eslintrc": "^2.1.2",
"@types/eslint-config-prettier": "^6.11.3",
"@types/node": "^22.10.1",
"@types/node": "^20.17.10",
"@types/react": "^19",
"@types/react-dom": "^19",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"@vitejs/plugin-react": "^4.3.4",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/eslint-plugin": "^1.1.20",
"autoprefixer": "^10.4.20",
"babel-plugin-react-compiler": "^19.0.0-beta-df7b47d-20241124",
"css.escape": "^1.5.1",
"eslint": "^9",
"eslint-config-next": "^15.0.4",
"eslint-config-next": "^15.1.2",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-next": "^0.0.0",
"eslint-plugin-playwright": "^2.1.0",
"http-proxy-middleware": "^3.0.3",
"husky": "^9.1.7",
"jsdom": "^25.0.1",
"lint-staged": "^15.2.10",
"lint-staged": "^15.2.11",
"postcss": "^8",
"prettier": "^3.4.2",
"start-server-and-test": "^2.0.8",
"start-server-and-test": "^2.0.9",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"typescript-eslint": "^8.18.1",
"vitest": "^2.1.8"
}
}
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
forbidOnly: Boolean(process.env.CI),
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : undefined,
Expand Down
3 changes: 2 additions & 1 deletion src/app/(root)/components/haku-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ListTableColumn } from '@/app/components/table/table-types';
import { makeCountColumn } from '@/app/components/table/table-columns';
import { ListTable } from '@/app/components/table/list-table';
import { OphLink } from '@opetushallitus/oph-design-system';
import { isTranslatedName } from '@/app/lib/localization/translation-utils';

export const HakuTable = ({
haut,
Expand All @@ -25,7 +26,7 @@ export const HakuTable = ({
key: 'nimi',
render: (haku) => (
<OphLink href={`/haku/${haku.oid}`} sx={{ textDecoration: 'none' }}>
{typeof haku.nimi == 'object'
{isTranslatedName(haku.nimi)
? translateEntity(haku.nimi)
: haku.nimi}
</OphLink>
Expand Down
79 changes: 79 additions & 0 deletions src/app/components/error-alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use client';

import {
Accordion,
AccordionDetails,
AccordionSummary,
Alert,
Box,
Typography,
} from '@mui/material';
import { useTranslations } from '@/app/hooks/useTranslations';
import { useState } from 'react';
import { styled } from '@/app/lib/theme';
import { ArrowRight } from '@mui/icons-material';

const StyledAccordionSummary = styled(AccordionSummary)({
flexDirection: 'row-reverse',
padding: 0,
'.Mui-expanded .custom-expand-icon': {
transform: 'rotate(-90deg)',
},
});

const ErrorContent = ({
message,
}: {
message: string | Array<string> | undefined;
}) => {
return message
? (Array.isArray(message) ? message : [message]).map((msg, index) => {
return (
<Typography variant="body2" key={`error-message-${index}`}>
{msg}
</Typography>
);
})
: null;
};

export const ErrorAlert = ({
title,
message,
hasAccordion = false,
}: {
title: string;
message: string | Array<string> | undefined;
hasAccordion?: boolean;
}) => {
const [errorVisible, setErrorVisible] = useState(false);
const { t } = useTranslations();

return (
<Alert severity="error">
<Typography color="error">{title}</Typography>
<Box sx={{ marginTop: 1 }}>
{hasAccordion ? (
<Accordion sx={{ backgroundColor: 'transparent' }}>
<StyledAccordionSummary
expandIcon={<ArrowRight className="custom-expand-icon" />}
sx={{ flexDirection: 'row-reverse', padding: 0 }}
onClick={() => setErrorVisible(!errorVisible)}
>
<Typography>
{errorVisible
? t('valinnanhallinta.piilotavirhe')
: t('valinnanhallinta.naytavirhe')}
</Typography>
</StyledAccordionSummary>
<AccordionDetails sx={{ paddingLeft: 0 }}>
<ErrorContent message={message} />
</AccordionDetails>
</Accordion>
) : (
<ErrorContent message={message} />
)}
</Box>
</Alert>
);
};
19 changes: 19 additions & 0 deletions src/app/components/error-with-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ErrorOutline } from '@mui/icons-material';
import { Box, SvgIconProps } from '@mui/material';

export const ErrorWithIcon = ({
children,
color,
}: {
children: React.ReactNode;
color?: SvgIconProps['color'];
}) => {
return (
<Box sx={{ display: 'flex', alignItems: 'flex-start' }}>
<ErrorOutline color={color ?? 'error'} />
<Box component="span" sx={{ paddingLeft: 1 }}>
{children}
</Box>
</Box>
);
};
17 changes: 0 additions & 17 deletions src/app/components/form/oph-input.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/components/oph-modal-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type OphModalDialogProps = Pick<
> & {
titleAlign?: 'center' | 'left';
contentAlign?: 'center' | 'left';
children: React.ReactNode;
children?: React.ReactNode;
title: string;
actions?: React.ReactNode;
onClose?: (
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/pisteet-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
numberValidator,
} from '@/app/components/form/input-validators';
import { OphFormControl } from '@/app/components/form/oph-form-control';
import { OphInput } from '@/app/components/form/oph-input';
import { useTranslations } from '@/app/hooks/useTranslations';
import { useState, ChangeEvent } from 'react';
import { type KoeInputsProps } from './koe-inputs';
import { OphInput } from '@opetushallitus/oph-design-system';

export const PisteetInput = ({
koe,
Expand Down
47 changes: 47 additions & 0 deletions src/app/components/progress-bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Box } from '@mui/material';
import { ophColors } from '@opetushallitus/oph-design-system';
import { TRANSITION_DURATION } from '@/app/lib/constants';

const PROGRESSBAR_HEIGHT = '42px';

export const ProgressBar = ({ value }: { value: number }) => {
const valuePercent = `${value}%`;
return (
<Box
role="progressbar"
aria-valuenow={value}
aria-valuetext={valuePercent}
aria-valuemin={0}
aria-valuemax={100}
sx={{
position: 'relative',
display: 'block',
height: PROGRESSBAR_HEIGHT,
border: `1px solid ${ophColors.grey300}`,
maxWidth: '700px',
borderRadius: '2px',
'&:before, &:after': {
position: 'absolute',
whiteSpace: 'nowrap',
overflow: 'hidden',
content: `"${valuePercent}"`,
height: '100%',
lineHeight: PROGRESSBAR_HEIGHT,
textIndent: (theme) => theme.spacing(2),
userSelect: 'none',
},
'&:before': {
backgroundColor: ophColors.white,
color: ophColors.grey900,
width: '100%',
},
'&:after': {
backgroundColor: ophColors.cyan1,
color: ophColors.white,
width: valuePercent,
transition: `${TRANSITION_DURATION} width linear`,
},
}}
/>
);
};
2 changes: 2 additions & 0 deletions src/app/components/react-query-client-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default function ReactQueryClientProvider({
retry: 1,
throwOnError: true,
staleTime: 10 * 1000,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
},
},
}),
Expand Down
5 changes: 3 additions & 2 deletions src/app/components/search-input.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { OphFormControl } from '@/app/components/form/oph-form-control';
import { useTranslations } from '@/app/hooks/useTranslations';
import { Search } from '@mui/icons-material';
import { InputAdornment, OutlinedInput } from '@mui/material';
import { InputAdornment } from '@mui/material';
import { ChangeEvent } from 'react';
import { styled } from '@/app/lib/theme';
import { OphInput } from '@opetushallitus/oph-design-system';

const StyledContol = styled(OphFormControl)({
flexGrow: 0,
Expand Down Expand Up @@ -39,7 +40,7 @@ export const SearchInput = ({
sx={sx ?? {}}
label={t(label ?? 'hakeneet.hae')}
renderInput={({ labelId }) => (
<OutlinedInput
<OphInput
id={name}
name={name}
inputProps={{ 'aria-labelledby': labelId }}
Expand Down
Loading

0 comments on commit d5e254e

Please sign in to comment.