Skip to content

Commit

Permalink
display toast upon update
Browse files Browse the repository at this point in the history
  • Loading branch information
SHni99 committed Jul 13, 2022
1 parent b405b87 commit cfab63d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const AnimatedRoutes = ({
<Route path="/create-listing" element={<CreateListingPage />} />
<Route path="/passwordpage" element={<PasswordPage />} />
<Route path="/resetpage" element={<ResetPage />} />
<Route path="/loginmainpage" element={<LoginMainPage />} />
<Route path="/loginmainpage" element={<LoginMainPage showSimpleToast={showSimpleToast}/>} />
<Route path="/formpage" element={<ReviewForm />} />
<Route
path="/profile"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfilePage/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ const ProfilePageBody = ({
)}

{show.email ? (
<div className="mb-3">
<div className="my-3">
<label className="poppins-normal-black-24px">Email:</label>
<div className="text ">{profileData.email}</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/UpdateProfilePage/updateProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Button from "react-bootstrap/Button";
import Form from "react-bootstrap/Form";

//retrieve session from loginmain page and call getProfile method if session is read
const UpdateProfilePage = ({ session }) => {
const UpdateProfilePage = ({ session, showSimpleToast }) => {
const { authData } = useContext(AuthContext);
const { username, gender, preferences, bio, avatar_url} = authData;
const { username, gender, preferences, bio, avatar_url } = authData;
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
const [genderOption, setGender] = useState(gender);
Expand Down Expand Up @@ -59,6 +59,8 @@ const UpdateProfilePage = ({ session }) => {
});

if (error) throw error;
showSimpleToast("Updated", "You have successfully updated!", 2000);
navigate("/listingspage");
} catch (error) {
alert(error.message);
} finally {
Expand Down Expand Up @@ -236,8 +238,6 @@ const ProfilePageBody = (props) => {
}}
onClick={() => {
updateProfile();
alert("updated");
navigate("/listingspage");
}}
>
<strong>{loading ? "Updating" : "Update"}</strong>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/loginMainPage/loginMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { supabaseClient } from "../../config/supabase-client";
import Login from "pages/LoginPage/login";
import Profile from "pages/UpdateProfilePage/updateProfile";

export default function LoginMainPage() {
export default function LoginMainPage({ showSimpleToast }) {
//value pass into setSession will update session
const [session, setSession] = useState(null);

Expand All @@ -22,7 +22,7 @@ export default function LoginMainPage() {
{!session ? (
<Login />
) : (
<Profile key={session.user.id} session={session} />
<Profile key={session.user.id} session={session} showSimpleToast={showSimpleToast}/>
)}
</div>
);
Expand Down

0 comments on commit cfab63d

Please sign in to comment.