mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2025-05-17 20:08:07 +08:00
Move to modals for user feedback
This commit is contained in:
parent
529a7a75fd
commit
ff114b496c
10 changed files with 203 additions and 82 deletions
|
@ -15,11 +15,13 @@ import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContai
|
|||
import { setUser } from "../../features/redux/slices/UserSlice/UserSlice";
|
||||
import { setOnboarding } from "../../features/redux/slices/StatusSlice/StatusSlice";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { useToast } from "react-native-toast-notifications";
|
||||
|
||||
export default function Revalidation() {
|
||||
const dispatch = useDispatch();
|
||||
const navigation = useNavigation<RootDrawerParamList>();
|
||||
const [state, setState] = useState("Checking for existing session");
|
||||
const toast = useToast();
|
||||
useEffect(() => {
|
||||
setState("Previous session found");
|
||||
TokenRefresh().then(async (response) => {
|
||||
|
@ -33,17 +35,35 @@ export default function Revalidation() {
|
|||
!user_info[1].semester
|
||||
) {
|
||||
dispatch(setOnboarding());
|
||||
toast.show("Previous session restored", {
|
||||
type: "success",
|
||||
placement: "bottom",
|
||||
duration: 4000,
|
||||
animationType: "slide-in",
|
||||
});
|
||||
await setTimeout(() => {
|
||||
navigation.navigate("Onboarding");
|
||||
}, 700);
|
||||
} else {
|
||||
dispatch(unsetOnboarding());
|
||||
toast.show("Previous session restored", {
|
||||
type: "success",
|
||||
placement: "bottom",
|
||||
duration: 4000,
|
||||
animationType: "slide-in",
|
||||
});
|
||||
await setTimeout(() => {
|
||||
navigation.navigate("Home");
|
||||
}, 700);
|
||||
}
|
||||
} else {
|
||||
await setState("Session expired");
|
||||
toast.show("Session expired. Please login again", {
|
||||
type: "warning",
|
||||
placement: "bottom",
|
||||
duration: 4000,
|
||||
animationType: "slide-in",
|
||||
});
|
||||
await setTimeout(() => {
|
||||
AsyncStorage.clear();
|
||||
navigation.navigate("Login");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue