Compare commits

..

8 Commits

Author SHA1 Message Date
8f9041301c docker-compose.yml aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 1m20s
2024-12-12 20:14:47 +00:00
3573fc8895 .gitea/workflows/registry.yml aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 1m24s
2024-12-12 20:10:07 +00:00
253d4ab6bd .gitea/workflows/registry.yml aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 1m25s
2024-12-12 20:04:42 +00:00
1c9d30b688 .gitea/workflows/registry.yml aktualisiert
Some checks failed
release-tag / release-image (push) Failing after 16s
2024-12-12 20:01:14 +00:00
feff219994 .gitea/workflows/registry.yml aktualisiert
Some checks failed
release-tag / release-image (push) Failing after 14s
2024-12-12 19:57:41 +00:00
6bc2fe0f46 .gitea/workflows/registry.yml hinzugefügt
Some checks failed
release-tag / release-image (push) Failing after 14s
2024-12-12 19:52:35 +00:00
Ömer Faruk Aydın
3d62fabaac Merge pull request #2246 from automatisch/restructure-queues
refactor: Abstract queue generation and configuration
2024-12-12 14:57:03 +01:00
Faruk AYDIN
e41a331ad7 refactor: Abstract queue generation and configuration 2024-12-12 14:51:13 +01:00
15 changed files with 288 additions and 404 deletions

View File

@@ -0,0 +1,52 @@
name: release-tag
on:
push:
branches:
- 'main'
jobs:
release-image:
runs-on: ubuntu-latest
env:
DOCKER_ORG: groot
DOCKER_LATEST: latest
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
with: # replace it with your local IP
config-inline: |
[registry."git.send.nrw"]
http = true
insecure = true
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: git.send.nrw # replace it with your local IP
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Meta
id: meta
run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./docker
file: ./docker/Dockerfile.compose
entrypoint: ./docker/compose-entrypoint.sh
platforms: |
linux/amd64
push: true
tags: | # replace it with your local IP and tags
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }}

View File

@@ -1,10 +1,7 @@
version: '3.9'
services:
main:
build:
context: ./docker
dockerfile: Dockerfile.compose
entrypoint: /compose-entrypoint.sh
image: git.send.nrw/groot/automatisch:latest
ports:
- '3000:3000'
depends_on:
@@ -28,10 +25,7 @@ services:
volumes:
- automatisch_storage:/automatisch/storage
worker:
build:
context: ./docker
dockerfile: Dockerfile.compose
entrypoint: /compose-entrypoint.sh
image: git.send.nrw/groot/automatisch:latest
depends_on:
- main
environment:

View File

@@ -1,27 +1,4 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
const actionQueue = new Queue('action', redisConnection);
actionQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in action queue!', error);
});
import { generateQueue } from './queue.js';
const actionQueue = generateQueue('action');
export default actionQueue;

View File

@@ -1,27 +1,4 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
const deleteUserQueue = new Queue('delete-user', redisConnection);
deleteUserQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in delete user queue!', error);
});
import { generateQueue } from './queue.js';
const deleteUserQueue = generateQueue('delete-user');
export default deleteUserQueue;

View File

@@ -1,27 +1,4 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
const emailQueue = new Queue('email', redisConnection);
emailQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in email queue!', error);
});
import { generateQueue } from './queue.js';
const emailQueue = generateQueue('email');
export default emailQueue;

View File

@@ -1,27 +1,4 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
const flowQueue = new Queue('flow', redisConnection);
flowQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in flow queue!', error);
});
import { generateQueue } from './queue.js';
const flowQueue = generateQueue('flow');
export default flowQueue;

View File

