add duration to toast

show until closed for batch users
This commit is contained in:
Davor 2022-07-27 13:44:00 +02:00
parent e830a095b8
commit d57fe9f488
2 changed files with 6 additions and 6 deletions

View file

@ -9,7 +9,7 @@ export enum ToastType {
Error = 'error', Error = 'error',
} }
export const showToast = (text: string, type?: ToastType) => { export const showToast = (text: string, type?: ToastType, duration?: number) => {
switch (type) { switch (type) {
case ToastType.Error: case ToastType.Error:
toast.custom( toast.custom(
@ -47,7 +47,7 @@ export const showToast = (text: string, type?: ToastType) => {
</div> </div>
</Transition> </Transition>
), ),
{ position: 'top-right' }, { position: 'top-right', duration },
); );
break; break;
default: default:
@ -86,7 +86,7 @@ export const showToast = (text: string, type?: ToastType) => {
</div> </div>
</Transition> </Transition>
), ),
{ position: 'top-right' }, { position: 'top-right', duration },
); );
} }
}; };

View file

@ -228,13 +228,13 @@ export const createBatchUsers = (users: any) => async (dispatch: Dispatch<any>)
// show information about created users // show information about created users
if (!_.isEmpty(responseData.success)) { if (!_.isEmpty(responseData.success)) {
showToast(responseData.success.message, ToastType.Success); showToast(responseData.success.message, ToastType.Success, Infinity);
} }
if (!_.isEmpty(responseData.existing)) { if (!_.isEmpty(responseData.existing)) {
showToast(responseData.existing.message, ToastType.Error); showToast(responseData.existing.message, ToastType.Error, Infinity);
} }
if (!_.isEmpty(responseData.failed)) { if (!_.isEmpty(responseData.failed)) {
showToast(responseData.failed.message, ToastType.Error); showToast(responseData.failed.message, ToastType.Error, Infinity);
} }
dispatch(fetchUsers()); dispatch(fetchUsers());