Skip to content
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0bf844a
feat: recently accessed components
vani-walvekar1494 Jun 17, 2025
7a7c3b2
fix: format files to pass nx format check
vani-walvekar1494 Jun 17, 2025
6292b87
Fix: resolved merge conflicts and updated dashboard styles
vani-walvekar1494 Jun 17, 2025
35f37ad
chore: format AppsSideNav to pass format:check
vani-walvekar1494 Jun 17, 2025
3ccaa74
Fix: Replace 'any' with proper types in RecentProjects to satisfy lin…
vani-walvekar1494 Jun 17, 2025
9a6aa1b
chore: format files to pass nx format check
vani-walvekar1494 Jun 17, 2025
2fb2441
wip: partial DB connection setup and fix for recent tools issue
vani-walvekar1494 Jun 23, 2025
c439559
wip: partial DB connection setup and fix for recent tools issue
vani-walvekar1494 Jun 23, 2025
4ec4659
Merge remote-tracking branch 'origin/feat/react-dashboard' into feat/…
vani-walvekar1494 Jun 24, 2025
89f43e8
Apply local changes after merging feat/react-dashboard
vani-walvekar1494 Jun 24, 2025
ae7e243
Fix lint error and other updates
vani-walvekar1494 Jun 27, 2025
9698ff4
Fix lint error and update files after merging feat/react-dashboard
vani-walvekar1494 Jun 27, 2025
c4e91a4
Fix formatting issues
vani-walvekar1494 Jun 27, 2025
98b6f96
Format migration files with Black
vani-walvekar1494 Jun 27, 2025
db1aec1
chore: refactor dashboard API, cleanup migrations, remove unused icons
vani-walvekar1494 Jun 30, 2025
b5e6a15
fix: format files to pass lint checks
vani-walvekar1494 Jul 1, 2025
b5d0868
fix(AppsSideNav): add Applications header text to resolve failing test
vani-walvekar1494 Jul 1, 2025
b6045cd
fix: resolve AppsSideNav formatting issues
vani-walvekar1494 Jul 1, 2025
245cefe
fix: remove unused imports and variables in AppsSideNav to pass lint …
vani-walvekar1494 Jul 1, 2025
7af4852
Merge feat/react-dashboard into feat/react-dashboard-utils: resolved …
vani-walvekar1494 Jul 2, 2025
03e9fa5
feat(dashboard): update layout and fix recent projects visibility
vani-walvekar1494 Jul 11, 2025
aaeed75
Resolved merge conflicts and merged feat/react-dashboard into feat/re…
vani-walvekar1494 Jul 11, 2025
be8befc
Revert package-lock.json changes and formatting changes in api/datafi…
vani-walvekar1494 Jul 17, 2025
913da5a
changed sidebar styling and fixed tool navigation
vani-walvekar1494 Jul 17, 2025
294abbe
fixed linting for package-lock.json
vani-walvekar1494 Jul 17, 2025
6092a55
Fixed AppsSideNav hook usage
vani-walvekar1494 Jul 17, 2025
d23e6ef
fix: show Applications: header during loading to fix unit test
vani-walvekar1494 Jul 17, 2025
e582a90
Refactored favorites logic, fix types,updated styling and dependencies
vani-walvekar1494 Jul 25, 2025
63701fd
Restore apps.ts from main to include missing comments/docstrings
vani-walvekar1494 Jul 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions client/modules/_hooks/src/favouritesApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import axios from 'axios';

const getCSRFToken = (): string => {
const match = document.cookie.match(/(^| )csrftoken=([^;]+)/);
return match ? match[2] : '';
};

const axiosInstance = axios.create({
withCredentials: true,
headers: {
'Content-Type': 'application/json',
},
});

export interface FavoriteTool {
tool_id: string;
version?: string;
}

const fetchFavorites = async (): Promise<FavoriteTool[]> => {
const response = await axiosInstance.get('/api/workspace/user-favorites/');
return response.data;
};

const postAddFavorite = async (toolId: string): Promise<void> => {
const csrfToken = getCSRFToken();
await axiosInstance.post(
'/api/workspace/user-favorites/add/',
{ tool_id: toolId },
{ headers: { 'X-CSRFToken': csrfToken } }
);
};

const postRemoveFavorite = async (toolId: string): Promise<void> => {
const csrfToken = getCSRFToken();
await axiosInstance.post(
'/api/workspace/user-favorites/remove/',
{ tool_id: toolId },
{ headers: { 'X-CSRFToken': csrfToken } }
);
};

export const getUserFavorites = fetchFavorites;
export const addFavorite = postAddFavorite;
export const removeFavorite = postRemoveFavorite;

export const useFavorites = () => {
return useQuery<FavoriteTool[]>({
queryKey: ['favorites'],
queryFn: fetchFavorites,
staleTime: 5 * 60 * 1000, // 5 minutes
});
};

export const useAddFavorite = () => {
const queryClient = useQueryClient();
return useMutation<void, unknown, string>({
mutationFn: postAddFavorite,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['favorites'] });
},
});
};

export const useRemoveFavorite = () => {
const queryClient = useQueryClient();
return useMutation<void, unknown, string>({
mutationFn: postRemoveFavorite,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['favorites'] });
},
});
};
1 change: 1 addition & 0 deletions client/modules/_hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './datafiles';
export * from './systems';
export * from './notifications';
export * from './onboarding';
export * from './favouritesApi';
Loading
Loading