Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
46dd53c
cp-159: + survey navigation parameter and survey screen enum
BrianSammit Sep 19, 2023
3a88d5b
cp-159: + add pages with more steps to the survey
BrianSammit Sep 19, 2023
d9b25bc
cp-159: + fix bug of white background color in nested stack and fix p…
BrianSammit Sep 19, 2023
1f313f8
cp-159: + get the journaling step data and send it to the back-end
BrianSammit Sep 19, 2023
c9f40e5
cp-159: + get the feeling steps data and send it to the back-end
BrianSammit Sep 19, 2023
4fe01dd
cp-159: + get the goals steps data and send it to the back-end
BrianSammit Sep 19, 2023
1b29104
cp-159: + get the worries steps data and send it to the back-end
BrianSammit Sep 19, 2023
9224ce5
cp-159: + get the worries steps data and send it to the back-end
BrianSammit Sep 19, 2023
1c4e8d7
cp-159: + get the meditation steps data and send it to the back-end
BrianSammit Sep 19, 2023
3ac21bd
Merge branch 'development' into task/cp-159-add-more-steps-survey
iamAlinaaa Sep 20, 2023
6538027
cp-159: + add a component for reuse in screens and move the stack sur…
BrianSammit Sep 26, 2023
011cec8
cp-159: + redux slice to manage the state of the survey
BrianSammit Sep 26, 2023
8bc5bb9
cp-159: + the data receive from each step and update the slice
BrianSammit Sep 26, 2023
a7fb50c
cp-159: + collect the data from steps and send it
BrianSammit Sep 27, 2023
f94cc12
Merge branch 'task/cp-159-add-more-steps-survey' of https://github.co…
BrianSammit Sep 28, 2023
f686892
Merge branch 'development' of https://github.com/BinaryStudioAcademy/…
BrianSammit Sep 28, 2023
2c3c0b3
cp-159: + all steps to survey and fix styles
BrianSammit Sep 28, 2023
a502750
cp-159: * fix misspelling that generate bug sending data to back end
BrianSammit Sep 28, 2023
b872bfc
cp-159: + form for one option and and validation
BrianSammit Sep 29, 2023
3758042
cp-159: * merge conflicts
BrianSammit Sep 29, 2023
3e9d897
Merge branch 'development' into task/cp-159-add-more-steps-survey
BrianSammit Sep 29, 2023
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
5 changes: 5 additions & 0 deletions frontend/src/pages/surveys/survey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const Survey: React.FC = () => {
void dispatch(
authActions.createUserSurvey({
userId: userId,
journalingExperience: '',
feelings: [],
goals: [],
worries: [],
meditationExperience: '',
preferences: options,
}),
);
Expand Down
13 changes: 11 additions & 2 deletions mobile/src/libs/components/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'fast-text-encoding';

import { NavigationContainer } from '@react-navigation/native';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import React from 'react';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import SplashScreen from 'react-native-splash-screen';
Expand All @@ -14,6 +14,15 @@ import { Root as RootNavigation } from '#navigations/navigations';
import { SPLASH_SCREEN_HIDE_TIMEOUT } from './libs/constants/constants';
import { styles } from './styles';

// Prevent white background color on nested navigation stack
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: 'transparent',
},
};

