-
Notifications
You must be signed in to change notification settings - Fork 0
Support dashboard #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a new "support" user role, implements a punishment workflow for restaurants, and updates routing and login logic accordingly.
- Extend user role enum with "support"
- Add PunishRestaurantPage component, styles, and routes
- Update login redirection to be role-based and adjust API_BASE_URL
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/redux/slices/userSlice.ts | Added "support" to the role union in UserState |
| src/redux/Api/apiService.ts | Changed API_BASE_URL and adjusted logout import path |
| src/feature/Tickets/screens/PunishRestaurant.tsx | New page for support users to issue restaurant punishments |
| src/feature/Tickets/screens/PunishRestaurant.module.css | Styles for the new PunishRestaurantPage |
| src/feature/Login/Login.tsx | Added role in selector and role-based redirect logic |
| src/AppWithMaps.tsx | Registered /tickets and /punish-restaurant/:id routes |
Comments suppressed due to low confidence (3)
src/feature/Tickets/screens/PunishRestaurant.tsx:8
- [nitpick] Remove the ".ts" extension in the import path; most bundlers resolve TypeScript files without the extension, improving consistency and portability.
import { API_BASE_URL } from "../../../redux/Api/apiService.ts";
src/AppWithMaps.tsx:39
- [nitpick] Use a consistent route parameter name, e.g.
:restaurantId, to match other routes like/dashboard/:restaurantIdand improve clarity.
<Route path="/punish-restaurant/:id" element={<PunishRestaurantPage/>} />
src/feature/Login/Login.tsx:39
- The login handler dispatches only the token but never sets the user role; ensure you dispatch the role (e.g.,
setRole(result.role)) so the redirect logic has the correctrolevalue.
// The useEffect above will handle redirection after the role is set
|
|
||
| // export const API_BASE_URL = 'https://freshdealbackend.azurewebsites.net/v1'; | ||
| export const API_BASE_URL = 'http://192.168.1.3:8000/v1'; | ||
| export const API_BASE_URL = 'http://192.168.1.6:8000/v1'; |
Copilot
AI
May 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid hard-coding the API base URL in code; consider loading it from environment variables or a configuration file to simplify switching between environments.
| export const API_BASE_URL = 'http://192.168.1.6:8000/v1'; | |
| export const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:8000/v1'; |
|
|
||
| try { | ||
| setLoading(true); | ||
| console.log('Fetching restaurant details for ID:', id, 'with token:', token); |
Copilot
AI
May 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove or replace raw console.log statements with a controlled logging solution; leaving debug logs in production code can clutter the console and expose sensitive data.
|
|
||
|
|
||
|
|
||
| {error && <div className={styles.error}>{error}</div>} |
Copilot
AI
May 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add role="alert" or aria-live="assertive" to the error container so that screen readers announce the message as soon as it appears.
| {error && <div className={styles.error}>{error}</div>} | |
| {error && <div className={styles.error} role="alert">{error}</div>} |
No description provided.