Skip to content

Commit

Permalink
Add logout button
Browse files Browse the repository at this point in the history
  • Loading branch information
aleda145 committed Aug 2, 2022
1 parent f6ce779 commit 9884ab9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/src/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React, { useEffect } from "react";
import { useQuery } from "@tanstack/react-query";
import { useNavigate, NavLink } from "react-router-dom";

export default function Dashboard({ client }) {
const navigate = useNavigate();

async function logOutClicked() {
await client.AuthStore.clear();
navigate("/dashboard");
}
const { isLoading, error, data } = useQuery(["repoData"], () =>
client.Records.getList("user_nums", 1, 50, {
filter: "created >= '2022-01-01 00:00:00'",
Expand All @@ -11,15 +18,15 @@ export default function Dashboard({ client }) {
if (isLoading) return "Loading...";

if (error) return "An error has occurred: " + error.message;
console.log(data);
console.log(data.items);
let favorite_numbers = [];
for (const item of data.items) {
favorite_numbers.push(item.num + " ");
}
return (
<div>
<div>My {client.AuthStore.model.email} favorite numbers</div>
<div>{favorite_numbers}</div>
<button onClick={logOutClicked}>Log out</button>
</div>
);
}

0 comments on commit 9884ab9

Please sign in to comment.