Răsfoiți Sursa

fixed logout white screen

jusrhee 5 ani în urmă
părinte
comite
dffe5ac537

+ 3 - 3
dashboard/src/main/Main.tsx

@@ -40,7 +40,7 @@ export default class Main extends Component<PropsType, StateType> {
     api
       .checkAuth("", {}, {})
       .then(res => {
-        if (res && res.data) {
+        if (res && res?.data) {
           setUser(res?.data?.id, res?.data?.email);
           this.setState({
             isLoggedIn: true,
@@ -64,7 +64,7 @@ export default class Main extends Component<PropsType, StateType> {
     api
       .checkAuth("", {}, {})
       .then(res => {
-        if (res && res.data) {
+        if (res && res?.data) {
           this.context.setUser(res?.data?.id, res?.data?.email);
           this.setState({
             isLoggedIn: true,
@@ -89,7 +89,7 @@ export default class Main extends Component<PropsType, StateType> {
         this.setState({ isLoggedIn: false, initialized: true });
         localStorage.clear();
       })
-      .catch(err => this.context.setCurrentError(err.response.data.errors[0]));
+      .catch(err => this.context.setCurrentError(err.response?.data.errors[0]));
   };
 
   renderMain = () => {

+ 1 - 1
dashboard/src/main/home/navbar/Navbar.tsx

@@ -51,7 +51,7 @@ export default class Navbar extends Component<PropsType, StateType> {
           }
         >
           <I className="material-icons-outlined">account_circle</I>
-          {this.context.user.email}
+          {this.context.user?.email}
           {this.renderSettingsDropdown()}
         </NavButton>
       </StyledNavbar>