Skip to content

Commit

Permalink
add loader
Browse files Browse the repository at this point in the history
  • Loading branch information
MargoMarm committed Sep 28, 2023
1 parent af2d527 commit 6828f4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/components/Lodaer/Loader.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Puff } from 'react-loader-spinner';
const Loader = ({ size }) => {

const Loader = ({ size, needToCenter }) => {
return (
<Puff
height={size}
Expand All @@ -10,6 +11,8 @@ const Loader = ({ size }) => {
wrapperStyle={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: needToCenter ? '100vh' : null,
margin: '20px auto 0 auto',
}}
wrapperClass=""
Expand Down
2 changes: 1 addition & 1 deletion src/components/SharedLayout/SharedLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const SharedLayout = () => {
return (
<Container>
<Header />
<Suspense fallback={<Loader />}>
<Suspense fallback={<Loader needToCenter/>}>
<Outlet />
</Suspense>
</Container>
Expand Down
14 changes: 11 additions & 3 deletions src/redux/auth/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ export const authSlice = createSlice({
state.error = null;
});
builder.addCase(logInUser.rejected, (state, action) => {
state.error = action.payload;
Notify.failure("Oops... Something went wrong! Enter correct email or password")
state.error = action.payload;
Notify.failure(
'Oops... Something went wrong! Enter correct email or password',
);
});

builder.addCase(logOutUser.fulfilled, state => {
Expand All @@ -89,12 +91,18 @@ export const authSlice = createSlice({
state.isLoggedIn = true;
state.error = null;
state.isRefreshing = false;
Loading.remove();
});
builder.addCase(fetchCurrentUser.rejected, state => {
state.isRefreshing = false;
Loading.remove();
});
builder.addCase(fetchCurrentUser.pending, state => {
state.isRefreshing = true;
Loading.standard({
svgColor: '#E6533C',
backgroundColor: '#040404',
});
});

//Update user data
Expand All @@ -105,7 +113,7 @@ export const authSlice = createSlice({
replaceUserState(state, payload);
state.error = null;
Loading.remove();
Notify.success('Your details have been updated');
Notify.success('Your details have been successfully updated');
});
builder.addCase(updateUserData.rejected, (state, action) => {
state.error = action.payload;
Expand Down

0 comments on commit 6828f4d

Please sign in to comment.