Skip to content

Commit

Permalink
Lint ja prettier korjauksia
Browse files Browse the repository at this point in the history
  • Loading branch information
hajoa committed Nov 29, 2024
1 parent 6b9ba46 commit 7526d58
Show file tree
Hide file tree
Showing 32 changed files with 587 additions and 464 deletions.
6 changes: 4 additions & 2 deletions src/maksut-ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/stylistic"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true
}
}
2 changes: 1 addition & 1 deletion src/maksut-ui/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
}
4 changes: 2 additions & 2 deletions src/maksut-ui/app/[locale]/[...rest]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {notFound} from 'next/navigation';
import { notFound } from 'next/navigation';

export default function CatchAllPage() {
notFound();
}
}
12 changes: 6 additions & 6 deletions src/maksut-ui/app/[locale]/error.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client'
'use client';

import ErrorPanel from "@/app/components/ErrorPanel";
import { useTranslations } from "use-intl";
import ErrorPanel from '@/app/components/ErrorPanel';
import { useTranslations } from 'use-intl';

export default function Error() {
const t = useTranslations('Error')
const t = useTranslations('Error');
return (
<ErrorPanel>
<h2>{t('header')}</h2>
</ErrorPanel>
)
}
);
}
43 changes: 22 additions & 21 deletions src/maksut-ui/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
import type { Metadata } from "next";
import { OphNextJsThemeProvider } from "@opetushallitus/oph-design-system/next/theme"
import { CssBaseline } from '@mui/material'
import { AppRouterCacheProvider} from "@mui/material-nextjs/v13-appRouter"
import { CSSProperties, ReactNode } from "react"
import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { TopBar } from "@/app/components/TopBar";
import { Locale } from "@/app/lib/types";
import { OphLanguage } from "@opetushallitus/oph-design-system";
import type { Metadata } from 'next';
import { OphNextJsThemeProvider } from '@opetushallitus/oph-design-system/next/theme';
import { CssBaseline } from '@mui/material';
import { AppRouterCacheProvider } from '@mui/material-nextjs/v13-appRouter';
import { CSSProperties, ReactNode } from 'react';
import { NextIntlClientProvider } from 'next-intl';
import { getMessages } from 'next-intl/server';
import { TopBar } from '@/app/components/TopBar';
import { Locale } from '@/app/lib/types';
import { OphLanguage } from '@opetushallitus/oph-design-system';

export const metadata: Metadata = {
title: "Maksut",
description: "Maksujen käyttöliittymä"
title: 'Maksut',
description: 'Maksujen käyttöliittymä',
};

export default async function LocaleLayout({
children,
params
params,
}: Readonly<{
children: ReactNode;
params: Promise<{locale: string}>;
params: Promise<{ locale: string }>;
}>) {
const messages = await getMessages();
const { locale } = await params
const { locale } = await params;

const bodyStyle: CSSProperties = {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
backgroundColor: '#F6F6F6',
}
};

return (
<html lang={locale}>
<body style={bodyStyle}>
<AppRouterCacheProvider>
<NextIntlClientProvider messages={messages}>
<OphNextJsThemeProvider lang={locale as OphLanguage} variant={"opintopolku"}>
<CssBaseline/>
<OphNextJsThemeProvider
lang={locale as OphLanguage}
variant={'opintopolku'}
>
<CssBaseline />
<TopBar lang={locale as Locale}></TopBar>
<main>
{children}
</main>
<main>{children}</main>
</OphNextJsThemeProvider>
</NextIntlClientProvider>
</AppRouterCacheProvider>
Expand Down
10 changes: 5 additions & 5 deletions src/maksut-ui/app/[locale]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { getTranslations } from "next-intl/server";
import ErrorPanel from "@/app/components/ErrorPanel";
import { getTranslations } from 'next-intl/server';
import ErrorPanel from '@/app/components/ErrorPanel';

export default async function NotFound() {
const t = await getTranslations('NotFound')
const t = await getTranslations('NotFound');

return (
<ErrorPanel>
<h2>{t('header')}</h2>
<span>{t('body1')}</span>
<span>{t('body2')}</span>
</ErrorPanel>
)
}
);
}
41 changes: 21 additions & 20 deletions src/maksut-ui/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import { fetchLaskutBySecret } from "@/app/lib/data";
import MaksutPanel from "@/app/components/MaksutPanel";
import { notFound, redirect } from "next/navigation";
import Header from "@/app/components/Header";
import { routing } from "@/i18n/routing";
import { getLocale } from "next-intl/server";
import ExpiredPanel from "@/app/components/ExpiredPanel";
import { Locale } from '@/app/lib/types'
import { fetchLaskutBySecret } from '@/app/lib/data';
import MaksutPanel from '@/app/components/MaksutPanel';
import { notFound, redirect } from 'next/navigation';
import Header from '@/app/components/Header';
import { routing } from '@/i18n/routing';
import { getLocale } from 'next-intl/server';
import ExpiredPanel from '@/app/components/ExpiredPanel';
import { Locale } from '@/app/lib/types';

