Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import ReactDOM from "react-dom/client";

axios.defaults.withCredentials = true;

const queryClient = new QueryClient();
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 60_000,
},
},
});

// Create a new router instance
const router = createRouter({
Expand Down
9 changes: 0 additions & 9 deletions src/routes/dashboard/admin/members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@ const CARD_CLASS =
"rounded-[18px] border border-border bg-card shadow-[0px_4px_14px_rgba(112,144,176,0.14)] dark:shadow-[0px_4px_14px_rgba(0,0,0,0.4)]";
const TEAL_BUTTON_CLASS = "bg-brand-teal font-bold text-primary hover:bg-brand-teal/85";

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Tanstack Query options

const membersQueryOptions = queryOptions({
Expand All @@ -319,7 +311,6 @@ const membersQueryOptions = queryOptions({
}
return members;
},
...SHARED_QUERY_OPTIONS,
});

/// Helper functions
Expand Down
12 changes: 0 additions & 12 deletions src/routes/dashboard/admin/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ const EVENTS_PAGE_SIZE = 50;
const CARD_CLASS =
"rounded-[18px] border border-border bg-card shadow-[0px_4px_14px_rgba(112,144,176,0.14)] dark:shadow-[0px_4px_14px_rgba(0,0,0,0.4)]";

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Tanstack Query options

const overviewMembersQueryOptions = queryOptions({
Expand All @@ -139,7 +131,6 @@ const overviewMembersQueryOptions = queryOptions({
}
return members;
},
...SHARED_QUERY_OPTIONS,
});

const overviewProjectsQueryOptions = queryOptions({
Expand All @@ -156,7 +147,6 @@ const overviewProjectsQueryOptions = queryOptions({
}
return projects.filter((project) => project.active).length;
},
...SHARED_QUERY_OPTIONS,
});

const overviewEventsQueryOptions = queryOptions({
Expand All @@ -174,7 +164,6 @@ const overviewEventsQueryOptions = queryOptions({
}
return events.filter((event) => !isPastEvent(event, now)).length;
},
...SHARED_QUERY_OPTIONS,
});

const overviewTagsQueryOptions = queryOptions({
Expand All @@ -184,7 +173,6 @@ const overviewTagsQueryOptions = queryOptions({
const { data } = await axios.get<unknown[]>(`${API_BASE_URL}/tags`);
return data.length;
},
...SHARED_QUERY_OPTIONS,
});

/// Route components
Expand Down
9 changes: 0 additions & 9 deletions src/routes/dashboard/admin/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,6 @@ const FIELD_ERROR_CLASS = "text-[12px] font-semibold text-[#e13737] dark:text-[#
const TAG_PILL_CLASS =
"inline-flex items-center rounded-full border border-border bg-muted px-2 py-0.5 text-[11px] font-semibold text-brand-text-sub";

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Zod schema

const tagFormSchema = z.object({
Expand All @@ -242,7 +234,6 @@ const tagsQueryOptions = queryOptions({
const { data } = await axios.get<FullTags[]>(`${API_BASE_URL}/tags`);
return data;
},
...SHARED_QUERY_OPTIONS,
});

/// Helper functions
Expand Down
11 changes: 0 additions & 11 deletions src/routes/dashboard/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ const API_BASE_URL =
(import.meta.env.VITE_API_URL as string | undefined) ?? "http://localhost:8000";
const EVENTS_VIEWS: EventView[] = ["calendar", "grid", "list"];

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Tanstack Query options

const memberQueryOptions = (memberId: string) =>
Expand All @@ -145,7 +137,6 @@ const memberQueryOptions = (memberId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

const eventAttendanceCodeQueryOptions = (eventId: string) =>
Expand All @@ -157,7 +148,6 @@ const eventAttendanceCodeQueryOptions = (eventId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

const eventAttendanceQueryOptions = (eventId: string) =>
Expand All @@ -170,7 +160,6 @@ const eventAttendanceQueryOptions = (eventId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

/// Route components
Expand Down
9 changes: 0 additions & 9 deletions src/routes/dashboard/events_.past.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ const API_BASE_URL =
(import.meta.env.VITE_API_URL as string | undefined) ?? "http://localhost:8000";
const PAST_VIEWS: EventView[] = ["list", "grid"];

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Tanstack Query options

const memberQueryOptions = (memberId: string) =>
Expand All @@ -63,7 +55,6 @@ const memberQueryOptions = (memberId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

function DashboardPastEvents() {
Expand Down
11 changes: 0 additions & 11 deletions src/routes/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ const TEAL_BUTTON_CLASS =
const RAIL_CLASS =
"rounded-[20px] border border-border bg-card p-4 shadow-[0px_4px_14px_rgba(112,144,176,0.14)] dark:shadow-[0px_4px_14px_rgba(0,0,0,0.4)]";

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Tanstack Query options

export const memberEventsQueryOptions = (filter: "attended" | "planned") =>
Expand All @@ -92,7 +84,6 @@ export const memberEventsQueryOptions = (filter: "attended" | "planned") =>
return data;
},
select: (events: FullEvent[]) => new Set(events.map((event) => event.id)),
...SHARED_QUERY_OPTIONS,
});

export const eventsListQueryOptions = queryOptions({
Expand All @@ -114,7 +105,6 @@ export const eventsListQueryOptions = queryOptions({
}
return events;
},
...SHARED_QUERY_OPTIONS,
});

export const meQueryOptions = queryOptions({
Expand All @@ -123,7 +113,6 @@ export const meQueryOptions = queryOptions({
const { data } = await axios.get<ClientMember>(`${API_BASE_URL}/members/me`);
return data;
},
...SHARED_QUERY_OPTIONS,
});

export const plannedEventsQueryOptions = memberEventsQueryOptions("planned");
Expand Down
11 changes: 0 additions & 11 deletions src/routes/dashboard/manage/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,6 @@ const FACT_LABEL_CLASS =
"mb-1 text-[10.5px] font-bold tracking-[0.06em] text-muted-foreground uppercase";
const FACT_VALUE_CLASS = "text-[13.5px] font-bold text-foreground";

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Zod schema

const eventFormSchema = z
Expand Down Expand Up @@ -367,7 +359,6 @@ const manageEventsQueryOptions = queryOptions({
}
return events;
},
...SHARED_QUERY_OPTIONS,
});

const eventAttendanceQueryOptions = (eventId: string) =>
Expand All @@ -380,7 +371,6 @@ const eventAttendanceQueryOptions = (eventId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

const eventAttendanceCodeQueryOptions = (eventId: string) =>
Expand All @@ -392,7 +382,6 @@ const eventAttendanceCodeQueryOptions = (eventId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

/// Helper functions
Expand Down
11 changes: 0 additions & 11 deletions src/routes/dashboard/manage/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,6 @@ const FACT_VALUE_CLASS = "text-[13.5px] font-bold text-foreground";
const FIELD_ERROR_CLASS = "text-[12px] font-semibold text-[#e13737] dark:text-[#ff6b6b]";
const MONTH_YEAR_FMT = new Intl.DateTimeFormat("en-US", { month: "short", year: "numeric" });

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Zod schema

const projectFormSchema = z.object({
Expand Down Expand Up @@ -437,7 +429,6 @@ const manageProjectsQueryOptions = ({ active, name, page }: ProjectPageParams) =
return data;
},
placeholderData: keepPreviousData,
...SHARED_QUERY_OPTIONS,
});

const memberDirectoryQueryOptions = (query: string) =>
Expand All @@ -454,7 +445,6 @@ const memberDirectoryQueryOptions = (query: string) =>
return data.data ?? EMPTY_MEMBERS;
},
placeholderData: keepPreviousData,
...SHARED_QUERY_OPTIONS,
});

const manageInvitesQueryOptions = queryOptions({
Expand All @@ -465,7 +455,6 @@ const manageInvitesQueryOptions = queryOptions({
});
return data;
},
...SHARED_QUERY_OPTIONS,
});

/// Helper functions
Expand Down
12 changes: 0 additions & 12 deletions src/routes/dashboard/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,6 @@ const FACT_LABEL_CLASS =
const FACT_VALUE_CLASS = "text-[13.5px] font-bold text-foreground";
const MONTH_YEAR_FMT = new Intl.DateTimeFormat("en-US", { month: "short", year: "numeric" });

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

/// Tanstack Query options

export const projectsQueryOptions = queryOptions({
Expand All @@ -265,7 +257,6 @@ export const projectsQueryOptions = queryOptions({
});
return data.data;
},
...SHARED_QUERY_OPTIONS,
});

const memberProjectsQueryOptions = queryOptions({
Expand All @@ -275,7 +266,6 @@ const memberProjectsQueryOptions = queryOptions({
return data;
},
select: (projects: MemberProject[]) => new Set(projects.map((project) => project.id)),
...SHARED_QUERY_OPTIONS,
});

const projectInvitesQueryOptions = queryOptions({
Expand All @@ -287,7 +277,6 @@ const projectInvitesQueryOptions = queryOptions({
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

export const projectMediaQueryOptions = (projectId: string) =>
Expand All @@ -299,7 +288,6 @@ export const projectMediaQueryOptions = (projectId: string) =>
);
return data;
},
...SHARED_QUERY_OPTIONS,
});

/// Helper functions
Expand Down
11 changes: 0 additions & 11 deletions src/routes/dashboard/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,6 @@ const SIDEBAR_STYLE = {
"--sidebar-width-icon": "3.5rem",
} as CSSProperties;

const SHARED_QUERY_OPTIONS = {
staleTime: 60_000,
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
} as const;

const OPEN_SETTINGS = (): { settings: "profile" } => ({ settings: "profile" });
const SETTINGS_MASK = { to: "/dashboard/settings" } as const;
const BLANK_DELETE_FORM = { email: "" };
Expand Down Expand Up @@ -336,7 +328,6 @@ export const meQueryOptions = queryOptions({
const { data } = await axios.get<ClientMember>(`${API_BASE_URL}/members/me`);
return data;
},
...SHARED_QUERY_OPTIONS,
});

export const sudoQueryOptions = queryOptions({
Expand All @@ -345,15 +336,13 @@ export const sudoQueryOptions = queryOptions({
const { data } = await axios.get<Sudo>(`${API_BASE_URL}/sudo`);
return data;
},
...SHARED_QUERY_OPTIONS,
});

export const settingsFlowQueryOptions = queryOptions({
queryKey: ["ory", "settings"],
queryFn: async () => {
return await oryInit("settings", {});
},
...SHARED_QUERY_OPTIONS,
});

/// Helper functions
Expand Down