Skip to content

Commit

Permalink
Merge pull request #3346 from energywebfoundation/chore/naming-and-typos
Browse files Browse the repository at this point in the history
  • Loading branch information
driamend authored Apr 8, 2022
2 parents 187536c + a3ca5a8 commit befdacc
Show file tree
Hide file tree
Showing 40 changed files with 181 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,24 @@ describe('Organization with status Active and User status active flow', () => {
cy.contains('Sell offers');
cy.contains('Buy offers');

cy.navigateMenu('exchangeAllBundles');
cy.url().should('include', 'all-bundles');
cy.navigateMenu('exchangeAllPackages');
cy.url().should('include', 'all-packages');
cy.contains('Total energy');
cy.contains('Price per MWh');

cy.navigateMenu('exchangeCreateBundle');
cy.url().should('include', 'create-bundle');
cy.contains('Create Bundle');
cy.navigateMenu('exchangeCreatePackage');
cy.url().should('include', 'create-package');
cy.contains('Create Package');
cy.contains('Selected For Sale');

cy.navigateMenu('exchangeMyTrades');
cy.url().should('include', 'my-trades');
cy.contains('My Trades');
cy.contains('Total');

cy.navigateMenu('exchangeMyBundles');
cy.url().should('include', 'my-bundles');
cy.contains('My bundles');
cy.navigateMenu('exchangeMyPackages');
cy.url().should('include', 'my-packages');
cy.contains('My packages');
cy.contains('Total energy');

cy.navigateMenu('exchangeMyOrders');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ describe('Organization with status Pending and User status active flow', () => {
cy.contains('Sell offers');
cy.contains('Buy offers');

cy.navigateMenu('exchangeAllBundles');
cy.url().should('include', 'all-bundles');
cy.navigateMenu('exchangeAllPackages');
cy.url().should('include', 'all-packages');
cy.contains('Total energy');
cy.contains('Price per MWh');

cy.navigateMenu('exchangeCreateBundle');
cy.url().should('include', 'create-bundle');
cy.navigateMenu('exchangeCreatePackage');
cy.url().should('include', 'create-package');
cy.contains('fulfill following criteria');
cy.contains('exchange deposit address');

Expand All @@ -135,8 +135,8 @@ describe('Organization with status Pending and User status active flow', () => {
cy.contains('fulfill following criteria');
cy.contains('exchange deposit address');

cy.navigateMenu('exchangeMyBundles');
cy.url().should('include', 'my-bundles');
cy.navigateMenu('exchangeMyPackages');
cy.url().should('include', 'my-packages');
cy.contains('fulfill following criteria');
cy.contains('exchange deposit address');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ describe('User with status Pending flow', () => {

cy.dataCy('exchangeMenu');
cy.dataCy('exchangeViewMarket');
cy.dataCy('exchangeAllBundles');
cy.dataCy('exchangeAllPackages');

cy.dataCy('exchangeCreateBundle').should('not.exist');
cy.dataCy('exchangeMyBundles').should('not.exist');
cy.dataCy('exchangeCreatePackage').should('not.exist');
cy.dataCy('exchangeMyPackages').should('not.exist');
cy.dataCy('exchangeMyTrades').should('not.exist');
cy.dataCy('exchangeMyOrders').should('not.exist');
cy.dataCy('exchangeSupply').should('not.exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useTranslation } from 'react-i18next';
import { useQueryClient } from 'react-query';
import { useGetBlockchainCertificateHandler } from '../fetching';

export const useRetireCertificateHandler = (
export const useBlockchainRedeemCertificateHandler = (
selectedBeneficiary: BeneficiaryDTO,
resetList: () => void,
startDate: Dayjs,
Expand All @@ -32,7 +32,7 @@ export const useRetireCertificateHandler = (
const { getBlockchainCertificate, isLoading: isGetBlockchainLoading } =
useGetBlockchainCertificateHandler();

const retireHandler = async <Id>(id: Id, amount: string) => {
const redeemHandler = async <Id>(id: Id, amount: string) => {
try {
const onChainCertificate = await getBlockchainCertificate(
id as unknown as CertificateDTO['id']
Expand All @@ -59,7 +59,7 @@ export const useRetireCertificateHandler = (
} else {
setTxPending(false);
showNotification(
t('certificate.blockchainInbox.notifications.retireSuccess'),
t('certificate.blockchainInbox.notifications.redeemSuccess'),
NotificationTypeEnum.Success
);
queryClient.resetQueries(blockchainCertificatesQueryKey);
Expand All @@ -68,13 +68,13 @@ export const useRetireCertificateHandler = (
} catch (error) {
console.error(error);
showNotification(
t('certificate.blockchainInbox.notifications.retireError'),
t('certificate.blockchainInbox.notifications.redeemError'),
NotificationTypeEnum.Error
);
}
};

const isLoading = isGetBlockchainLoading;

return { retireHandler, isLoading };
return { redeemHandler, isLoading };
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
AccountAssetDTO,
ClaimDataDTO,
getAccountBalanceControllerGetQueryKey,
RequestClaimDTO,
} from '@energyweb/exchange-react-query-client';
import {
useIrecTransferControllerRequestClaim,
Expand All @@ -20,7 +18,7 @@ import { useTranslation } from 'react-i18next';
import { useQueryClient } from 'react-query';
import { useCachedUser } from '../cached';

export const useClaimCertificateHandler = (
export const useExchangeRedeemCertificateHandler = (
exchangeCertificates: AccountAssetDTO[],
beneficiary: BeneficiaryDTO,
startDate: Dayjs,
Expand All @@ -36,7 +34,7 @@ export const useClaimCertificateHandler = (

const user = useCachedUser();

const claimHandler = <Id>(id: Id, amount: string) => {
const redeemHandler = <Id>(id: Id, amount: string) => {
setTxPending(true);
const assetId = exchangeCertificates.find(
(cert) =>
Expand Down Expand Up @@ -65,15 +63,15 @@ export const useClaimCertificateHandler = (
{
onSuccess: () => {
showNotification(
t('certificate.exchangeInbox.notifications.claimSuccess'),
t('certificate.exchangeInbox.notifications.redeemSuccess'),
NotificationTypeEnum.Success
);
queryClient.invalidateQueries(exchangeCertificatesQueryKey);
resetList();
},
onError: (error: any) => {
showNotification(
`${t('certificate.exchangeInbox.notifications.claimError')}:
`${t('certificate.exchangeInbox.notifications.redeemError')}:
${error?.response?.data?.message || ''}
`,
NotificationTypeEnum.Error
Expand All @@ -84,5 +82,5 @@ export const useClaimCertificateHandler = (
);
};

return { claimHandler, isMutating: isLoading };
return { redeemHandler, isMutating: isLoading };
};
4 changes: 2 additions & 2 deletions packages/ui/libs/certificate/data/src/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export * from './sellCertificate';
export * from './withdrawCertificate';
export * from './exchangeTransferCertificate';
export * from './exchangeExportCertificate';
export * from './claimCertificate';
export * from './exchangeRedeemCertificate';

export * from './depositCertificate';
export * from './retireCertificate';
export * from './blockchainRedeemCertificate';
export * from './blockchainTransferCertificate';
export * from './importCertificate';
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { formatSelectedBlockchainItems } from './formatSelectedBlockchain';
import {
SelectedItem,
TUseBeneficiaryFormLogic,
TUseRetireActionLogic,
TUseBlockchainRedeemActionLogic,
} from './types';

export const useRetireActionLogic: TUseRetireActionLogic<
export const useBlockchainRedeemActionLogic: TUseBlockchainRedeemActionLogic<
CertificateDTO['id']
> = ({ selectedIds, blockchainCertificates, allDevices, allFuelTypes }) => {
const { t } = useTranslation();
Expand All @@ -24,8 +24,8 @@ export const useRetireActionLogic: TUseRetireActionLogic<
: [];

return {
title: t('certificate.blockchainInbox.selectedForRetirement'),
buttonText: t('certificate.blockchainInbox.retireButton'),
title: t('certificate.blockchainInbox.selectedForRedemption'),
buttonText: t('certificate.blockchainInbox.redeemButton'),
selectedItems,
selectDisabledTooltip: t(
'certificate.blockchainInbox.addBeneficiariesTooltip'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './blockchainInbox';
export * from './depositAction';
export * from './retireAction';
export * from './blockchainRedeemAction';
export * from './blockchainTransferAction';
export * from './permissions';
export * from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export type TUseDepositActionLogic<Id> = (
selectedItems: SelectedItem<Id>[];
};

type TUseRetireActionLogicArgs<Id> = {
type TUseBlockchainRedeemActionLogicArgs<Id> = {
selectedIds: Id[];
blockchainCertificates: CertificateDTO[];
allDevices: ComposedPublicDevice[];
allFuelTypes: CodeNameDTO[];
};

export type TUseRetireActionLogic<Id> = (
args: TUseRetireActionLogicArgs<Id>
export type TUseBlockchainRedeemActionLogic<Id> = (
args: TUseBlockchainRedeemActionLogicArgs<Id>
) => {
title: string;
buttonText: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import * as yup from 'yup';
import { formatSelectedExchangeItems } from './formatSelectedExchangeItems';
import {
SelectedItem,
TUseClaimActionLogic,
TUseClaimBeneficiariesFormLogic,
TUseExchangeRedeemActionLogic,
TUseRedeemBeneficiariesFormLogic,
} from './types';

export const useClaimActionLogic: TUseClaimActionLogic<
export const useExchangeRedeemActionLogic: TUseExchangeRedeemActionLogic<
AccountAssetDTO['asset']['id']
> = ({ selectedIds, exchangeCertificates, allDevices, allFuelTypes }) => {
const { t } = useTranslation();
Expand All @@ -25,16 +25,16 @@ export const useClaimActionLogic: TUseClaimActionLogic<
: [];

return {
title: t('certificate.exchangeInbox.selectedForClaim'),
buttonText: t('certificate.exchangeInbox.claimButton'),
title: t('certificate.exchangeInbox.selectedForRedemption'),
buttonText: t('certificate.exchangeInbox.redeemButton'),
selectedItems,
selectDisabledTooltip: t(
'certificate.exchangeInbox.addBeneficiariesTooltip'
),
};
};

export const useClaimBeneficiaryFormLogic: TUseClaimBeneficiariesFormLogic = (
export const useRedeemBeneficiaryFormLogic: TUseRedeemBeneficiariesFormLogic = (
beneficiaries
) => {
const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export * from './sellAction';
export * from './withdrawAction';
export * from './exchangeTransferAction';
export * from './exchangeExportAction';
export * from './claimAction';
export * from './exchangeRedeemAction';
12 changes: 7 additions & 5 deletions packages/ui/libs/certificate/logic/src/exchange-inbox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,32 @@ export type TUseExchangeExportActionLogic<Id> = (
inputHeader: string;
};

type TUseClaimActionLogicArgs<Id> = {
type TUseExchangeRedeemActionLogicArgs<Id> = {
selectedIds: Id[];
exchangeCertificates: AccountAssetDTO[];
allDevices: ComposedPublicDevice[];
allFuelTypes: CodeNameDTO[];
};

export type TUseClaimActionLogic<Id> = (args: TUseClaimActionLogicArgs<Id>) => {
export type TUseExchangeRedeemActionLogic<Id> = (
args: TUseExchangeRedeemActionLogicArgs<Id>
) => {
title: string;
buttonText: string;
selectedItems: SelectedItem<Id>[];
selectDisabledTooltip: string;
};

export type ClaimBeneficiaryFormValues = {
export type RedeemBeneficiaryFormValues = {
beneficiary: number;
startDate: Dayjs;
endDate: Dayjs;
purpose: string;
};

export type TUseClaimBeneficiariesFormLogic = (
export type TUseRedeemBeneficiariesFormLogic = (
beneficiaries: BeneficiaryDTO[]
) => Pick<
GenericFormProps<ClaimBeneficiaryFormValues>,
GenericFormProps<RedeemBeneficiaryFormValues>,
'initialValues' | 'validationSchema' | 'fields'
>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
useCachedBlockchainCertificates,
useCachedAllFuelTypes,
useCachedAllDevices,
useRetireCertificateHandler,
useBlockchainRedeemCertificateHandler,
useCompanyBeneficiaries,
} from '@energyweb/origin-ui-certificate-data';
import {
useBeneficiaryFormLogic,
useRetireActionLogic,
useBlockchainRedeemActionLogic,
} from '@energyweb/origin-ui-certificate-logic';
import { Dayjs } from 'dayjs';
import { useMemo } from 'react';
Expand All @@ -16,7 +16,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
import { CertificateDTO } from '@energyweb/issuer-irec-api-react-query-client';
import { useTransactionPendingDispatch } from '../../../context';

export const useRetireActionEffects = (
export const useBlockchainRedeemActionEffects = (
selectedIds: CertificateDTO['id'][],
resetIds: () => void
) => {
Expand Down Expand Up @@ -46,8 +46,8 @@ export const useRetireActionEffects = (
[companyBeneficiaries, beneficiary]
);

const { retireHandler, isLoading: isHandlerLoading } =
useRetireCertificateHandler(
const { redeemHandler, isLoading: isHandlerLoading } =
useBlockchainRedeemCertificateHandler(
selectedBeneficiary,
resetIds,
startDate as Dayjs,
Expand All @@ -56,7 +56,7 @@ export const useRetireActionEffects = (
setTxPending
);

const actionLogic = useRetireActionLogic({
const actionLogic = useBlockchainRedeemActionLogic({
selectedIds,
blockchainCertificates,
allDevices,
Expand All @@ -70,7 +70,7 @@ export const useRetireActionEffects = (

return {
...actionLogic,
retireHandler,
redeemHandler,
isLoading,
buttonDisabled,
fields,
Expand Down
Loading

0 comments on commit befdacc

Please sign in to comment.