Skip to content

Dev#97

Merged
abhishek-nexgen-dev merged 3 commits into
masterfrom
dev
May 16, 2026
Merged

Dev#97
abhishek-nexgen-dev merged 3 commits into
masterfrom
dev

Conversation

@abhishek-nexgen-dev
Copy link
Copy Markdown
Member

No description provided.

- Reformatted imports for better organization in WebhookListPage and WebhookLogsPage.
- Enhanced readability by adjusting spacing and line breaks throughout the components.
- Updated state management and event handling for clarity in WebhookListPage.
- Implemented consistent error handling and loading states in WebhookLogsPage.
- Added axios utility for automatic token refresh on 401 errors.
- Introduced telemetry utility for tracking actions and errors.
- Adjusted routing structure in MemberRoutes and OrgRoute for better organization.
- Integrated SidebarProvider in MemberLayout for improved context management.
- Minor adjustments to LoginUserTemplate for role-based redirection.
- Updated vitest setup for consistent import style.
@abhishek-nexgen-dev abhishek-nexgen-dev merged commit 7c42130 into master May 16, 2026
1 of 2 checks passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces authentication and organization state management using Zustand, implements login logic with React Query, and adds an Axios interceptor for automatic token refreshing. It also includes extensive formatting updates across the documentation and the Tasks and Webhooks features. Feedback focuses on correcting programmatic navigation in components by using useNavigate instead of redirect, preventing infinite loops in the auth interceptor, moving side effects from useMemo to useEffect, and cleaning up debug logs and unused imports.

import useAuthStore from "../Auth/v1/Store/Auth.Store";
import SideBar from "../SideBar/v1/Section/SideBar";
import { Outlet } from "react-router";
import { Outlet, redirect } from "react-router";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The redirect function from react-router is intended for use in loaders and actions. To perform programmatic navigation within a component, use the useNavigate hook.

Suggested change
import { Outlet, redirect } from "react-router";
import { Outlet, useNavigate } from "react-router";

Comment thread src/utils/axios.utils.ts
const originalRequest = error.config as RetryAxiosRequestConfig;

// Check if error is 401 and we haven't already tried to refresh
if (error.response?.status === 401 && !originalRequest._retry) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This interceptor could cause an infinite loop if the /auth/refresh request itself returns a 401. Add a check to ensure the interceptor does not attempt to refresh when the failed request is the refresh request.

Suggested change
if (error.response?.status === 401 && !originalRequest._retry) {
if (error.response?.status === 401 && !originalRequest._retry && originalRequest.url !== "/auth/refresh") {

Comment on lines +10 to +22
let user = useAuthStore((state) => state.user);

useMemo(() => {

console.log("User in Organisation_Template-->:", user);


if (user?.role) {
if (user.role !== "organization") {
redirect("/");
}
}
}, [user]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Handle the navigation side effect using useEffect and useNavigate. Also, remove the console log and use const for the user variable.

  const user = useAuthStore((state) => state.user);
  const navigate = useNavigate();

  useEffect(() => {
    if (user?.role && user.role !== "organization") {
      navigate("/");
    }
  }, [user, navigate]);

import SideBarLink from "../Components/SideBarLink";
import { dashboardData } from "@/features/Member/v1/mock/dashboardData";
import useAuthStore from "@/features/Auth/v1/Store/Auth.Store";
import { useEffect } from "react";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Unused import useEffect.

Comment on lines +51 to +54
const response = await api.post(
`${baseUrl}${AUTH_ENDPOINTS.LOGIN}`,
credentials
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use relative paths with the axios instance.

Suggested change
const response = await api.post(
`${baseUrl}${AUTH_ENDPOINTS.LOGIN}`,
credentials
);
const response = await api.post(
AUTH_ENDPOINTS.LOGIN,
credentials
);

Comment on lines +20 to +22
const response = await api.get(
`${baseUrl}${AUTH_ENDPOINTS.GET_ORGANIZATION_BY_ID}?ownerId=${_id}`
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use relative paths with the axios instance to leverage the pre-configured baseURL.

Suggested change
const response = await api.get(
`${baseUrl}${AUTH_ENDPOINTS.GET_ORGANIZATION_BY_ID}?ownerId=${_id}`
);
const response = await api.get(
`${AUTH_ENDPOINTS.GET_ORGANIZATION_BY_ID}?ownerId=${_id}`
);

import { Outlet, redirect } from "react-router";
import BotamNavBar from "../SideBar/v1/Section/BotamNavBar";

import { useMemo } from "react";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Side effects like navigation should be handled in useEffect, not useMemo.

Suggested change
import { useMemo } from "react";
import { useEffect } from "react";

Comment on lines +8 to +9
const baseUrl =
import.meta.env.VITE_API_BASE_URL || "http://localhost:8000/api/v1";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The api instance (from axios.utils.ts) already has a baseURL configured. Defining baseUrl here and manually prepending it to every request is redundant and can lead to bugs if environment variables are inconsistent. Use relative paths with the axios instance.

Comment thread src/utils/axios.utils.ts
@@ -0,0 +1,43 @@
import axios, { AxiosError, AxiosRequestConfig, InternalAxiosRequestConfig } from "axios";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Unused import InternalAxiosRequestConfig.

Suggested change
import axios, { AxiosError, AxiosRequestConfig, InternalAxiosRequestConfig } from "axios";
import axios, { AxiosError, AxiosRequestConfig } from "axios";

Comment on lines +37 to +39
console.log("Login successful:", response);

// redirect / save token / navigate
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Remove debug logs and placeholder comments before merging.

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.

1 participant