nexus-react-core
Version:
A comprehensive React toolkit with services, hooks, and Redux store management
87 lines • 3.17 kB
TypeScript
export interface RouterInterface {
push: (url: string) => void;
}
export declare const setRouter: (router: RouterInterface) => void;
/**
* Makes API calls with automatic token refresh
* @param endpoint API endpoint (without base URL)
* @param method HTTP method
* @param data Request data (optional)
* @param headers Additional headers (optional)
*/
export declare const apiCall: (endpoint: string, method?: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: Record<string, string>) => Promise<any>;
/**
* Utility function to check if user has a specific role
* @param roleToCheck The role to check against
* @returns boolean indicating if user has the specified role
*/
export declare const checkUserRole: (roleToCheck: string) => Promise<boolean>;
/**
* Utility function to get the user's MongoDB ID
*/
export declare const getUserMongoId: () => Promise<string>;
/**
* Fetches notifications for a user
*/
export declare const fetchUserNotifications: (userId: string, forceRefresh?: boolean) => Promise<any>;
/**
* Fetches latest notifications
*/
export declare const getLatestNotificationsWithRefresh: (userId: string) => Promise<any>;
/**
* Add a function to handle user login that will initialize the socket for notifications
*/
export declare const handleUserLogin: (userData: any) => Promise<void>;
/**
* Interface for streak functionality data
*/
export interface StreakData {
currentStreak: number;
longestStreak: number;
multiplier: number;
isActive: boolean;
streakDates: Date[];
lastActivityDate: Date | null;
timeLeftToLoseStreak?: number | null;
streakLossWarning?: boolean;
}
/**
* Fetches the current streak status for a user
*/
export declare const fetchStreakStatus: (userId: string) => Promise<StreakData & {
timeLeftToLoseStreak: number | null;
streakLossWarning?: boolean;
}>;
/**
* Updates the streak for a user
*/
export declare const updateStreak: (userId: string) => Promise<StreakData>;
/**
* Marks all notifications as read for a user
*/
export declare const markAllNotificationsAsRead: (userId: string) => Promise<void>;
/**
* Marks a specific notification as read
*/
export declare const markNotificationAsRead: (notificationId: string, userId: string) => Promise<void>;
/**
* Deletes a notification
*/
export declare const deleteNotification: (notificationId: string, userId: string) => Promise<any>;
/**
* Gets the streak calendar for a specific month and year
*/
export declare const getStreakCalendar: (userId: string, year: number, month: number) => Promise<Date[]>;
/**
* Gets the current streak multiplier for a user
*/
export declare const getStreakMultiplier: (userId: string) => Promise<number>;
/**
* Makes API calls that don't require authentication (like login/signup)
* @param endpoint API endpoint (without base URL)
* @param method HTTP method
* @param data Request data (optional)
* @param headers Additional headers (optional)
*/
export declare const publicApiCall: (endpoint: string, method?: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: Record<string, string>) => Promise<any>;
//# sourceMappingURL=apiCall.d.ts.map