Skip to content

Commit

Permalink
AI Assistant: add next-tier prop (#34028)
Browse files Browse the repository at this point in the history
* add next-tier prop on JP AI Helper

* add next-tier prop from response into the hooks and state

* changelog

* add mapped value for next-tier

* resolve conflicts
  • Loading branch information
CGastrell authored Nov 9, 2023
1 parent a0b90f7 commit f106233
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ public static function get_ai_assistance_feature() {
'site-require-upgrade' => $require_upgrade,
'upgrade-type' => $upgrade_type,
'current-tier' => WPCOM\Jetpack_AI\Usage\Helper::get_current_tier( $blog_id ),
'next-tier' => WPCOM\Jetpack_AI\Usage\Helper::get_next_tier( $blog_id ),
'tier-plans' => WPCOM\Jetpack_AI\Usage\Helper::get_tier_plans_list(),
);
}
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/add-jp-helper-next-tier
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Add next-tier prop to the AI assistant feature endpoint response. Add the prop to hooks and statee
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const AI_Assistant_Initial_State = {
currentTier: {
value: aiAssistantFeature?.[ 'current-tier' ]?.value || 1,
},
nextTier: aiAssistantFeature?.[ 'next-tier' ] || null,
};

export default function useAiFeature() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function mapAIFeatureResponseToAiFeatureProps(
currentTier: {
value: response[ 'current-tier' ]?.value || 1,
},
nextTier: response[ 'next-tier' ] || null,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const INITIAL_STATE: PlanStateProps = {
_meta: {
isRequesting: false,
},
nextTier: null,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type AiFeatureProps = {
nextStart: string;
requestsCount: number;
};
nextTier: null;
};

export type AiFeatureStateProps = AiFeatureProps & {
Expand Down
1 change: 1 addition & 0 deletions projects/plugins/jetpack/extensions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export type SiteAIAssistantFeatureEndpointResponseProps = {
limit: number;
value: TierValueProp;
} >;
'next-tier'?: null;
};

0 comments on commit f106233

Please sign in to comment.