Skip to content

Commit 80573b3

Browse files
committed
Replace react-redux-toastr by sonner
1 parent 7c52e3c commit 80573b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+214
-327
lines changed

daikoku/javascript/package-lock.json

+16-62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

daikoku/javascript/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,16 @@
5959
"react-modal": "3.16.1",
6060
"react-paginate": "8.2.0",
6161
"react-redux": "8.1.3",
62-
"react-redux-toastr": "7.6.13",
6362
"react-router-dom": "6.22.0",
6463
"react-select": "5.8.0",
6564
"react-step-wizard": "5.3.11",
6665
"react-tooltip": "5.26.2",
6766
"recharts": "2.12.0",
6867
"redoc": "2.1.3",
6968
"redux": "4.2.1",
70-
"redux-logger": "3.0.6",
7169
"redux-thunk": "2.4.2",
7270
"set-value": "4.1.0",
71+
"sonner": "^1.4.0",
7372
"showdown": "2.1.0",
7473
"swagger-editor": "4.12.1",
7574
"swagger-ui-dist": "5.11.6",

daikoku/javascript/src/apps/DaikokuApp.tsx

-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import React, { useContext, useEffect, useState } from 'react';
22
import { BrowserRouter, BrowserRouter as Router, Route, Routes, useParams } from 'react-router-dom';
33
import { Navigate } from 'react-router';
44
import { useDispatch, useSelector } from 'react-redux';
5-
import ReduxToastr from 'react-redux-toastr';
65

76
import { SideBar, Spinner, Error, Footer } from '../components/utils';
87
import * as Services from '../services';
98
import { updateTeam, setError } from '../core';
109
import { TeamBackOffice } from '../components/backoffice/TeamBackOffice';
1110
import { ModalProvider, NavProvider } from '../contexts';
1211

