Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/common/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,15 @@ export interface paths {
};
};
};
"/plans/{pid}/rules-evaluation": {
/** Usefull endpoint when a purchasable plan have some failed rules */
get: operations["get-plans-pid-rules-evaluation"];
parameters: {
path: {
pid: string;
};
};
};
"/plans/{pid}/status": {
/** */
patch: operations["patch-workspaces-wid-plans-pid-status"];
Expand Down Expand Up @@ -1424,6 +1433,16 @@ export interface components {
name: string;
workspaceId: number;
};
/**
* PurchasablePlanRules
* @enum {string}
*/
PurchasablePlanRules:
| "number_of_modules"
| "module_type"
| "number_of_testers"
| "number_of_tasks"
| "task_type";
/** Report */
Report: {
creation_date?: string;
Expand Down Expand Up @@ -3344,8 +3363,12 @@ export interface operations {
config: {
modules: components["schemas"]["Module"][];
};
from_template?: {
id: number;
title: string;
};
id: number;
is_frozen?: number;
price?: string;
project: {
id: number;
name: string;
Expand Down Expand Up @@ -3421,6 +3444,24 @@ export interface operations {
500: components["responses"]["Error"];
};
};
/** Usefull endpoint when a purchasable plan have some failed rules */
"get-plans-pid-rules-evaluation": {
parameters: {
path: {
pid: string;
};
};
responses: {
/** OK */
200: {
content: {
"application/json": {
failed: components["schemas"]["PurchasablePlanRules"][];
};
};
};
};
};
/** */
"patch-workspaces-wid-plans-pid-status": {
parameters: {
Expand Down
1 change: 1 addition & 0 deletions src/features/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const apiSlice = createApi({
'Archive',
'Plans',
'Users',
'EvaluationRules',
],
endpoints: () => ({}),
});
5 changes: 4 additions & 1 deletion src/features/api/apiTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ unguessApi.enhanceEndpoints({
},
},
patchPlansByPid: {
invalidatesTags: ['Plans'],
invalidatesTags: ['Plans', 'EvaluationRules'],
},
postWorkspacesByWidPlans: {
invalidatesTags: ['Plans'],
Expand All @@ -324,6 +324,9 @@ unguessApi.enhanceEndpoints({
getWorkspacesByWidTemplates: {
providesTags: ['Templates'],
},
getPlansByPidRulesEvaluation: {
providesTags: ['EvaluationRules'],
},
},
});

Expand Down
25 changes: 24 additions & 1 deletion src/features/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@ const injectedRtkApi = api.injectEndpoints({
>({
query: (queryArg) => ({ url: `/plans/${queryArg.pid}/checkoutItem` }),
}),
getPlansByPidRulesEvaluation: build.query<
GetPlansByPidRulesEvaluationApiResponse,
GetPlansByPidRulesEvaluationApiArg
>({
query: (queryArg) => ({ url: `/plans/${queryArg.pid}/rules-evaluation` }),
}),
patchPlansByPidStatus: build.mutation<
PatchPlansByPidStatusApiResponse,
PatchPlansByPidStatusApiArg
Expand Down Expand Up @@ -1553,8 +1559,12 @@ export type GetPlansByPidApiResponse = /** status 200 OK */ {
config: {
modules: Module[];
};
from_template?: {
id: number;
title: string;
};
id: number;
is_frozen?: number;
price?: string;
project: {
id: number;
name: string;
Expand Down Expand Up @@ -1587,6 +1597,12 @@ export type GetPlansByPidCheckoutItemApiResponse = /** status 200 OK */ {
export type GetPlansByPidCheckoutItemApiArg = {
pid: string;
};
export type GetPlansByPidRulesEvaluationApiResponse = /** status 200 OK */ {
failed: PurchasablePlanRules[];
};
export type GetPlansByPidRulesEvaluationApiArg = {
pid: string;
};
export type PatchPlansByPidStatusApiResponse = /** status 200 OK */ {};
export type PatchPlansByPidStatusApiArg = {
pid: string;
Expand Down Expand Up @@ -2811,6 +2827,12 @@ export type Module =
| ModuleGasSupply
| ModuleAnnualIncomeRange;
export type PlanStatus = 'pending_review' | 'draft' | 'approved' | 'paying';
export type PurchasablePlanRules =
| 'number_of_modules'
| 'module_type'
| 'number_of_testers'
| 'number_of_tasks'
| 'task_type';
export type Project = {
campaigns_count: number;
description?: string;
Expand Down Expand Up @@ -2991,6 +3013,7 @@ export const {
useGetPlansByPidQuery,
usePatchPlansByPidMutation,
useGetPlansByPidCheckoutItemQuery,
useGetPlansByPidRulesEvaluationQuery,
usePatchPlansByPidStatusMutation,
usePostProjectsMutation,
useDeleteProjectsByPidMutation,
Expand Down
14 changes: 13 additions & 1 deletion src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,9 @@
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_1": "Our team will review your request;",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_2": "You'll receive confirmation or a quotation for the activity;",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_3": "First results will be available between 3-7 working days after launch;",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_FAILED_RULES": "Your customizations require our expert team to create a personalized quote for you.",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_TITLE": "Ready to submit your activity?",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_TITLE_FAILED_RULES": "Switching to expert-assisted service",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BUTTON_CANCEL": "Cancel",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BUTTON_CONFIRM": "Submit",
"__PLAN_PAGE_MODAL_SEND_REQUEST_DATES_DESCRIPTION": "Choose the start date when you'll be ready to begin the activity",
Expand Down Expand Up @@ -1117,6 +1119,16 @@
"__PLAN_PAGE_TAB_TARGET_TAB_TITLE": "Screen participants",
"__PLAN_PAGE_TITLE": "Plan your activity",
"__PLAN_REQUEST_QUOTATION_CTA": "Submit Request",
"__PLAN_RULE_MODULE_TYPE": "Custom features added",
"__PLAN_RULE_NUMBER_OF_MODULES": "Extra modules added",
"__PLAN_RULE_NUMBER_OF_TASKS": "Extra tasks added",
"__PLAN_RULE_NUMBER_OF_TESTERS": "Participants increased",
"__PLAN_RULE_TASK_TYPE": "Custom tasks added",
"__PLAN_RULES_CHANGED_LIST": "What changed",
"__PLAN_RULES_WHAT_MEANS": "What this means",
"__PLAN_RULES_WHAT_MEANS_DESCRIPTION_1": "2-day expert review",
"__PLAN_RULES_WHAT_MEANS_DESCRIPTION_2": "Custom quote via email",
"__PLAN_RULES_WHAT_MEANS_DESCRIPTION_3": "Personalised support",
"__PLAN_SAVE_CONFIGURATION_CTA": "Save Draft",
"__PLAN_SAVE_DRAFT_TOAST_ERROR": "We couldn't save your draft: please try again later.",
"__PLAN_SAVE_DRAFT_TOAST_SUCCESS": "Activity draft saved! You can safely continue editing.",
Expand Down Expand Up @@ -1408,8 +1420,8 @@
"SIGNUP_FORM_ROLE_IS_REQUIRED": "This field is required",
"SIGNUP_FORM_ROLE_LABEL": "Job title",
"SIGNUP_FORM_ROLE_PLACEHOLDER": "Select a Job role",
"SIGNUP_FORM_STEP_1_TITLE": "Create your free account",
"SIGNUP_FORM_STEP_1_DESCRIPTION": "Use our templates and launch activities in minutes with expert validation. Get real insights, commitment-free.",
"SIGNUP_FORM_STEP_1_TITLE": "Create your free account",
"SIGNUP_FORM_STEP_2_DESCRIPTION": "So we can tailor the experience to fit your role and needs.",
"SIGNUP_FORM_STEP_2_TITLE": "Tell us a bit about yourself",
"SIGNUP_FORM_STEP_3_DESCRIPTION": "Choose a name that represents your team — it’ll shape your personalized experience.",
Expand Down
13 changes: 13 additions & 0 deletions src/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,9 @@
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_1": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_2": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_3": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_DESCRIPTION_FAILED_RULES": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_TITLE": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BODY_TITLE_FAILED_RULES": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BUTTON_CANCEL": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_BUTTON_CONFIRM": "",
"__PLAN_PAGE_MODAL_SEND_REQUEST_DATES_DESCRIPTION": "",
Expand Down Expand Up @@ -1148,6 +1150,16 @@
"__PLAN_PAGE_TAB_TARGET_TAB_TITLE": "",
"__PLAN_PAGE_TITLE": "Pianifica la tua attività",
"__PLAN_REQUEST_QUOTATION_CTA": "",
"__PLAN_RULE_MODULE_TYPE": "",
"__PLAN_RULE_NUMBER_OF_MODULES": "",
"__PLAN_RULE_NUMBER_OF_TASKS": "",
"__PLAN_RULE_NUMBER_OF_TESTERS": "",
"__PLAN_RULE_TASK_TYPE": "",
"__PLAN_RULES_CHANGED_LIST": "",
"__PLAN_RULES_WHAT_MEANS": "",
"__PLAN_RULES_WHAT_MEANS_DESCRIPTION_1": "",
"__PLAN_RULES_WHAT_MEANS_DESCRIPTION_2": "",
"__PLAN_RULES_WHAT_MEANS_DESCRIPTION_3": "",
"__PLAN_SAVE_CONFIGURATION_CTA": "",
"__PLAN_SAVE_DRAFT_TOAST_ERROR": "",
"__PLAN_SAVE_DRAFT_TOAST_SUCCESS": "",
Expand Down Expand Up @@ -1449,6 +1461,7 @@
"SIGNUP_FORM_ROLE_IS_REQUIRED": "",
"SIGNUP_FORM_ROLE_LABEL": "",
"SIGNUP_FORM_ROLE_PLACEHOLDER": "",
"SIGNUP_FORM_STEP_1_DESCRIPTION": "",
"SIGNUP_FORM_STEP_1_TITLE": "",
"SIGNUP_FORM_STEP_2_DESCRIPTION": "",
"SIGNUP_FORM_STEP_2_TITLE": "",
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Plan/Controls/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useToast, Notification } from '@appquality/unguess-design-system';
import { Notification, useToast } from '@appquality/unguess-design-system';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
Expand Down Expand Up @@ -93,7 +93,10 @@ export const Controls = () => {
)}

{isRequestQuotationModalOpen && (
<SendRequestModal onQuit={() => setRequestQuotationModalOpen(false)} />
<SendRequestModal
isPurchasable={plan.isPurchasable}
onQuit={() => setRequestQuotationModalOpen(false)}
/>
)}
</div>
);
Expand Down
66 changes: 66 additions & 0 deletions src/pages/Plan/modals/PurchasablePlanRules.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { MD, UnorderedList } from '@appquality/unguess-design-system';
import { useTranslation } from 'react-i18next';
import { PurchasablePlanRules } from 'src/features/api';
import styled from 'styled-components';

const Wrapper = styled.div`
display: grid;
grid-template-columns: 1fr 1fr;
gap: ${({ theme }) => theme.space.md};
> div {
background-color: ${({ theme }) => theme.palette.grey[100]};
border-radius: 8px;
border: 1px solid ${({ theme }) => theme.palette.grey[200]};
padding: ${({ theme }) => theme.space.sm} ${({ theme }) => theme.space.md};
}
${MD} {
color: ${({ theme }) => theme.palette.teal[700]};
margin-bottom: ${({ theme }) => theme.space.xs};
}
`;

export const PurchasablePlanRulesGuide = ({
failedRules,
}: {
failedRules: PurchasablePlanRules[];
}) => {
const { t } = useTranslation();

const getRuleDescription = (rule: PurchasablePlanRules) => {
switch (rule) {
case 'number_of_modules':
return t('__PLAN_RULE_NUMBER_OF_MODULES');
case 'module_type':
return t('__PLAN_RULE_MODULE_TYPE');
case 'number_of_testers':
return t('__PLAN_RULE_NUMBER_OF_TESTERS');
case 'number_of_tasks':
return t('__PLAN_RULE_NUMBER_OF_TASKS');
case 'task_type':
return t('__PLAN_RULE_TASK_TYPE');
default:
return rule;
}
};

return (
<Wrapper data-qa="purchasable-plan-rules">
<div>
<MD isBold>{t('__PLAN_RULES_CHANGED_LIST')}</MD>
<UnorderedList>
{failedRules.map((rule) => (
<li key={rule}>{getRuleDescription(rule)}</li>
))}
</UnorderedList>
</div>
<div>
<MD isBold>{t('__PLAN_RULES_WHAT_MEANS')}</MD>
<UnorderedList>
<li>{t('__PLAN_RULES_WHAT_MEANS_DESCRIPTION_1')}</li>
<li>{t('__PLAN_RULES_WHAT_MEANS_DESCRIPTION_2')}</li>
<li>{t('__PLAN_RULES_WHAT_MEANS_DESCRIPTION_3')}</li>
</UnorderedList>
</div>
</Wrapper>
);
};
Loading
Loading