Skip to content

Commit

Permalink
Merge pull request #181 from moderntribe/fix/MAD-12109/handle-empty-p…
Browse files Browse the repository at this point in the history
…ackage
  • Loading branch information
chumpgrub authored Jan 10, 2023
2 parents a9659de + 9ccf6b6 commit 227ab60
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-flowers-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moderntribe/sitebuilder': patch
---

Adds fix to handle null domain search package property
15 changes: 9 additions & 6 deletions packages/sitebuilder/src/utils/parseDomainListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type DomainListItem = {
selected: boolean,
}

function getPrice(termFees: DomainTermFees, isAvailable: boolean) {
if (! isAvailable) {
function getPrice(termFees: DomainTermFees | undefined, isAvailable: boolean) {
if (! termFees || ! isAvailable) {
return undefined;
}

Expand All @@ -31,8 +31,11 @@ function getPrice(termFees: DomainTermFees, isAvailable: boolean) {
);
}

function getChipLabel(isAvailable: boolean, isSelected: boolean) {
if (! isAvailable) {
function getChipLabel(domain: Domain, isSelected: boolean) {
if (! domain.package) {
return GoLiveStringData.domainItems.unavailable;
}
if (! domain.is_available) {
return GoLiveStringData.domainItems.taken;
}
if (isSelected) {
Expand All @@ -52,8 +55,8 @@ export function parseDomainListItem(domain: Domain, selected: boolean): DomainLi
return ({
name: domain.domain,
disabled: ! domain.is_available,
price: getPrice(domain.package.term_fees, domain.is_available),
chipLabel: getChipLabel(domain.is_available, selected),
price: getPrice(domain.package?.term_fees, domain.is_available),
chipLabel: getChipLabel(domain, selected),
chipColor: getChipColor(domain.is_available, selected),
selected,
});
Expand Down
1 change: 1 addition & 0 deletions packages/sitebuilder/src/wizards/go-live/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ export const GoLiveStringData = {
taken: __('Taken', 'moderntribe-sitebuilder'),
selected: __('Selected', 'moderntribe-sitebuilder'),
available: __('Available', 'moderntribe-sitebuilder'),
unavailable: __('Unavailable', 'moderntribe-sitebuilder'),
}
};

0 comments on commit 227ab60

Please sign in to comment.