Skip to content

Commit

Permalink
fix queryKey args, sort some imports alphabetically, general style
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyFinn-Akamai committed Jul 13, 2023
1 parent 2721659 commit 7650e1c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 2 additions & 6 deletions packages/api-v4/src/account/betas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import Request, {
setData,
} from '../request';
import { Filter, Params, ResourcePage } from '../types';
import { AccountBeta } from './types';

export interface EnrollInBetaData {
id: string;
}
import { AccountBeta, EnrollInBetaPayload } from './types';

/**
* getBetas
Expand Down Expand Up @@ -45,7 +41,7 @@ export const getAccountBeta = (betaId: string) =>
* @param data.id { string } ID of the beta you want to be enrolled in.
*
*/
export const enrollInBeta = (data: EnrollInBetaData) =>
export const enrollInBeta = (data: EnrollInBetaPayload) =>
Request<{}>(
setURL(`${API_ROOT}/account/betas`),
setMethod('POST'),
Expand Down
4 changes: 4 additions & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,7 @@ export interface AccountLogin {
export interface AccountBeta extends Beta {
enrolled: string;
}

export interface EnrollInBetaPayload {
id: string;
}
2 changes: 1 addition & 1 deletion packages/manager/src/factories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export * from './accountSettings';
export * from './accountMaintenance';
export * from './accountOAuth';
export * from './accountPayment';
export * from './billing';
export * from './betas';
export * from './billing';
export * from './config';
export * from './databases';
export * from './disk';
Expand Down
14 changes: 7 additions & 7 deletions packages/manager/src/queries/accountBetas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
AccountBeta,
getAccountBetas,
EnrollInBetaData,
EnrollInBetaPayload,
getAccountBeta,
enrollInBeta,
} from '@linode/api-v4/lib/account';
Expand All @@ -17,27 +17,27 @@ export const queryKey = 'account-beta';

export const useAccountBetasQuery = (params?: Params, filter?: Filter) =>
useQuery<ResourcePage<AccountBeta>, APIError[]>(
[`${queryKey}-list`, params, filter],
[queryKey, 'paginated', params, filter],
() => getAccountBetas(params, filter),
{
keepPreviousData: true,
}
);

export const useAccountBetaQuery = (id: string) =>
useQuery<AccountBeta, APIError[]>([queryKey, id], () => getAccountBeta(id), {
keepPreviousData: true,
});
useQuery<AccountBeta, APIError[]>([queryKey, 'account-beta', id], () =>
getAccountBeta(id)
);

export const useCreateAccountBetaMutation = () => {
const queryClient = useQueryClient();
return useMutation<{}, APIError[], EnrollInBetaData>(
return useMutation<{}, APIError[], EnrollInBetaPayload>(
(data) => {
return enrollInBeta(data);
},
{
onSuccess() {
queryClient.invalidateQueries(`${queryKey}-list`);
queryClient.invalidateQueries([queryKey, 'paginated']);
},
}
);
Expand Down

0 comments on commit 7650e1c

Please sign in to comment.