Refactor cache functions to use explicit loaders
The commit refactors the previous implementation of using cache functions across several modules. They are now explicitly defined as loaders to improve readability and maintain a consistent style. This prevents the cache function calls from getting too nested and difficult to understand, especially in asynchronous cases. Additionally, the user session related hooks are deleted which were not used anymore.
This commit is contained in:
@@ -22,7 +22,13 @@ const BILLING_MODE = z
|
||||
.default('subscription')
|
||||
.parse(process.env.BILLING_MODE);
|
||||
|
||||
export const loadTeamAccountBillingPage = cache((accountId: string) => {
|
||||
/**
|
||||
* @name loadTeamAccountBillingPage
|
||||
* @description Load the team account billing page data for the given account.
|
||||
*/
|
||||
export const loadTeamAccountBillingPage = cache(teamAccountBillingPageLoader);
|
||||
|
||||
function teamAccountBillingPageLoader(accountId: string) {
|
||||
const client = getSupabaseServerComponentClient();
|
||||
const api = createAccountsApi(client);
|
||||
|
||||
@@ -34,4 +40,4 @@ export const loadTeamAccountBillingPage = cache((accountId: string) => {
|
||||
const customerId = api.getCustomerId(accountId);
|
||||
|
||||
return Promise.all([data, customerId]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ export type TeamAccountWorkspace = Awaited<
|
||||
*
|
||||
* @param accountSlug
|
||||
*/
|
||||
export const loadTeamWorkspace = cache(async (accountSlug: string) => {
|
||||
export const loadTeamWorkspace = cache(workspaceLoader);
|
||||
|
||||
async function workspaceLoader(accountSlug: string) {
|
||||
const client = getSupabaseServerComponentClient();
|
||||
const api = createTeamAccountsApi(client);
|
||||
|
||||
@@ -48,4 +50,4 @@ export const loadTeamWorkspace = cache(async (accountSlug: string) => {
|
||||
...workspace.data,
|
||||
user,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user