Skip to content

Commit

Permalink
small code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ccanos committed Sep 19, 2024
1 parent bb27bfa commit e42435c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 60 deletions.
16 changes: 8 additions & 8 deletions src/core/apollo/generated/apollo-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11453,9 +11453,9 @@ export function refetchRolesOrganizationQuery(variables: SchemaTypes.RolesOrgani
}

export const AssignLicensePlanToAccountDocument = gql`
mutation AssignLicensePlanToAccount($licensePlanId: UUID!, $accountID: UUID!, $licensingID: UUID!) {
mutation AssignLicensePlanToAccount($licensePlanId: UUID!, $accountId: UUID!, $licensingId: UUID!) {
assignLicensePlanToAccount(
planData: { accountID: $accountID, licensePlanID: $licensePlanId, licensingID: $licensingID }
planData: { accountID: $accountId, licensePlanID: $licensePlanId, licensingID: $licensingId }
) {
id
}
Expand All @@ -11480,8 +11480,8 @@ export type AssignLicensePlanToAccountMutationFn = Apollo.MutationFunction<
* const [assignLicensePlanToAccountMutation, { data, loading, error }] = useAssignLicensePlanToAccountMutation({
* variables: {
* licensePlanId: // value for 'licensePlanId'
* accountID: // value for 'accountID'
* licensingID: // value for 'licensingID'
* accountId: // value for 'accountId'
* licensingId: // value for 'licensingId'
* },
* });
*/
Expand All @@ -11506,9 +11506,9 @@ export type AssignLicensePlanToAccountMutationOptions = Apollo.BaseMutationOptio
SchemaTypes.AssignLicensePlanToAccountMutationVariables
>;
export const RevokeLicensePlanFromAccountDocument = gql`
mutation RevokeLicensePlanFromAccount($licensePlanId: UUID!, $accountID: UUID!, $licensingID: UUID!) {
mutation RevokeLicensePlanFromAccount($licensePlanId: UUID!, $accountId: UUID!, $licensingId: UUID!) {
revokeLicensePlanFromAccount(
planData: { accountID: $accountID, licensePlanID: $licensePlanId, licensingID: $licensingID }
planData: { accountID: $accountId, licensePlanID: $licensePlanId, licensingID: $licensingId }
) {
id
}
Expand All @@ -11533,8 +11533,8 @@ export type RevokeLicensePlanFromAccountMutationFn = Apollo.MutationFunction<
* const [revokeLicensePlanFromAccountMutation, { data, loading, error }] = useRevokeLicensePlanFromAccountMutation({
* variables: {
* licensePlanId: // value for 'licensePlanId'
* accountID: // value for 'accountID'
* licensingID: // value for 'licensingID'
* accountId: // value for 'accountId'
* licensingId: // value for 'licensingId'
* },
* });
*/
Expand Down
8 changes: 4 additions & 4 deletions src/core/apollo/generated/graphql-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16269,8 +16269,8 @@ export type RolesOrganizationQuery = {

export type AssignLicensePlanToAccountMutationVariables = Exact<{
licensePlanId: Scalars['UUID'];
accountID: Scalars['UUID'];
licensingID: Scalars['UUID'];
accountId: Scalars['UUID'];
licensingId: Scalars['UUID'];
}>;

export type AssignLicensePlanToAccountMutation = {
Expand All @@ -16280,8 +16280,8 @@ export type AssignLicensePlanToAccountMutation = {

export type RevokeLicensePlanFromAccountMutationVariables = Exact<{
licensePlanId: Scalars['UUID'];
accountID: Scalars['UUID'];
licensingID: Scalars['UUID'];
accountId: Scalars['UUID'];
licensingId: Scalars['UUID'];
}>;

export type RevokeLicensePlanFromAccountMutation = {
Expand Down
29 changes: 9 additions & 20 deletions src/core/ui/dialogs/InfoDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { gutters } from '../grid/utils';
// however there's no need of this entities, actions, etc. structure
interface InfoDialogProps {
entities: {
title?: string | React.ReactNode;
content?: ReactNode;
confirmButtonText?: string;
title: string | React.ReactNode;
content: ReactNode;
buttonCaption: string;
};
actions: {
onConfirm: () => void;
onButtonClick: () => void;
};
options: {
show: boolean;
Expand All @@ -27,22 +27,11 @@ interface InfoDialogProps {
}

const InfoDialog: FC<InfoDialogProps> = ({ entities, actions, options, state }) => {
const title = entities.title;
if (!title) {
throw new Error('The confirmation dialog needs a title provided');
}
const content = entities.content;
if (!content) {
throw new Error('The confirmation dialog needs text content provided');
}
const confirmButtonText = entities.confirmButtonText;
if (!confirmButtonText) {
throw new Error('The confirmation dialog needs button text content provided');
}
const { title, content, buttonCaption } = entities;

return (
<Dialog open={options.show} aria-labelledby="confirmation-dialog" onClose={actions.onConfirm}>
<DialogHeader onClose={actions.onConfirm}>
<Dialog open={options.show} aria-labelledby="confirmation-dialog" onClose={actions.onButtonClick}>
<DialogHeader onClose={actions.onButtonClick}>
<BlockTitle>{title}</BlockTitle>
</DialogHeader>
<DialogContent>{content}</DialogContent>
Expand All @@ -51,9 +40,9 @@ const InfoDialog: FC<InfoDialogProps> = ({ entities, actions, options, state })
variant="text"
loading={state?.isLoading}
disabled={state?.isLoading}
onClick={actions.onConfirm}
onClick={actions.onButtonClick}
>
{confirmButtonText}
{buttonCaption}
</LoadingButton>
</Actions>
</Dialog>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
mutation AssignLicensePlanToAccount($licensePlanId: UUID!, $accountID: UUID!, $licensingID: UUID!) {
mutation AssignLicensePlanToAccount($licensePlanId: UUID!, $accountId: UUID!, $licensingId: UUID!) {
assignLicensePlanToAccount(planData: {
accountID: $accountID
accountID: $accountId
licensePlanID: $licensePlanId
licensingID: $licensingID
licensingID: $licensingId
}) {
id
}
}

mutation RevokeLicensePlanFromAccount($licensePlanId: UUID!, $accountID: UUID!, $licensingID: UUID!) {
mutation RevokeLicensePlanFromAccount($licensePlanId: UUID!, $accountId: UUID!, $licensingId: UUID!) {
revokeLicensePlanFromAccount(planData: {
accountID: $accountID
accountID: $accountId
licensePlanID: $licensePlanId
licensingID: $licensingID
licensingID: $licensingId
}) {
id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ export const useAdminGlobalOrganizationsList = () => {
};

const [assignLicense] = useAssignLicensePlanToAccountMutation();
const assignLicensePlan = async (accountId: string, planId: string) => {
const assignLicensePlan = async (accountId: string, licensePlanId: string) => {
await assignLicense({
variables: {
accountID: accountId,
licensePlanId: planId,
licensingID: data?.platform.licensing.id ?? '',
accountId,
licensePlanId,
licensingId: data?.platform.licensing.id ?? '',
},
refetchQueries: [
refetchAdminGlobalOrganizationsListQuery({
Expand All @@ -125,12 +125,12 @@ export const useAdminGlobalOrganizationsList = () => {
};

const [revokeLicense] = useRevokeLicensePlanFromAccountMutation();
const revokeLicensePlan = async (accountId: string, planId: string) => {
const revokeLicensePlan = async (accountId: string, licensePlanId: string) => {
await revokeLicense({
variables: {
accountID: accountId,
licensePlanId: planId,
licensingID: data?.platform.licensing.id ?? '',
accountId,
licensePlanId,
licensingId: data?.platform.licensing.id ?? '',
},
refetchQueries: [
refetchAdminGlobalOrganizationsListQuery({
Expand Down
16 changes: 8 additions & 8 deletions src/domain/community/user/adminUsers/useAdminGlobalUserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ const useAdminGlobalUserList = ({
};

const [assignLicense] = useAssignLicensePlanToAccountMutation();
const assignLicensePlan = async (accountId: string, planId: string) => {
const assignLicensePlan = async (accountId: string, licensePlanId: string) => {
await assignLicense({
variables: {
accountID: accountId,
licensePlanId: planId,
licensingID: data?.platform.licensing.id ?? '',
accountId,
licensePlanId,
licensingId: data?.platform.licensing.id ?? '',
},
refetchQueries: [
refetchUserListQuery({
Expand All @@ -125,12 +125,12 @@ const useAdminGlobalUserList = ({
};

const [revokeLicense] = useRevokeLicensePlanFromAccountMutation();
const revokeLicensePlan = async (accountId: string, planId: string) => {
const revokeLicensePlan = async (accountId: string, licensePlanId: string) => {
await revokeLicense({
variables: {
accountID: accountId,
licensePlanId: planId,
licensingID: data?.platform.licensing.id ?? '',
accountId,
licensePlanId,
licensingId: data?.platform.licensing.id ?? '',
},
refetchQueries: [
refetchUserListQuery({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,16 @@ const useNewVirtualContributorWizard = (): useNewVirtualContributorWizardProvide
},
});

const vcId = data?.createVirtualContributor.id;
const virtualContributorId = data?.createVirtualContributor.id;

if (vcId) {
if (virtualContributorId) {
if (parentCommunityId) {
// the VC cannot be added to the BoK community
// if it's not part of the parent community
await addVirtualContributorToCommunity({
variables: {
communityId: parentCommunityId,
virtualContributorId: vcId,
virtualContributorId,
},
});
}
Expand All @@ -508,7 +508,7 @@ const useNewVirtualContributorWizard = (): useNewVirtualContributorWizardProvide
await addVirtualContributorToCommunity({
variables: {
communityId: communityId,
virtualContributorId: vcId,
virtualContributorId,
},
});

Expand All @@ -527,6 +527,7 @@ const useNewVirtualContributorWizard = (): useNewVirtualContributorWizardProvide

return false;
} catch (error) {
// TODO: log this to Sentry
return false;
}
};
Expand Down Expand Up @@ -583,9 +584,9 @@ const useNewVirtualContributorWizard = (): useNewVirtualContributorWizardProvide
entities={{
title: t('createVirtualContributorWizard.insufficientPrivileges.title'),
content: t('createVirtualContributorWizard.insufficientPrivileges.description'),
confirmButtonText: t('buttons.ok'),
buttonCaption: t('buttons.ok'),
}}
actions={{ onConfirm: onDialogClose }}
actions={{ onButtonClick: onDialogClose }}
options={{ show: true }}
/>
)}
Expand Down

0 comments on commit e42435c

Please sign in to comment.