ProfessionsPage: pluralize words using the lib "polish-plurals"
This commit is contained in:
parent
1185b5f0de
commit
5645d4e9f3
|
@ -8,6 +8,7 @@ import {
|
|||
withDefault,
|
||||
} from 'use-query-params';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import { polishPlurals } from 'polish-plurals';
|
||||
import SortParam, { decodeSort } from 'libs/serialize-query-params/SortParam';
|
||||
import { useScrollToElement } from 'libs/hooks';
|
||||
import useProfessions from './ProfessionsPage.useProfessions';
|
||||
|
@ -210,7 +211,12 @@ const ProfessionsPage = () => {
|
|||
<Snackbar
|
||||
open={selectedProfessions.length > 0}
|
||||
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
||||
message={`Wybrane zawody: ${selectedProfessions.length}`}
|
||||
message={`Wybrano ${selectedProfessions.length} ${polishPlurals(
|
||||
'zawód',
|
||||
'zawody',
|
||||
'zawodów',
|
||||
selectedProfessions.length
|
||||
)}`}
|
||||
action={
|
||||
<>
|
||||
<Button onClick={handleDeleteProfessions} color="secondary">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { useForm } from 'react-hook-form';
|
||||
import { pick } from 'lodash';
|
||||
import { polishPlurals } from 'polish-plurals';
|
||||
import { MAX_NAME_LENGTH } from './constants';
|
||||
import { ProfessionInput } from 'libs/graphql/types';
|
||||
|
||||
|
@ -58,7 +59,12 @@ const Form = ({ onClose, profession, onSubmit }: FormDialogProps) => {
|
|||
required: 'Te pole jest wymagane.',
|
||||
maxLength: {
|
||||
value: MAX_NAME_LENGTH,
|
||||
message: `Maksymalna długość nazwy zawodu to ${MAX_NAME_LENGTH} znaki.`,
|
||||
message: `Maksymalna długość nazwy zawodu to ${MAX_NAME_LENGTH} ${polishPlurals(
|
||||
'znak',
|
||||
'znaki',
|
||||
'znaków',
|
||||
MAX_NAME_LENGTH
|
||||
)}.`,
|
||||
},
|
||||
})}
|
||||
error={!!errors.name}
|
||||
|
|
|
@ -61,8 +61,9 @@ const FormDialog = ({ open, onClose, user, onSubmit }: FormDialogProps) => {
|
|||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={isSubmitting ? undefined : onClose}
|
||||
onClose={onClose}
|
||||
fullWidth
|
||||
disableBackdropClick={isSubmitting}
|
||||
maxWidth="xs"
|
||||
>
|
||||
<form onSubmit={handleSubmit(_onSubmit)}>
|
||||
|
|
Reference in New Issue