-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose add-on upsells to /plans pages
Add checkout functionality to spotlight plan Fix plans features main tests Fix type errors Refactor grid plans and default storage options Prevent purchased add-ons from being added to cart Remove unnecessary usePastBillingTransactions hook Add checkout link to storage add-ons data structure Add description to use default storage option hook Display prices for all add-on options
- Loading branch information
Showing
12 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 17 additions & 9 deletions
26
client/my-sites/plans-grid/hooks/npm-ready/data-store/use-default-storage-option.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
import type { StorageOption } from '@automattic/calypso-products'; | ||
import type { StorageOption, WPComStorageAddOnSlug } from '@automattic/calypso-products'; | ||
import type { AddOnMeta } from '@automattic/data-stores'; | ||
|
||
type Props = { | ||
storageAddOnsForPlan: ( AddOnMeta | null )[] | null; | ||
storageOptions: StorageOption[]; | ||
storageOptions?: StorageOption[]; | ||
}; | ||
|
||
/** | ||
* Returns the storage add-on upsell option to display to | ||
* the user on initial load. If the user has purchased a | ||
* storage add-on, that will be the default. Otherwise, | ||
* the storage included with any given plan will be used. | ||
* | ||
*/ | ||
export default function useDefaultStorageOption( { storageOptions, storageAddOnsForPlan }: Props ) { | ||
const [ purchasedStorageAddOn ] = | ||
storageAddOnsForPlan?.find( ( storageAddOn ) => storageAddOn?.purchased )?.featureSlugs ?? []; | ||
const [ purchasedStorageAddOnSlug ]: [ WPComStorageAddOnSlug ] = | ||
( storageAddOnsForPlan?.find( ( storageAddOn ) => storageAddOn?.purchased )?.featureSlugs as [ | ||
WPComStorageAddOnSlug, | ||
] ) ?? []; | ||
|
||
const defaultStorageOption = | ||
purchasedStorageAddOn || | ||
storageOptions?.find( ( storageOption ) => ! storageOption.isAddOn )?.slug; | ||
|
||
return defaultStorageOption; | ||
return ( | ||
purchasedStorageAddOnSlug || | ||
storageOptions?.find( ( storageOption ) => ! storageOption.isAddOn )?.slug | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters