Skip to content

Commit

Permalink
fixed review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mishramonalisha76 committed Aug 22, 2024
1 parent c5f3b0d commit c0b898d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/modules/sendNotification/SendNotification.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ export const getChannelChainList = (channelDetails: ChannelDetails, account: str
return [...aliases, appConfig.coreContractChain];
};

export const getChannelDelegatesOptions = (delegatees: [ChannelDetails]) => {
if (delegatees && delegatees.length) {
return delegatees?.map((channel) => ({
export const getChannelDelegatesOptions = (
delegatees: [ChannelDetails],
channelDetails: ChannelDetails | undefined
) => {
const delegateesArray = [...(delegatees || []), ...(channelDetails ? [channelDetails] : [])];
if (delegateesArray && delegateesArray.length) {
return delegateesArray?.map((channel) => ({
icon: (
<Box
width="24px"
Expand Down Expand Up @@ -66,7 +70,6 @@ export const getRecipients = (type: NotificationType, recipient: string) => {
};

export const getChannelAddress = (channelOption: ChannelDetails, chainId: string, onCoreNetwork: boolean) => {
console.debug(channelOption);
if (onCoreNetwork) return convertAddressToAddrCaip(channelOption.channel, parseInt(chainId));
else {
const aliasAddress =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const SendNotificationForm: FC<SendNotificationFormProps> = ({ channelDetails })
/** replace the delegatees with high level sdk function once it is available */
const { delegatees } = useSelector((state: any) => state.admin);
const onCoreNetwork = CORE_CHAIN_ID === chainId;
const delegateesOptions = getChannelDelegatesOptions(
delegatees?.length ? delegatees : channelDetails ? [channelDetails] : []
);

const delegateesOptions = getChannelDelegatesOptions(delegatees, channelDetails);

const selectedChannel =
delegatees?.find((delegatee: ChannelDetails) => delegatee.channel === formik.values.channelAddress) ||
delegatees?.find((delegatee: ChannelDetails) => delegatee.channel === delegateesOptions[0]?.value) ||
channelDetails;

const aliasChainOptions = getSelectChains(getChannelChainList(selectedChannel, account));

const formik = useFormik<NotficationValue>({
Expand Down

0 comments on commit c0b898d

Please sign in to comment.