Skip to content
Snippets Groups Projects
Commit 5700ca8e authored by andmag's avatar andmag
Browse files

Refactored toasts in redux actions

parent 6caae2ed
No related branches found
No related tags found
1 merge request!65Resolve "Refactor toastmessages"
......@@ -10,7 +10,7 @@ import {
UPDATE_SALAMANDER_LIST,
REMOVE_SALAMANDER_LIST,
} from "../actionConstants";
import Toast from "react-native-toast-message";
import { toast500, toastError, toastSuccess } from "../../constants/toasts";
/**
* Signs user in to the application.
......@@ -40,28 +40,15 @@ export const onUserLogin = ({
] = `Bearer ${response.data.access_token}`;
setShowIndicator(false);
signInApp(response.data.access_token);
Toast.show({
type: "success",
text1: "Success",
visibilityTime: 1000,
text2: response.data.message,
});
toastSuccess("top", 1000, response.data.message);
dispatch({ type: USER_LOGIN, payload: response.data });
} else {
setShowIndicator(false);
Toast.show({
type: "error",
text1: "Error",
text2: response.data.message,
});
toastError("top", 3000, response.data.message);
}
} catch (error) {
setShowIndicator(false);
Toast.show({
type: "error",
text1: "Error",
text2: "Server error.",
});
toast500();
dispatch({ type: ON_ERROR, payload: error });
}
};
......@@ -80,11 +67,7 @@ export const onUserSignOut = ({ signOutApp }) => {
signOutApp();
dispatch({ type: USER_LOGOUT });
} catch (error) {
Toast.show({
type: "error",
text1: "Error",
text2: "Server error.",
});
toast500();
dispatch({ type: ON_ERROR, payload: error });
}
};
......@@ -109,11 +92,7 @@ export const updateLocations = ({ setShowIndicator }) => {
} catch (error) {
console.log(error);
setShowIndicator(false);
Toast.show({
type: "error",
text1: "Error",
text2: "Network error. Token may have expired. Try logging in again.",
});
toast500();
}
};
};
......@@ -182,11 +161,7 @@ export const updateSalamanderList = ({ setShowIndicator, locationValue }) => {
}
} catch (error) {
setShowIndicator(false);
Toast.show({
type: "error",
text1: "Error",
text2: "Network error. Token may have expired. Try logging in again.",
});
toast500();
}
};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment