Skip to content
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

fix(userRecentOpenings): (SILVA-570) stop retry if no user recent openings present #474

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions frontend/src/services/search/openings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ export const fetchOpenings = async (filters: OpeningFilters): Promise<any> => {

// Used to fetch the recent openings for a user based on a limit value
export const fetchUserRecentOpenings = async (limit: number): Promise<any> => {

// Retrieve the auth token
const authToken = getAuthIdToken();

// Make the API request with the Authorization header
Expand All @@ -132,6 +130,14 @@ export const fetchUserRecentOpenings = async (limit: number): Promise<any> => {
}
});

// Handle empty or invalid data gracefully
if (!response.data || response.data.data === null || response.data.data.length === 0) {
return {
...response.data,
data: [] // Return empty array for `data` to signal no results
};
}

// Flatten the data part of the response
const flattenedData = response.data.data.map((item: OpeningItem) => ({
...item,
Expand All @@ -143,13 +149,14 @@ export const fetchUserRecentOpenings = async (limit: number): Promise<any> => {
category: undefined // Remove the old nested category object
}));

// Returning the modified response data with the flattened structure
// Return the modified response data with the flattened structure
return {
...response.data,
data: flattenedData
};
};


export const fetchCategories = async (): Promise<any> => {
// Retrieve the auth token
const authToken = getAuthIdToken();
Expand Down
Loading