Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: activity action plan (M2-7166) #535

Merged
merged 26 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
max_line_length = 100

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"buffer": "^6.0.3",
"date-fns": "^2.29.3",
"dayspan": "^1.1.0",
"html2canvas": "^1.4.1",
"i18next": "^22.0.6",
"i18next-browser-languagedetector": "^7.0.1",
"launchdarkly-react-client-sdk": "^3.1.0",
Expand Down
15 changes: 15 additions & 0 deletions src/abstract/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,19 @@ export const supportableResponseTypes = [
'multiSelectRows',
'singleSelectRows',
'sliderRows',
'phrasalTemplate',
];

export const phrasalTemplateCompatibleResponseTypes = [
'date',
'multiSelect',
'numberSelect',
'singleSelect',
'slider',
'text',
'time',
'timeRange',
'multiSelectRows',
'singleSelectRows',
'sliderRows',
];
5 changes: 5 additions & 0 deletions src/assets/download-icon-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/download-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/assets/mindlogger-action-plan-footer-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 50 additions & 2 deletions src/entities/activity/lib/types/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export type ActivityItemType =
| 'audio'
| 'audioPlayer'
| 'unsupportable'
| 'splashScreen';
| 'splashScreen'
| 'phrasalTemplate';

export type ButtonsConfig = {
removeBackButton: boolean;
Expand Down Expand Up @@ -97,10 +98,57 @@ export type ResponseValues =
| SelectorValues
| AudioPlayerItemValues
| MultiSelectionRowsItemResponseValues
| SliderRowsItemResponseValues;
| SliderRowsItemResponseValues
| PhrasalTemplateValues;

export type EmptyResponseValues = null;

export interface PhrasalTemplateItem extends ActivityItemBase {
responseType: 'phrasalTemplate';
config: never;
responseValues: PhrasalTemplateValues;
answer: DefaultAnswer;
}

export type PhrasalTemplateValues = {
cardTitle: string;
phrases: PhrasalTemplatePhrase[];
};

export type PhrasalTemplatePhrase = {
fields: PhrasalTemplateField[];
image: string | null;
};

export type PhrasalTemplateField =
| PhrasalTemplateSentenceField
| PhrasalTemplateItemResponseField
| PhrasalTemplateLineBreakField;

export type PhrasalTemplateSentenceField = {
type: 'sentence';
text: string;
};

export type PhrasalTemplateItemResponseField = {
type: 'item_response';
itemIndex: number;
itemName: string;
displayMode: PhrasalTemplateItemResponseFieldDisplayMode;
};

export type PhrasalTemplateLineBreakField = {
type: 'line_break';
};

export type PhrasalTemplateItemResponseFieldDisplayMode =
| 'sentence'
| 'sentence_option_row'
| 'sentence_row_option'
| 'bullet_list'
| 'bullet_list_option_row'
| 'bullet_list_text_row';

export interface TextItem extends ActivityItemBase {
responseType: 'text';
config: TextItemConfig;
Expand Down
6 changes: 6 additions & 0 deletions src/entities/activity/lib/useActionPlanTranslation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useCustomTranslation } from '~/shared/utils';

export const useActionPlanTranslation = () => {
const { t, i18n } = useCustomTranslation({ keyPrefix: 'ActionPlan' });
return { t, i18n };
};
6 changes: 6 additions & 0 deletions src/entities/activity/lib/usePhrasalTemplateTranslation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useCustomTranslation } from '~/shared/utils';

export const usePhrasalTemplateTranslation = () => {
const { t, i18n } = useCustomTranslation({ keyPrefix: 'PhrasalTemplate' });
return { t, i18n };
};
2 changes: 1 addition & 1 deletion src/entities/activity/ui/ActivityCardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ActivityCardItem = ({
return (
<SliderAnimation step={step} prevStep={prevStep ?? step}>
<CardItem
markdown={questionText}
markdown={item.responseType === 'phrasalTemplate' ? null : questionText}
watermark={watermark}
isOptional={!isOptionalFlagHidden && (item.config.skippableItem || allowToSkipAllItems)}
testId="active-item"
Expand Down
15 changes: 15 additions & 0 deletions src/entities/activity/ui/items/ActionPlan/Body.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PropsWithChildren } from 'react';

import { useXScaledDimension } from './hooks';

import Box from '~/shared/ui/Box';

export const Body = ({ children }: PropsWithChildren) => {
const gap = useXScaledDimension(32);

return (
<Box display="flex" flexDirection="column" gap={`${gap}px`} overflow="hidden">
qiushihe marked this conversation as resolved.
Show resolved Hide resolved
{children}
</Box>
);
};
Loading
Loading