Skip to content

Commit

Permalink
Use translations for swal
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwalo32 committed Jan 15, 2024
1 parent fe6e62f commit 967b56b
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class AudioRecorder extends React.Component<AudioRecorderProps, AudioRecorderSta
title: this.state.lang.components.audio.deleteTitle,
text: this.state.lang.components.audio.deleteWarning,
icon: 'warning',
buttons: [true],
buttons: [true, true],
dangerMode: true,
}).then((willDelete) => {
if (willDelete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ const EditFieldModal = ({
title: translations.components.modal.deleteTitle,
text: translations.components.modal.deleteFieldConfirmation,
icon: 'warning',
buttons: [true],
buttons: [
translations.components.button.discard.cancelButton,
translations.components.button.discard.confirmButton,
],
dangerMode: true,
}).then((willDelete) => {
if (willDelete) {
Expand Down
5 changes: 4 additions & 1 deletion apps/frontend/src/components/EditRoleModal/EditRoleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ const EditRoleModal = ({
title: translations.components.modal.deleteTitle,
text: translations.components.modal.deleteUserConfirmation,
icon: 'warning',
buttons: [true],
buttons: [
translations.components.button.discard.cancelButton,
translations.components.button.discard.confirmButton,
],
dangerMode: true,
}).then(async (willDelete) => {
if (willDelete) {
Expand Down
5 changes: 4 additions & 1 deletion apps/frontend/src/components/EditStepModal/EditStepModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ const EditStepModal = ({
title: translations.components.modal.deleteTitle,
text: translations.components.modal.deleteStepConfirmation,
icon: 'warning',
buttons: [true],
buttons: [
translations.components.button.discard.cancelButton,
translations.components.button.discard.confirmButton,
],
dangerMode: true,
}).then((willDelete) => {
if (willDelete) {
Expand Down
8 changes: 6 additions & 2 deletions apps/frontend/src/components/Fields/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import './Fields.scss';
import { useTranslations } from '../../hooks/useTranslations';
import { formToJSON } from 'axios';
import { Nullish } from '@3dp4me/types';
import { useMemo } from 'react';

export interface DateFieldProps {
displayName: string
isDisabled: boolean
fieldId: string
value: string,
value: Nullish<string>,
onChange: (field: string, value: string) => void
}

Expand All @@ -22,11 +25,12 @@ const DateField = ({ displayName, isDisabled, fieldId, value, onChange }: DateFi
? 'input-field datepicker'
: 'active-input datepicker';


return (
<div>
<h3>{displayName}</h3>
<DatePicker
selected={new Date(Date.parse(value))}
selected={value ? new Date(Date.parse(value)): null}
disabled={isDisabled}
locale={selectedLang}
className={className}
Expand Down
11 changes: 5 additions & 6 deletions apps/frontend/src/components/Fields/MapField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import ReactMapGL, { MapRef, Marker } from 'react-map-gl';
import Geocoder from 'react-map-gl-geocoder';
Expand All @@ -13,11 +12,11 @@ import {
PIN_URL,
} from '../../utils/constants';
import './MapField.scss';
import { MapPoint } from '@3dp4me/types';
import { MapPoint, Nullish } from '@3dp4me/types';

export interface MapFieldProps {
value: MapPoint
initValue: MapPoint,
value: Nullish<MapPoint>
initValue: Nullish<MapPoint>,
displayName: string
isDisabled: boolean
onChange: (field: string, value: MapPoint) => void
Expand Down Expand Up @@ -131,8 +130,8 @@ const MapField = ({
>
<img
src={PIN_URL}
width={viewport?.zoom * 5}
height={viewport?.zoom * 5}
width={viewport?.zoom * 2}
height={viewport?.zoom * 2.5}
alt="Location marker"
/>
</Marker>
Expand Down
5 changes: 4 additions & 1 deletion apps/frontend/src/components/Files/Files.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ const Files = <T extends string>({
title: translations.components.file.deleteTitle,
text: translations.components.file.deleteWarning,
icon: 'warning',
buttons: [true],
buttons: [
translations.components.button.discard.cancelButton,
translations.components.button.discard.confirmButton,
],
dangerMode: true,
}).then((willDelete) => {
if (willDelete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ const ManagePatientModal = ({
title: translations.components.modal.deleteTitle,
text: translations.components.modal.deletePatientConfirmation,
icon: 'warning',
buttons: [true, true],
buttons: [
translations.components.button.discard.cancelButton,
translations.components.button.discard.confirmButton,
],
dangerMode: true,
}).then(async (willDelete) => {
if (willDelete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ const ManageRoleModal = ({
title: translations.components.modal.deleteTitle,
text: translations.roleManagement.warning,
icon: 'warning',
buttons: [true],
buttons: [
translations.components.button.discard.cancelButton,
translations.components.button.discard.confirmButton,
],
dangerMode: true,
}).then(async (willDelete) => {
if (willDelete) {
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/components/PatientTable/PatientTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const PatientTable = ({
swal({
title: translations.components.swal.createPatient.successMsg,
icon: 'success',
buttons: [translations.components.button.discard.confirmButton],
});

onAddPatient(patient);
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/src/components/StepContent/StepContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ const StepContent = ({
swal({
title: translations.components.button.discard.success,
icon: 'success',
buttons:
[translations.components.button.discard.confirmButton],
buttons: [translations.components.button.discard.confirmButton],
});
// TODO: Nonexistent values don't get reset.
setUpdatedData(_.cloneDeep(stepData));
Expand Down

0 comments on commit 967b56b

Please sign in to comment.