Skip to content

Conversation

@emreutkan
Copy link
Member

No description provided.

@emreutkan emreutkan requested a review from Copilot May 17, 2025 12:27
@emreutkan emreutkan merged commit 42d9c2b into main May 17, 2025
2 checks passed
Copy link

Copilot AI left a 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/:restaurantId and 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 correct role value.
// 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';
Copy link

Copilot AI May 17, 2025

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.

Suggested change
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';

Copilot uses AI. Check for mistakes.

try {
setLoading(true);
console.log('Fetching restaurant details for ID:', id, 'with token:', token);
Copy link

Copilot AI May 17, 2025

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.

Copilot uses AI. Check for mistakes.



{error && <div className={styles.error}>{error}</div>}
Copy link

Copilot AI May 17, 2025

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.

Suggested change
{error && <div className={styles.error}>{error}</div>}
{error && <div className={styles.error} role="alert">{error}</div>}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants