Skip to content

Commit

Permalink
fix!: prettier v3 does not work with jest-snapshot
Browse files Browse the repository at this point in the history
KK-1017.
More details: jestjs/jest#14305
  • Loading branch information
nikomakela committed Oct 24, 2023
1 parent 21631cf commit 22dd196
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 283 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@testing-library/testcafe": "^5.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-testcafe": "^0.2.1",
"full-icu": "^1.5.0",
"helsinki-utils": "City-of-Helsinki/helsinki-utils-js.git#0.1.0",
"jest-localstorage-mock": "^2.4.26",
"prettier": "^3.0.3",
"prettier": "^2.8.8",
"testcafe": "^3.3.0",
"testcafe-reporter-html": "^1.4.6"
},
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="fi">
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion public/silent_renew.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head></head>
<body>
Expand Down
65 changes: 32 additions & 33 deletions src/domain/events/detail/EventShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,44 @@ interface AddOccurrenceButtonProps extends WithStyles<typeof styles> {
record?: Occurrence;
}

const AddOccurrenceButton = withStyles(styles)(({
classes,
}: AddOccurrenceButtonProps) => {
const record = useRecordContext();
return (
<Button
component={Link}
className={classes.button}
to={{
pathname: '/occurrences/create',
search: `?event_id=${record?.id}`,
}}
label="occurrences.create.title"
>
<AddIcon />
</Button>
);
});
const AddOccurrenceButton = withStyles(styles)(
({ classes }: AddOccurrenceButtonProps) => {
const record = useRecordContext();
return (
<Button
component={Link}
className={classes.button}
to={{
pathname: '/occurrences/create',
search: `?event_id=${record?.id}`,
}}
label="occurrences.create.title"
>
<AddIcon />
</Button>
);
}
);

interface ImportTicketSystemPasswordsButtonProps
extends WithStyles<typeof styles> {
onClick: () => void;
}

const ImportTicketSystemPasswordsButton = withStyles(styles)(({
classes,
onClick,
}: ImportTicketSystemPasswordsButtonProps) => {
const translate = useTranslate();
return (
<Button
className={classes.button}
label={translate('ticketSystemPassword.import.dialog.openButton')}
onClick={onClick}
>
<AddIcon />
</Button>
);
});
const ImportTicketSystemPasswordsButton = withStyles(styles)(
({ classes, onClick }: ImportTicketSystemPasswordsButtonProps) => {
const translate = useTranslate();
return (
<Button
className={classes.button}
label={translate('ticketSystemPassword.import.dialog.openButton')}
onClick={onClick}
>
<AddIcon />
</Button>
);
}
);

interface ImportTicketmasterPasswordsControlsProps {
record: AdminEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,95 +27,101 @@ interface ImportTicketSystemPasswordsModalProps
record: AdminEvent;
}

const ImportTicketSystemPasswordsFormDialog = withStyles(styles)(({
isOpen,
onClose,
classes,
record,
}: ImportTicketSystemPasswordsModalProps) => {
const translate = useTranslate();
const [passwordsText, setPasswordsText] = React.useState('');
const refresh = useRefresh();
const notify = useNotify();
const onChangePasswordsText: React.ChangeEventHandler<HTMLTextAreaElement> = (
e
) => {
setPasswordsText(e.currentTarget.value);
};
const ImportTicketSystemPasswordsFormDialog = withStyles(styles)(
({
isOpen,
onClose,
classes,
record,
}: ImportTicketSystemPasswordsModalProps) => {
const translate = useTranslate();
const [passwordsText, setPasswordsText] = React.useState('');
const refresh = useRefresh();
const notify = useNotify();
const onChangePasswordsText: React.ChangeEventHandler<
HTMLTextAreaElement
> = (e) => {
setPasswordsText(e.currentTarget.value);
};

const submitPasswords = async () => {
// Collect the passwords in a list
// Every new line is a new password
const passwords = passwordsText.split(/\r?\n/);
const submitPasswords = async () => {
// Collect the passwords in a list
// Every new line is a new password
const passwords = passwordsText.split(/\r?\n/);

// Submit the import event passwords mutation to the API
try {
const response =
await ticketSystemPasswordsApi.importTicketSystemPasswords({
data: {
eventId: record.id,
passwords,
},
});
const data = response?.data
? (response.data as unknown as ImportTicketSystemPasswords)
: null;
// Submit the import event passwords mutation to the API
try {
const response =
await ticketSystemPasswordsApi.importTicketSystemPasswords({
data: {
eventId: record.id,
passwords,
},
});
const data = response?.data
? (response.data as unknown as ImportTicketSystemPasswords)
: null;

if (data?.errors?.length) {
const passwordsWithError = data.errors.map((error) => error?.value);
notify('ticketSystemPassword.import.submit.passwords.error', {
type: 'warning',
passwords: passwordsWithError.join(', '),
});
}
if (data?.errors?.length) {
const passwordsWithError = data.errors.map((error) => error?.value);
notify('ticketSystemPassword.import.submit.passwords.error', {
type: 'warning',
passwords: passwordsWithError.join(', '),
});
}

notify('ticketSystemPassword.import.submit.success', { type: 'info' });
} catch (e) {
notify('ticketSystemPassword.import.submit.error', { type: 'error' });
}
notify('ticketSystemPassword.import.submit.success', { type: 'info' });
} catch (e) {
notify('ticketSystemPassword.import.submit.error', { type: 'error' });
}

// Clear input
setPasswordsText('');
// Clear input
setPasswordsText('');

// Close the dialog
onClose();
// Close the dialog
onClose();

refresh();
};
refresh();
};

return (
<Dialog open={isOpen} onClose={onClose} aria-labelledby="form-dialog-title">
<DialogTitle id="form-dialog-title">
{translate('ticketSystemPassword.import.dialog.title')}
</DialogTitle>
<DialogContent>
<DialogContentText>
{translate('ticketSystemPassword.import.dialog.text')}
</DialogContentText>
<TextareaAutosize
name="passwords"
className={classes.passwordsField}
aria-label={translate(
'ticketSystemPassword.import.passwords.ariaLabel'
)}
placeholder={translate(
'ticketSystemPassword.import.passwords.placeholder'
)}
minRows={10}
value={passwordsText}
onChange={onChangePasswordsText}
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>
{translate('ticketSystemPassword.import.action.cancel')}
</Button>
<Button onClick={submitPasswords} color="primary">
{translate('ticketSystemPassword.import.action.import')}
</Button>
</DialogActions>
</Dialog>
);
});
return (
<Dialog
open={isOpen}
onClose={onClose}
aria-labelledby="form-dialog-title"
>
<DialogTitle id="form-dialog-title">
{translate('ticketSystemPassword.import.dialog.title')}
</DialogTitle>
<DialogContent>
<DialogContentText>
{translate('ticketSystemPassword.import.dialog.text')}
</DialogContentText>
<TextareaAutosize
name="passwords"
className={classes.passwordsField}
aria-label={translate(
'ticketSystemPassword.import.passwords.ariaLabel'
)}
placeholder={translate(
'ticketSystemPassword.import.passwords.placeholder'
)}
minRows={10}
value={passwordsText}
onChange={onChangePasswordsText}
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>
{translate('ticketSystemPassword.import.action.cancel')}
</Button>
<Button onClick={submitPasswords} color="primary">
{translate('ticketSystemPassword.import.action.import')}
</Button>
</DialogActions>
</Dialog>
);
}
);

export default ImportTicketSystemPasswordsFormDialog;
Loading

0 comments on commit 22dd196

Please sign in to comment.