export default async function Page({ searchParams }: {searchParams: Promise<{secret?: string}>}) {
const { secret } = await searchParams
const locale = await getLocale()
export default async function Page({
searchParams,
}: {
searchParams: Promise<{ secret?: string }>;
}) {
const { secret } = await searchParams;
const locale = await getLocale();

if (!routing.locales.includes(locale as Locale)) {
redirect(`/fi?secret=${secret}`)
redirect(`/fi?secret=${secret}`);
}

if (!secret) {
notFound()
notFound();
}
const { laskut, contact } = await fetchLaskutBySecret(secret)
const activeLasku = laskut.find((lasku) => lasku.secret === secret)
const { laskut, contact } = await fetchLaskutBySecret(secret);
const activeLasku = laskut.find((lasku) => lasku.secret === secret);

if (!laskut.length || !activeLasku) {
return (
<ExpiredPanel contact={contact}/>
)
return <ExpiredPanel contact={contact} />;
}


return (
<>
<Header lasku={activeLasku}></Header>
<MaksutPanel laskut={laskut} secret={secret}/>
<MaksutPanel laskut={laskut} secret={secret} />
</>
);
}
32 changes: 17 additions & 15 deletions src/maksut-ui/app/components/AlertIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import Image from "next/image";
import { Box } from "@mui/material";
import Image from 'next/image';
import { Box } from '@mui/material';

const AlertIcon = () => {
return (
<Box style={{
backgroundColor: '#cc2f1b',
borderRadius: '50%',
width: '60px',
height: '60px',
display: 'flex',
alignItems: 'center',
}}>
<Box
style={{
backgroundColor: '#cc2f1b',
borderRadius: '50%',
width: '60px',
height: '60px',
display: 'flex',
alignItems: 'center',
}}
>
<Image
src={'/maksut-ui/alert.svg'}
alt={'Alert icon'}
Expand All @@ -19,10 +21,10 @@ const AlertIcon = () => {
style={{
filter: 'invert(1)',
margin: 'auto',
}}>
</Image>
}}
></Image>
</Box>
)
}
);
};

export default AlertIcon
export default AlertIcon;
43 changes: 25 additions & 18 deletions src/maksut-ui/app/components/AstuPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use client'
'use client';

import { Lasku, Locale } from "@/app/lib/types";
import Maksu from "@/app/components/Maksu";
import { useLocale, useTranslations } from "use-intl";
import { translateLocalizedString } from "@/app/lib/utils";
import Panel from "@/app/components/Panel";
import MaksaButton from "@/app/components/MaksaButton";
import { Lasku, Locale } from '@/app/lib/types';
import Maksu from '@/app/components/Maksu';
import { useLocale, useTranslations } from 'use-intl';
import { translateLocalizedString } from '@/app/lib/utils';
import Panel from '@/app/components/Panel';
import MaksaButton from '@/app/components/MaksaButton';

const AstuPanel = ({ lasku }: {lasku: Lasku}) => {
const t = useTranslations('AstuPanel')
const locale = useLocale() as Locale
const tMaksut = useTranslations('MaksutPanel')
const AstuPanel = ({ lasku }: { lasku: Lasku }) => {
const t = useTranslations('AstuPanel');
const locale = useLocale() as Locale;
const tMaksut = useTranslations('MaksutPanel');

const stateText = () => {
if (lasku.status === 'paid') {
Expand All @@ -19,23 +19,30 @@ const AstuPanel = ({ lasku }: {lasku: Lasku}) => {
<span>{t('päätösMaksettu')}</span>
<span>{tMaksut('yhteiskäytto')}</span>
</>
)
);
} else {
return (
<>
<span>{t('päätösMaksamatta')}</span>
</>
)
);
}
}
};

return (
<Panel>
<h2>{translateLocalizedString(lasku.metadata?.form_name, locale, "ASTU lomake")}</h2>
<h2>
{translateLocalizedString(
lasku.metadata?.form_name,
locale,
'ASTU lomake',
)}
</h2>
{stateText()}
<Maksu lasku={lasku} />
<MaksaButton lasku={lasku}></MaksaButton>
</Panel>)
}
</Panel>
);
};

export default AstuPanel
export default AstuPanel;
16 changes: 8 additions & 8 deletions src/maksut-ui/app/components/ErrorPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use client'
'use client';

import Panel from "@/app/components/Panel";
import AlertIcon from "@/app/components/AlertIcon";
import Panel from '@/app/components/Panel';
import AlertIcon from '@/app/components/AlertIcon';

const ErrorPanel = ({children}: {children: React.ReactNode}) => {
const ErrorPanel = ({ children }: { children: React.ReactNode }) => {
return (
<div style={{marginTop: '72px'}}>
<div style={{ marginTop: '72px' }}>
<Panel>
<AlertIcon></AlertIcon>
{children}
</Panel>
</div>
)
}
);
};

export default ErrorPanel
export default ErrorPanel;
23 changes: 13 additions & 10 deletions src/maksut-ui/app/components/ExpiredPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
'use client'
'use client';

import ErrorPanel from "@/app/components/ErrorPanel";
import { useTranslations } from "use-intl";
import { OphLink } from "@opetushallitus/oph-design-system";
import ErrorPanel from '@/app/components/ErrorPanel';
import { useTranslations } from 'use-intl';
import { OphLink } from '@opetushallitus/oph-design-system';

const ExpiredPanel = ({contact}: {contact: string | undefined}) => {
const t = useTranslations('ExpiredPanel')
const ExpiredPanel = ({ contact }: { contact: string | undefined }) => {
const t = useTranslations('ExpiredPanel');

return (
<ErrorPanel>
<h2>{t('header')}</h2>
<span>{t('body1')}</span>
<span>{t('body2')}<OphLink href={`mailto:${contact}`}>{contact}</OphLink>.</span>
<span>
{t('body2')}
<OphLink href={`mailto:${contact}`}>{contact}</OphLink>.
</span>
</ErrorPanel>
)
}
);
};

export default ExpiredPanel;
export default ExpiredPanel;
Loading

0 comments on commit 7526d58

Please sign in to comment.