Skip to content

Commit

Permalink
Merge pull request #296 from COS301-SE-2024/feat/web/Settings-page
Browse files Browse the repository at this point in the history
Feat/web/settings page
  • Loading branch information
Tinashe-Austin authored Aug 12, 2024
2 parents bd1b842 + 91f4d8f commit d7f7b4e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Binary file modified frontend/occupi-web/bun.lockb
Binary file not shown.
16 changes: 15 additions & 1 deletion frontend/occupi-web/src/AuthService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios";
import Cookies from "js-cookie"; // Import a cookie management library like js-cookie

const API_URL = "/auth"; // This will be proxied to https://dev.occupi.tech
const API_USER_URL = "/api"; // Adjust this if needed
Expand Down Expand Up @@ -182,13 +183,26 @@ const AuthService = {

logout: async () => {
try {
// Perform the logout request
const response = await axios.post(`${API_URL}/logout`, {});

// Attempt to clear all cookies after successful logout
try {
const allCookies = Cookies.get(); // Get all cookies
Object.keys(allCookies).forEach(cookieName => {
Cookies.remove(cookieName); // Remove each cookie
});
} catch (cookieError) {
console.error("Error clearing cookies:", cookieError);
throw new Error("Failed to clear cookies after logging out.");
}

return response.data;
} catch (error) {
if (axios.isAxiosError(error) && error.response?.data) {
throw error.response.data;
}
throw new Error("An unexpected error occurred Whilst Logging out");
throw new Error("An unexpected error occurred whilst logging out");
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,11 @@ export default function App() {
<div
data-testid="input-search"
className="flex justify-between gap-3 items-end"

>
<Input
isClearable
className="w-full sm:max-w-[44%] border-none"
className="w-full sm:max-w-[44%] border-none mt-5"
placeholder="Search by name..."
startContent={<SearchIcon />}
value={filterValue}
Expand Down
2 changes: 1 addition & 1 deletion frontend/occupi-web/src/pages/rooms/Rooms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const Rooms: React.FC = () => {
}}
/>

<div className="flex items-center justify-between mb-4">
<div className="flex items-center justify-between mb-4 mt-2">
<h2 className="text-text_col text-2xl font-bold"></h2>
<Button
className="text-text_col_alt font-semibold bg-secondary_alt"
Expand Down

0 comments on commit d7f7b4e

Please sign in to comment.