Skip to content

Commit

Permalink
Add description to use default storage option hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jeyip committed Oct 25, 2023
1 parent 3e5c14e commit ac5daa4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ type Props = {
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 [ purchasedStorageAddOnSlug ]: [ WPComStorageAddOnSlug ] =
( storageAddOnsForPlan?.find( ( storageAddOn ) => storageAddOn?.purchased )?.featureSlugs as [
WPComStorageAddOnSlug,
] ) ?? [];

// Default to most recently purchased storage add-on. Otherwise use default storage for plan.
return (
purchasedStorageAddOnSlug ||
storageOptions?.find( ( storageOption ) => ! storageOption.isAddOn )?.slug
Expand Down

0 comments on commit ac5daa4

Please sign in to comment.