@@ -0,0 +1,44 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
export const generateQueue = (queueName, options) => {
const queue = new Queue(queueName, redisConnection);
queue.on('error', (error) => queueOnError(error, queueName));
if (options?.runDaily) addScheduler(queueName, queue);
return queue;
};
const queueOnError = (error, queueName) => {
if (error.code === CONNECTION_REFUSED) {
const errorMessage =
'Make sure you have installed Redis and it is running.';
logger.error(errorMessage, error);
process.exit();
}
logger.error(`Error happened in ${queueName} queue!`, error);
};
const addScheduler = (queueName, queue) => {
const everydayAtOneOclock = '0 1 * * *';
queue.add(queueName, null, {
jobId: queueName,
repeat: {
pattern: everydayAtOneOclock,
},
});
};

View File

@@ -1,40 +1,8 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
import { generateQueue } from './queue.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
const removeCancelledSubscriptionsQueue = new Queue(
const removeCancelledSubscriptionsQueue = generateQueue(
'remove-cancelled-subscriptions',
redisConnection
{ runDaily: true }
);
removeCancelledSubscriptionsQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error(
'Error happened in remove cancelled subscriptions queue!',
error
);
});
removeCancelledSubscriptionsQueue.add('remove-cancelled-subscriptions', null, {
jobId: 'remove-cancelled-subscriptions',
repeat: {
pattern: '0 1 * * *',
},
});
export default removeCancelledSubscriptionsQueue;

View File

@@ -1,27 +1,4 @@
import process from 'process';
import { Queue } from 'bullmq';
import redisConfig from '../config/redis.js';
import logger from '../helpers/logger.js';
const CONNECTION_REFUSED = 'ECONNREFUSED';
const redisConnection = {
connection: redisConfig,
};
const triggerQueue = new Queue('trigger', redisConnection);
triggerQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in trigger queue!', error);
});
import { generateQueue } from './queue.js';
const triggerQueue = generateQueue('trigger');
export default triggerQueue;

View File

@@ -1,4 +1,4 @@
import { BasePage } from './base-page';
import { BasePage } from "./base-page";
const { faker } = require('@faker-js/faker');
const { expect } = require('@playwright/test');
@@ -6,18 +6,16 @@ export class AdminSetupPage extends BasePage {
path = '/installation';
/**
* @param {import('@playwright/test').Page} page
*/
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.fullNameTextField = this.page.getByTestId('fullName-text-field');
this.emailTextField = this.page.getByTestId('email-text-field');
this.passwordTextField = this.page.getByTestId('password-text-field');
this.repeatPasswordTextField = this.page.getByTestId(
'repeat-password-text-field'
);
this.createAdminButton = this.page.getByTestId('installation-button');
this.repeatPasswordTextField = this.page.getByTestId('repeat-password-text-field');
this.createAdminButton = this.page.getByTestId('signUp-button');
this.invalidFields = this.page.locator('p.Mui-error');
this.successAlert = this.page.getByTestId('success-alert');
}
@@ -48,7 +46,7 @@ export class AdminSetupPage extends BasePage {
await this.repeatPasswordTextField.fill(testUser.wronglyRepeatedPassword);
}
async submitAdminForm() {
async submitAdminForm() {
await this.createAdminButton.click();
}
@@ -61,10 +59,7 @@ export class AdminSetupPage extends BasePage {
}
async expectSuccessMessageToContainLoginLink() {
await expect(await this.successAlert.locator('a')).toHaveAttribute(
'href',
'/login'
);
await expect(await this.successAlert.locator('a')).toHaveAttribute('href', '/login');
}
generateUser() {
@@ -74,7 +69,7 @@ export class AdminSetupPage extends BasePage {
fullName: faker.person.fullName(),
email: faker.internet.email(),
password: faker.internet.password(),
wronglyRepeatedPassword: faker.internet.password(),
wronglyRepeatedPassword: faker.internet.password()
};
}
}
};

View File

@@ -46,12 +46,7 @@ function Form(props) {
return (
<FormProvider {...methods}>
<form
onSubmit={methods.handleSubmit((data, event) =>
onSubmit?.(data, event, methods.setError),
)}
{...formProps}
>
<form onSubmit={methods.handleSubmit(onSubmit)} {...formProps}>
{render ? render(methods) : children}
</form>
</FormProvider>

View File

@@ -2,55 +2,35 @@ import * as React from 'react';
import { Link as RouterLink } from 'react-router-dom';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Alert from '@mui/material/Alert';
import { Alert } from '@mui/material';
import LoadingButton from '@mui/lab/LoadingButton';
import * as yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import { enqueueSnackbar } from 'notistack';
import { useQueryClient } from '@tanstack/react-query';
import Link from '@mui/material/Link';
import { getGeneralErrorMessage } from 'helpers/errors';
import useFormatMessage from 'hooks/useFormatMessage';
import useInstallation from 'hooks/useInstallation';
import * as URLS from 'config/urls';
import Form from 'components/Form';
import TextField from 'components/TextField';
const getValidationSchema = (formatMessage) => {
const getMandatoryInputMessage = (inputNameId) =>
formatMessage('installationForm.mandatoryInput', {
inputName: formatMessage(inputNameId),
});
const validationSchema = yup.object().shape({
fullName: yup.string().trim().required('installationForm.mandatoryInput'),
email: yup
.string()
.trim()
.email('installationForm.validateEmail')
.required('installationForm.mandatoryInput'),
password: yup.string().required('installationForm.mandatoryInput'),
confirmPassword: yup
.string()
.required('installationForm.mandatoryInput')
.oneOf([yup.ref('password')], 'installationForm.passwordsMustMatch'),
});
return yup.object().shape({
fullName: yup
.string()
.trim()
.required(
getMandatoryInputMessage('installationForm.fullNameFieldLabel'),
),
email: yup
.string()
.trim()
.required(getMandatoryInputMessage('installationForm.emailFieldLabel'))
.email(formatMessage('installationForm.validateEmail')),
password: yup
.string()
.required(getMandatoryInputMessage('installationForm.passwordFieldLabel'))
.min(6, formatMessage('installationForm.passwordMinLength')),
confirmPassword: yup
.string()
.required(
getMandatoryInputMessage('installationForm.confirmPasswordFieldLabel'),
)
.oneOf(
[yup.ref('password')],
formatMessage('installationForm.passwordsMustMatch'),
),
});
};
const defaultValues = {
const initialValues = {
fullName: '',
email: '',
password: '',
@@ -59,7 +39,7 @@ const defaultValues = {
function InstallationForm() {
const formatMessage = useFormatMessage();
const { mutateAsync: install, isSuccess, isPending } = useInstallation();
const install = useInstallation();
const queryClient = useQueryClient();
const handleOnRedirect = () => {
@@ -68,38 +48,21 @@ function InstallationForm() {
});
};
const handleSubmit = async ({ fullName, email, password }, e, setError) => {
const handleSubmit = async (values) => {
const { fullName, email, password } = values;
try {
await install({
await install.mutateAsync({
fullName,
email,
password,
});
} catch (error) {
const errors = error?.response?.data?.errors;
if (errors) {
const fieldNames = Object.keys(defaultValues);
Object.entries(errors).forEach(([fieldName, fieldErrors]) => {
if (fieldNames.includes(fieldName) && Array.isArray(fieldErrors)) {
setError(fieldName, {
type: 'fieldRequestError',
message: fieldErrors.join(', '),
});
}
});
}
const generalError = getGeneralErrorMessage({
error,
fallbackMessage: formatMessage('installationForm.error'),
});
if (generalError) {
setError('root.general', {
type: 'requestError',
message: generalError,
});
}
enqueueSnackbar(
error?.message || formatMessage('installationForm.error'),
{
variant: 'error',
},
);
}
};
@@ -119,13 +82,11 @@ function InstallationForm() {
{formatMessage('installationForm.title')}
</Typography>
<Form
automaticValidation={false}
noValidate
defaultValues={defaultValues}
defaultValues={initialValues}
onSubmit={handleSubmit}
resolver={yupResolver(getValidationSchema(formatMessage))}
resolver={yupResolver(validationSchema)}
mode="onChange"
render={({ formState: { errors } }) => (
render={({ formState: { errors, touchedFields } }) => (
<>
<TextField
label={formatMessage('installationForm.fullNameFieldLabel')}
@@ -134,12 +95,19 @@ function InstallationForm() {
margin="dense"
autoComplete="fullName"
data-test="fullName-text-field"
error={!!errors?.fullName}
helperText={errors?.fullName?.message}
error={touchedFields.fullName && !!errors?.fullName}
helperText={
touchedFields.fullName && errors?.fullName?.message
? formatMessage(errors?.fullName?.message, {
inputName: formatMessage(
'installationForm.fullNameFieldLabel',
),
})
: ''
}
required
readOnly={isSuccess}
readOnly={install.isSuccess}
/>
<TextField
label={formatMessage('installationForm.emailFieldLabel')}
name="email"
@@ -147,12 +115,19 @@ function InstallationForm() {
margin="dense"
autoComplete="email"
data-test="email-text-field"
error={!!errors?.email}
helperText={errors?.email?.message}
error={touchedFields.email && !!errors?.email}
helperText={
touchedFields.email && errors?.email?.message
? formatMessage(errors?.email?.message, {
inputName: formatMessage(
'installationForm.emailFieldLabel',
),
})
: ''
}
required
readOnly={isSuccess}
readOnly={install.isSuccess}
/>
<TextField
label={formatMessage('installationForm.passwordFieldLabel')}
name="password"
@@ -160,12 +135,19 @@ function InstallationForm() {
margin="dense"
type="password"
data-test="password-text-field"
error={!!errors?.password}
helperText={errors?.password?.message}
error={touchedFields.password && !!errors?.password}
helperText={
touchedFields.password && errors?.password?.message
? formatMessage(errors?.password?.message, {
inputName: formatMessage(
'installationForm.passwordFieldLabel',
),
})
: ''
}
required
readOnly={isSuccess}
readOnly={install.isSuccess}
/>
<TextField
label={formatMessage(
'installationForm.confirmPasswordFieldLabel',
@@ -175,53 +157,52 @@ function InstallationForm() {
margin="dense"
type="password"
data-test="repeat-password-text-field"
error={!!errors?.confirmPassword}
helperText={errors?.confirmPassword?.message}
error={touchedFields.confirmPassword && !!errors?.confirmPassword}
helperText={
touchedFields.confirmPassword &&
errors?.confirmPassword?.message
? formatMessage(errors?.confirmPassword?.message, {
inputName: formatMessage(
'installationForm.confirmPasswordFieldLabel',
),
})
: ''
}
required
readOnly={isSuccess}
readOnly={install.isSuccess}
/>
{errors?.root?.general && (
<Alert data-test="error-alert" severity="error" sx={{ mt: 2 }}>
{errors.root.general.message}
</Alert>
)}
{isSuccess && (
<Alert
data-test="success-alert"
severity="success"
sx={{ mt: 2 }}
>
{formatMessage('installationForm.success', {
link: (str) => (
<Link
component={RouterLink}
to={URLS.LOGIN}
onClick={handleOnRedirect}
replace
>
{str}
</Link>
),
})}
</Alert>
)}
<LoadingButton
type="submit"
variant="contained"
color="primary"
sx={{ boxShadow: 2, mt: 2 }}
loading={isPending}
disabled={isSuccess}
sx={{ boxShadow: 2, mt: 3 }}
loading={install.isPending}
disabled={install.isSuccess}
fullWidth
data-test="installation-button"
data-test="signUp-button"
>
{formatMessage('installationForm.submit')}
</LoadingButton>
</>
)}
/>
{install.isSuccess && (
<Alert data-test="success-alert" severity="success" sx={{ mt: 3 }}>
{formatMessage('installationForm.success', {
link: (str) => (
<Link
component={RouterLink}
to={URLS.LOGIN}
onClick={handleOnRedirect}
replace
>
{str}
</Link>
),
})}
</Alert>
)}
</Paper>
);
}

View File

@@ -3,52 +3,33 @@ import { useNavigate } from 'react-router-dom';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import LoadingButton from '@mui/lab/LoadingButton';
import Alert from '@mui/material/Alert';
import * as yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import { getGeneralErrorMessage } from 'helpers/errors';
import useAuthentication from 'hooks/useAuthentication';
import * as URLS from 'config/urls';
import Form from 'components/Form';
import TextField from 'components/TextField';
import useFormatMessage from 'hooks/useFormatMessage';
import useCreateAccessToken from 'hooks/useCreateAccessToken';
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
import useRegisterUser from 'hooks/useRegisterUser';
const getValidationSchema = (formatMessage) => {
const getMandatoryInputMessage = (inputNameId) =>
formatMessage('signupForm.mandatoryInput', {
inputName: formatMessage(inputNameId),
});
const validationSchema = yup.object().shape({
fullName: yup.string().trim().required('signupForm.mandatoryInput'),
email: yup
.string()
.trim()
.email('signupForm.validateEmail')
.required('signupForm.mandatoryInput'),
password: yup.string().required('signupForm.mandatoryInput'),
confirmPassword: yup
.string()
.required('signupForm.mandatoryInput')
.oneOf([yup.ref('password')], 'signupForm.passwordsMustMatch'),
});
return yup.object().shape({
fullName: yup
.string()
.trim()
.required(getMandatoryInputMessage('signupForm.fullNameFieldLabel')),
email: yup
.string()
.trim()
.required(getMandatoryInputMessage('signupForm.emailFieldLabel'))
.email(formatMessage('signupForm.validateEmail')),
password: yup
.string()
.required(getMandatoryInputMessage('signupForm.passwordFieldLabel'))
.min(6, formatMessage('signupForm.passwordMinLength')),
confirmPassword: yup
.string()
.required(
getMandatoryInputMessage('signupForm.confirmPasswordFieldLabel'),
)
.oneOf(
[yup.ref('password')],
formatMessage('signupForm.passwordsMustMatch'),
),
});
};
const defaultValues = {
const initialValues = {
fullName: '',
email: '',
password: '',
@@ -59,6 +40,7 @@ function SignUpForm() {
const navigate = useNavigate();
const authentication = useAuthentication();
const formatMessage = useFormatMessage();
const enqueueSnackbar = useEnqueueSnackbar();
const { mutateAsync: registerUser, isPending: isRegisterUserPending } =
useRegisterUser();
const { mutateAsync: createAccessToken, isPending: loginLoading } =
@@ -70,7 +52,7 @@ function SignUpForm() {
}
}, [authentication.isAuthenticated]);
const handleSubmit = async (values, e, setError) => {
const handleSubmit = async (values) => {
try {
const { fullName, email, password } = values;
await registerUser({
@@ -85,28 +67,25 @@ function SignUpForm() {
const { token } = data;
authentication.updateToken(token);
} catch (error) {
const errors = error?.response?.data?.errors;
if (errors) {
const fieldNames = Object.keys(defaultValues);
Object.entries(errors).forEach(([fieldName, fieldErrors]) => {
if (fieldNames.includes(fieldName) && Array.isArray(fieldErrors)) {
setError(fieldName, {
type: 'fieldRequestError',
message: fieldErrors.join(', '),
});
}
});
}
const errors = error?.response?.data?.errors
? Object.values(error.response.data.errors)
: [];
const generalError = getGeneralErrorMessage({
error,
fallbackMessage: formatMessage('signupForm.error'),
});
if (generalError) {
setError('root.general', {
type: 'requestError',
message: generalError,
if (errors.length) {
for (const [error] of errors) {
enqueueSnackbar(error, {
variant: 'error',
SnackbarProps: {
'data-test': 'snackbar-sign-up-error',
},
});
}
} else {
enqueueSnackbar(error?.message || formatMessage('signupForm.error'), {
variant: 'error',
SnackbarProps: {
'data-test': 'snackbar-sign-up-error',
},
});
}
}
@@ -129,13 +108,11 @@ function SignUpForm() {
</Typography>
<Form
automaticValidation={false}
noValidate
defaultValues={defaultValues}
defaultValues={initialValues}
onSubmit={handleSubmit}
resolver={yupResolver(getValidationSchema(formatMessage))}
resolver={yupResolver(validationSchema)}
mode="onChange"
render={({ formState: { errors } }) => (
render={({ formState: { errors, touchedFields } }) => (
<>
<TextField
label={formatMessage('signupForm.fullNameFieldLabel')}
@@ -144,9 +121,14 @@ function SignUpForm() {
margin="dense"
autoComplete="fullName"
data-test="fullName-text-field"
error={!!errors?.fullName}
helperText={errors?.fullName?.message}
required
error={touchedFields.fullName && !!errors?.fullName}
helperText={
touchedFields.fullName && errors?.fullName?.message
? formatMessage(errors?.fullName?.message, {
inputName: formatMessage('signupForm.fullNameFieldLabel'),
})
: ''
}
/>
<TextField
@@ -156,9 +138,14 @@ function SignUpForm() {
margin="dense"
autoComplete="email"
data-test="email-text-field"
error={!!errors?.email}
helperText={errors?.email?.message}
required
error={touchedFields.email && !!errors?.email}
helperText={
touchedFields.email && errors?.email?.message
? formatMessage(errors?.email?.message, {
inputName: formatMessage('signupForm.emailFieldLabel'),
})
: ''
}
/>
<TextField
@@ -167,9 +154,14 @@ function SignUpForm() {
fullWidth
margin="dense"
type="password"
error={!!errors?.password}
helperText={errors?.password?.message}
required
error={touchedFields.password && !!errors?.password}
helperText={
touchedFields.password && errors?.password?.message
? formatMessage(errors?.password?.message, {
inputName: formatMessage('signupForm.passwordFieldLabel'),
})
: ''
}
/>
<TextField
@@ -178,21 +170,19 @@ function SignUpForm() {
fullWidth
margin="dense"
type="password"
error={!!errors?.confirmPassword}
helperText={errors?.confirmPassword?.message}
required
error={touchedFields.confirmPassword && !!errors?.confirmPassword}
helperText={
touchedFields.confirmPassword &&
errors?.confirmPassword?.message
? formatMessage(errors?.confirmPassword?.message, {
inputName: formatMessage(
'signupForm.confirmPasswordFieldLabel',
),
})
: ''
}
/>
{errors?.root?.general && (
<Alert
data-test="alert-sign-up-error"
severity="error"
sx={{ mt: 2 }}
>
{errors.root.general.message}
</Alert>
)}
<LoadingButton
type="submit"
variant="contained"

View File

@@ -1,18 +0,0 @@
// Helpers to extract errors received from the API
export const getGeneralErrorMessage = ({ error, fallbackMessage }) => {
if (!error) {
return;
}
const errors = error?.response?.data?.errors;
const generalError = errors?.general;
if (generalError && Array.isArray(generalError)) {
return generalError.join(' ');
}
if (!errors) {
return error?.message || fallbackMessage;
}
};

View File

@@ -138,7 +138,6 @@
"installationForm.submit": "Create admin",
"installationForm.validateEmail": "Email must be valid.",
"installationForm.passwordsMustMatch": "Passwords must match.",
"installationForm.passwordMinLength": "Password must be at least 6 characters long.",
"installationForm.mandatoryInput": "{inputName} is required.",
"installationForm.success": "The admin account has been created, and thus, the installation has been completed. You can now log in <link>here</link>.",
"installationForm.error": "Something went wrong. Please try again.",
@@ -150,7 +149,6 @@
"signupForm.submit": "Sign up",
"signupForm.validateEmail": "Email must be valid.",
"signupForm.passwordsMustMatch": "Passwords must match.",
"signupForm.passwordMinLength": "Password must be at least 6 characters long.",
"signupForm.mandatoryInput": "{inputName} is required.",
"signupForm.error": "Something went wrong. Please try again.",
"loginForm.title": "Login",