Skip to content

Commit

Permalink
fix: undefined email in profile (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dun-sin authored Sep 27, 2023
1 parent 0e18d4b commit 23fe79f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/src/context/reducers/authReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function authReducer(state, action) {
});
// Save auth state to localStorage on each change
localStorage.setItem('auth', JSON.stringify(clonedState));

return clonedState;
}

Expand All @@ -39,4 +40,5 @@ export default function authReducer(state, action) {
default:
throw new Error('No action provided!');
}

}
7 changes: 4 additions & 3 deletions client/src/pages/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ import { api } from 'src/lib/axios';
import { createClassesFromArray } from 'src/lib/utils';

const Profile = () => {
const [username, setUsername] = useState('anonymous')
const [username, setUsername] = useState('Anonymous')

const { email, dispatchAuth } = useAuth();
const { authState, dispatchAuth } = useAuth();
const { logout } = useKindeAuth()

const aboutRef = useRef(null)
const genderRef = useRef(null)
const ageRef = useRef(null)

const { email } = authState

const getProfileData = async (email) => {
try {
const response = await api.get(`/profile/${email}`);
const { aboutMe, age, gender, username } = response.data

setUsername(username);
aboutRef.current.value = aboutMe;
aboutRef.current.value = aboutMe || ''
ageRef.current.value = age
genderRef.current.value = gender
} catch (error) {
Expand Down

1 comment on commit 23fe79f

@vercel
Copy link

@vercel vercel bot commented on 23fe79f Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.