13-
import 'react-redux-toastr/src/styles/index.scss';
14-
1512
import {
1613
TeamHome,
1714
MyHome,
@@ -403,14 +400,6 @@ export const DaikokuApp = ({
403400
<Error />
404401
</div>
405402
</div>
406-
<ReduxToastr
407-
timeOut={4000}
408-
newestOnTop={false}
409-
position="top-right"
410-
transitionIn="fadeIn"
411-
transitionOut="fadeOut"
412-
closeOnToastrClick
413-
/>
414403
<Routes>
415404
{['/settings', '/notifications', '/me', '/:teamId/settings'].map((r) => (
416405
<Route key={r} path={r} element={<></>} />

daikoku/javascript/src/apps/DaikokuHomeApp.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { constraints, Form, format, type } from '@maif/react-forms';
22
import { md5 } from 'js-md5';
33
import queryString from 'query-string';
44
import { useContext, useEffect, useState } from 'react';
5-
import { toastr } from 'react-redux-toastr';
5+
import { toast } from 'sonner';
66
import { BrowserRouter as Router, Route, Routes, useNavigate } from 'react-router-dom';
77

88
import { UnauthenticatedHome, UnauthenticatedTopBar } from '../components/frontend/unauthenticated';
@@ -329,9 +329,9 @@ export const TwoFactorAuthentication = ({
329329
function reset2faAccess() {
330330
Services.reset2faAccess(backupCode).then((res) => {
331331
if (res.error) {
332-
toastr.error(translate('Error'), res.error);
332+
toast.error(res.error);
333333
} else {
334-
toastr.success(translate('Success'), translate('2fa.successfully_disabled'));
334+
toast.success(translate('2fa.successfully_disabled'));
335335
window.location.replace('/');
336336
}
337337
});

daikoku/javascript/src/components/adminbackoffice/otoroshi/InititializeFromOtoroshi.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useMachine } from '@xstate/react';
33
import orderBy from 'lodash/orderBy';
44
import React, { useContext, useEffect, useState } from 'react';
55
import { useSelector } from 'react-redux';
6-
import { toastr } from 'react-redux-toastr';
6+
import { toast } from 'sonner';
77
import StepWizard from 'react-step-wizard';
88
import ReactDOMServer from 'react-dom/server';
99

@@ -155,14 +155,14 @@ export const InitializeFromOtoroshi = () => {
155155
setStep(1);
156156
// setApis({apis});
157157
setCreatedApis([]);
158-
toastr.success(translate('Success'), translate('Apis successfully created'));
158+
toast.success(translate('Apis successfully created'));
159159
});
160160
};
161161

162162
const afterSubCreation = () => {
163163
setStep(1);
164164
setCreatedSubs([]);
165-
toastr.success(translate('Success'), translate('Subscriptions successfully created'));
165+
toast.success(translate('Subscriptions successfully created'));
166166
};
167167

168168
const loadPreviousState = () => {
@@ -178,7 +178,7 @@ export const InitializeFromOtoroshi = () => {
178178
setCreatedSubs(prevState.createdSubs);
179179
send('LOAD_PREVIOUS_STATE', { otoroshi: prevState.otoroshi, tenant: prevState.tenant, goto: 'apikeys' });
180180
} else {
181-
toastr.warning(translate('Warning'), translate('Seems to have no saved state...please continue'));
181+
toast.warning(translate('Seems to have no saved state...please continue'));
182182
}
183183
};
184184

daikoku/javascript/src/components/adminbackoffice/otoroshi/TenantOtoroshi.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Form, type, constraints } from '@maif/react-forms'
55

66
import * as Services from '../../../services';
77
import { Can, manage, tenant as TENANT, Spinner } from '../../utils';
8-
import { toastr } from 'react-redux-toastr';
8+
import { toast } from 'sonner';
99
import { I18nContext } from '../../../contexts/i18n-context';
1010
import { useTenantBackOffice } from '../../../contexts';
1111

@@ -57,19 +57,19 @@ export const TenantOtoroshi = () => {
5757
Services.createOtoroshiSettings(tenant._id, data)
5858
.then((result) => {
5959
if (result.error) {
60-
toastr.error('Failure', result.error);
60+
toast.error(result.error);
6161
} else {
62-
toastr.success(translate('Success'), translate('otoroshi.settings.created.success'));
62+
toast.success(translate('otoroshi.settings.created.success'));
6363
navigate('/settings/otoroshis')
6464
}
6565
});
6666
} else {
6767
Services.saveOtoroshiSettings(tenant._id, data)
6868
.then((result) => {
6969
if (result.error) {
70-
toastr.error('Failure', result.error);
70+
toast.error(result.error);
7171
} else {
72-
toastr.success(translate('Success'), translate('otoroshi.settings.updated.success'));
72+
toast.success(translate('otoroshi.settings.updated.success'));
7373
navigate('/settings/otoroshis')
7474
}
7575
});

daikoku/javascript/src/components/adminbackoffice/otoroshi/TenantOtoroshis.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { nanoid } from 'nanoid';
66
import * as Services from '../../../services';
77
import { Table, TableRef } from '../../inputs';
88
import { Can, manage, tenant as TENANT } from '../../utils';
9-
import { toastr } from 'react-redux-toastr';
9+
import { toast } from 'sonner';
1010
import { I18nContext } from '../../../contexts/i18n-context';
1111
import { ModalContext, useTenantBackOffice } from '../../../contexts';
1212
import { IOtoroshiSettings, isError, IState, IStateContext } from '../../../types';
@@ -83,7 +83,7 @@ export const TenantOtoroshis = () => {
8383
if (ok) {
8484
Services.deleteOtoroshiSettings(tenant._id, id)
8585
.then(() => {
86-
toastr.success(translate('Success'), translate('otoroshi.settings.deleted.success'));
86+
toast.success(translate('otoroshi.settings.deleted.success'));
8787
table.current?.update();
8888
});
8989
}

daikoku/javascript/src/components/adminbackoffice/teams/TeamList.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query';
44
import debounce from "lodash/debounce";
55
import { useContext, useEffect, useMemo, useState } from 'react';
66
import Pagination from "react-paginate";
7-
import { toastr } from 'react-redux-toastr';
7+
import { toast } from 'sonner';
88
import { useNavigate } from 'react-router-dom';
99
import Plus from 'react-feather/dist/icons/plus'
1010

@@ -151,13 +151,11 @@ export const TeamList = () => {
151151
.then(team => Services.createTeam(team))
152152
.then(r => {
153153
if (r.error) {
154-
toastr.error(translate('Error'), r.error)
154+
toast.error(r.error)
155155
} else {
156156
queryClient.invalidateQueries({ queryKey: ['teams'] });
157-
toastr.info(
158-
translate("mailValidation.sent.title"),
159-
translate("mailValidation.sent.body"))
160-
toastr.success(translate('Success'), translate({ key: "team.created.success", replacements: [data.name] }))
157+
toast.info(translate("mailValidation.sent.body"))
158+
toast.success(translate({ key: "team.created.success", replacements: [data.name] }))
161159
}
162160
}),
163161
value: newTeam
@@ -226,9 +224,9 @@ export const TeamList = () => {
226224
.then(teamToUpdate => Services.updateTeam(teamToUpdate))
227225
.then(r => {
228226
if (r.error) {
229-
toastr.error(translate('Error'), r.error)
227+
toast.error(r.error)
230228
} else {
231-
toastr.success(translate('Success'), translate({ key: "team.updated.success", replacements: [team.name] }))
229+
toast.success(translate({ key: "team.updated.success", replacements: [team.name] }))
232230
queryClient.invalidateQueries({ queryKey: ['teams'] });
233231
}
234232
})

daikoku/javascript/src/components/adminbackoffice/tenants/EditFrontOfficeTranslations.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useContext, useEffect, useRef } from 'react';
22
import { useDispatch } from 'react-redux';
3-
import { toastr } from 'react-redux-toastr';
3+
import { toast } from 'sonner';
44
import { nanoid } from 'nanoid';
55
import { type, format, constraints } from '@maif/react-forms';
66

@@ -117,7 +117,7 @@ export function EditFrontOfficeTranslations(props: any) {
117117
} else {
118118
updateTranslation(t)
119119
.then(() => {
120-
toastr.success(translate('Success'), translate('mailing_internalization.translation_updated'))
120+
toast.success(translate('mailing_internalization.translation_updated'))
121121
table.current?.update()
122122
})
123123
}

0 commit comments

Comments
 (0)