const App: React.FC = () => {
useEffect(() => {
// To prevent white screen after splash screen disappears
Expand All @@ -29,7 +38,7 @@ const App: React.FC = () => {
return (
<StoreProvider store={store.instance}>
<GestureHandlerRootView style={styles.root}>
<NavigationContainer>
<NavigationContainer theme={theme}>
<RootNavigation />
</NavigationContainer>
<Toast />
Expand Down
1 change: 1 addition & 0 deletions mobile/src/libs/enums/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
MeditationScreenName,
ProfileScreenName,
RootScreenName,
SurveyScreenName,
} from './navigation/navigation';
export { AppColor, FontFamily } from './ui/ui';
export {
Expand Down
1 change: 1 addition & 0 deletions mobile/src/libs/enums/navigation/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { MainScreenName } from './main-screen-name.enum';
export { MeditationScreenName } from './meditation-screen-name.enum';
export { ProfileScreenName } from './profile-screen-name.enum';
export { RootScreenName } from './root-screen-name.enum';
export { SurveyScreenName } from './survey-screen-name.enum';
10 changes: 10 additions & 0 deletions mobile/src/libs/enums/navigation/survey-screen-name.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const SurveyScreenName = {
PREFERENCES: 'preferences',
FEELINGS: 'feelings',
GOALS: 'goals',
WORRIES: 'worries',
MEDITATION_EXPERIENCE: 'meditationExperience',
JOURNALING_EXPERIENCE: 'journalingExperience',
} as const;

export { SurveyScreenName };
3 changes: 3 additions & 0 deletions mobile/src/libs/packages/store/store.package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { reducer as authReducer } from '#slices/auth/auth';
import { reducer as chatsReducer } from '#slices/chats/chats';
import { reducer as journalReducer } from '#slices/journal/journal';
import { reducer as meditationReducer } from '#slices/meditation/meditation';
import { reducer as surveyReducer } from '#slices/survey/survey';

import { type Config } from '../config/config';
import { notification } from '../notification/notification';
Expand All @@ -26,6 +27,7 @@ type RootReducer = {
auth: ReturnType<typeof authReducer>;
journal: ReturnType<typeof journalReducer>;
chats: ReturnType<typeof chatsReducer>;
survey: ReturnType<typeof surveyReducer>;
meditation: ReturnType<typeof meditationReducer>;
};

Expand Down Expand Up @@ -56,6 +58,7 @@ class Store {
auth: authReducer,
journal: journalReducer,
chats: chatsReducer,
survey: surveyReducer,
meditation: meditationReducer,
},
middleware: (getDefaultMiddleware) => {
Expand Down
2 changes: 2 additions & 0 deletions mobile/src/libs/types/navigation/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export { type NavigationItem } from './navigation-item.type';
export { type NavigationScreenProperties } from './navigation-screen-properties.type';
export { type ProfileNavigationParameterList } from './profile-navigation-parameter-list.type';
export { type RootNavigationParameterList } from './root-navigation-parameter-list.type';
export { type SurveyNavigationItem } from './survey-navigation-item.type';
export { type SurveyNavigationParameterList } from './survey-navigation-parameter-list.type';
export { type TabNavigationParameterList } from './tab-navigation-parameter-list.type';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { type SurveyNavigationParameterList } from './survey-navigation-parameter-list.type';

type SurveyNavigationItem = {
name: keyof SurveyNavigationParameterList;
component: React.ComponentType;
};

export { type SurveyNavigationItem };
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { type SurveyScreenName } from '#libs/enums/enums';

type SurveyNavigationParameterList = {
[SurveyScreenName.PREFERENCES]: undefined | object;
[SurveyScreenName.FEELINGS]: undefined | object;
[SurveyScreenName.GOALS]: undefined | object;
[SurveyScreenName.WORRIES]: undefined | object;
[SurveyScreenName.MEDITATION_EXPERIENCE]: undefined | object;
[SurveyScreenName.JOURNALING_EXPERIENCE]: undefined | object;
Comment on lines +4 to +9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide more specific types

};

export { type SurveyNavigationParameterList };
2 changes: 2 additions & 0 deletions mobile/src/libs/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export {
type NavigationScreenProperties,
type ProfileNavigationParameterList,
type RootNavigationParameterList,
type SurveyNavigationItem,
type SurveyNavigationParameterList,
type TabNavigationParameterList,
} from './navigation/navigation';
export {
Expand Down
1 change: 1 addition & 0 deletions mobile/src/navigations/navigations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export { Chat } from './chat/chat';
export { Main } from './main/main';
export { Meditation } from './meditation/meditation';
export { Root } from './root/root';
export { Survey } from './survey/survey';
export { UserProfile } from './user-profile/user-profile';
3 changes: 1 addition & 2 deletions mobile/src/navigations/root/libs/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { RootScreenName } from '#libs/enums/enums';
import { type NavigationItem } from '#libs/types/types';
import { Main, UserProfile } from '#navigations/navigations';
import { Main, Survey, UserProfile } from '#navigations/navigations';
import { Auth } from '#screens/auth/auth';
import { Survey } from '#screens/survey/survey';

const NAVIGATION_ITEMS: NavigationItem[] = [
{
Expand Down
39 changes: 39 additions & 0 deletions mobile/src/navigations/survey/libs/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { SurveyScreenName } from '#libs/enums/enums';
import { type SurveyNavigationItem } from '#libs/types/types';
import {
FeelingsStep,
GoalsStep,
JournalingStep,
MeditationStep,
PreferencesStep,
WorriesStep,
} from '#screens/survey/components/components';

const SURVEY_NAVIGATION_ITEMS: SurveyNavigationItem[] = [
{
name: SurveyScreenName.PREFERENCES,
component: PreferencesStep,
},
{
name: SurveyScreenName.FEELINGS,
component: FeelingsStep,
},
{
name: SurveyScreenName.GOALS,
component: GoalsStep,
},
{
name: SurveyScreenName.WORRIES,
component: WorriesStep,
},
{
name: SurveyScreenName.MEDITATION_EXPERIENCE,
component: MeditationStep,
},
{
name: SurveyScreenName.JOURNALING_EXPERIENCE,
component: JournalingStep,
},
];

export { SURVEY_NAVIGATION_ITEMS };
44 changes: 44 additions & 0 deletions mobile/src/navigations/survey/survey.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
createNativeStackNavigator,
type NativeStackNavigationOptions,
} from '@react-navigation/native-stack';
import React from 'react';

import { SignBackground } from '#libs/components/components';
import { useAppDispatch, useEffect } from '#libs/hooks/hooks';
import { type SurveyNavigationParameterList } from '#libs/types/types';
import { actions as authActions } from '#slices/auth/auth';

import { SURVEY_NAVIGATION_ITEMS } from './libs/constants';

const NativeStack = createNativeStackNavigator<SurveyNavigationParameterList>();

const screenOptions: NativeStackNavigationOptions = {
headerShown: false,
};

const Survey: React.FC = () => {
const dispatch = useAppDispatch();

useEffect(() => {
void dispatch(authActions.getAuthenticatedUser());
}, [dispatch]);

return (
<SignBackground>
<NativeStack.Navigator screenOptions={screenOptions}>
{SURVEY_NAVIGATION_ITEMS.map((screen) => {
return (
<NativeStack.Screen
name={screen.name}
component={screen.component}
key={screen.name}
/>
);
})}
</NativeStack.Navigator>
</SignBackground>
);
};

export { Survey };
3 changes: 2 additions & 1 deletion mobile/src/packages/survey/libs/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export {
type SurveyGetAllItemResponseDto,
type SurveyInputDto,
type SurveyMultipleInputDto,
type SurveyOneInputDto,
type SurveyRequestDto,
} from 'shared/build/index.js';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { surveyInputValidationSchema } from 'shared/build/index.js';
export { surveyInputValidationSchemaMultiple } from 'shared/build/index.js';
5 changes: 3 additions & 2 deletions mobile/src/packages/survey/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export { PREFERENCES_OTHER_CATEGORY } from './libs/constants/constants';
export { getSurveyCategories } from './libs/helpers/helpers';
export {
type SurveyGetAllItemResponseDto,
type SurveyInputDto,
type SurveyMultipleInputDto,
type SurveyOneInputDto,
type SurveyRequestDto,
} from './libs/types/types';
export { surveyInputValidationSchema } from './libs/validation-shemas/validation-schemas';
export { surveyInputValidationSchemaMultiple } from './libs/validation-shemas/validation-schemas';
7 changes: 7 additions & 0 deletions mobile/src/screens/survey/components/components.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
export { FeelingsStep } from './feelings-step/feelings-step';
export { GoalsStep } from './goals-step/goals-step';
export { JournalingStep } from './journaling-step/journaling-step';
export { MeditationStep } from './meditation-step/meditation-step';
export { PreferencesStep } from './preferences-step/preferences-step';
export { SurveyCategory } from './survey-category/survey-category';
export { SurveyStepMultiple } from './survey-step/survey-step-multiple';
export { SurveyStepOne } from './survey-step/survey-step-one';
export { WorriesStep } from './worries-step/worries-step';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { type NavigationProp } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';
import React from 'react';

import { SurveyScreenName } from '#libs/enums/enums';
import { type SurveyNavigationParameterList } from '#libs/types/types';
import { FEELING_CATEGORIES } from '#screens/survey/libs/constants/constants';

import { SurveyStepMultiple } from '../components';

const FeelingsStep: React.FC = () => {
const navigation =
useNavigation<NavigationProp<SurveyNavigationParameterList>>();

return (
<SurveyStepMultiple
stepSurvey={SurveyScreenName.FEELINGS}
navigation={navigation}
stepTitle="How have you been feeling lately?"
categories={FEELING_CATEGORIES}
nextScreen={SurveyScreenName.GOALS}
previousScreen={SurveyScreenName.PREFERENCES}
/>
);
};

export { FeelingsStep };
27 changes: 27 additions & 0 deletions mobile/src/screens/survey/components/goals-step/goals-step.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { type NavigationProp } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';
import React from 'react';

import { SurveyScreenName } from '#libs/enums/enums';
import { type SurveyNavigationParameterList } from '#libs/types/types';
import { GOALS_CATEGORIES } from '#screens/survey/libs/constants/constants';

import { SurveyStepMultiple } from '../components';

const GoalsStep: React.FC = () => {
const navigation =
useNavigation<NavigationProp<SurveyNavigationParameterList>>();

return (
<SurveyStepMultiple
stepSurvey={SurveyScreenName.GOALS}
navigation={navigation}
stepTitle="What do you want to achieve with Calmpal?"
categories={GOALS_CATEGORIES}
nextScreen={SurveyScreenName.WORRIES}
previousScreen={SurveyScreenName.FEELINGS}
/>
);
};

export { GoalsStep };
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { type NavigationProp } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';
import React from 'react';

import { SurveyScreenName } from '#libs/enums/enums';
import { type SurveyNavigationParameterList } from '#libs/types/types';
import { JOURNALING_EXPERIENCE_CATEGORIES } from '#screens/survey/libs/constants/constants';

import { SurveyStepOne } from '../components';

const JournalingStep: React.FC = () => {
const navigation =
useNavigation<NavigationProp<SurveyNavigationParameterList>>();

return (
<SurveyStepOne
stepSurvey={SurveyScreenName.JOURNALING_EXPERIENCE}
navigation={navigation}
stepTitle="What's your experience with journaling?"
categories={JOURNALING_EXPERIENCE_CATEGORIES}
nextScreen={SurveyScreenName.JOURNALING_EXPERIENCE}
previousScreen={SurveyScreenName.MEDITATION_EXPERIENCE}
isLastStep
isOneOption
/>
);
};

export { JournalingStep };
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { type NavigationProp } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';
import React from 'react';

import { SurveyScreenName } from '#libs/enums/enums';
import { type SurveyNavigationParameterList } from '#libs/types/types';
import { MEDITATION_EXPERIENCE_CATEGORIES } from '#screens/survey/libs/constants/constants';

import { SurveyStepOne } from '../components';

const MeditationStep: React.FC = () => {
const navigation =
useNavigation<NavigationProp<SurveyNavigationParameterList>>();

return (
<SurveyStepOne
stepSurvey={SurveyScreenName.MEDITATION_EXPERIENCE}
navigation={navigation}
stepTitle="What's your experince with meditation?"
categories={MEDITATION_EXPERIENCE_CATEGORIES}
nextScreen={SurveyScreenName.JOURNALING_EXPERIENCE}
previousScreen={SurveyScreenName.WORRIES}
isOneOption
/>
);
};

export { MeditationStep };
Loading