diff --git a/CHANGELOG.md b/CHANGELOG.md index a01209884..49e49a6aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ ## [1.141.2](https://github.com/SocialGouv/1000jours/compare/v1.141.1...v1.141.2) (2024-07-08) - ### Bug Fixes -* change type whatsapp_redirect_message to richtext ([#1755](https://github.com/SocialGouv/1000jours/issues/1755)) ([1094147](https://github.com/SocialGouv/1000jours/commit/1094147f4c8042e28e013f6c9f8b41be18bc7134)) +- change type whatsapp_redirect_message to richtext ([#1755](https://github.com/SocialGouv/1000jours/issues/1755)) ([1094147](https://github.com/SocialGouv/1000jours/commit/1094147f4c8042e28e013f6c9f8b41be18bc7134)) ## [1.141.1](https://github.com/SocialGouv/1000jours/compare/v1.141.0...v1.141.1) (2024-07-03) diff --git a/front/app.config.js b/front/app.config.js index f8c3721f2..de4393766 100644 --- a/front/app.config.js +++ b/front/app.config.js @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ -const APP_VERSION = "1.1.106"; -const APP_VERSION_NUM = 106; +const APP_VERSION = "1.1.107"; +const APP_VERSION_NUM = 107; export default { expo: { diff --git a/front/src/components/baseComponents/loader.component.tsx b/front/src/components/baseComponents/loader.component.tsx index b679cb6db..e25b90aad 100644 --- a/front/src/components/baseComponents/loader.component.tsx +++ b/front/src/components/baseComponents/loader.component.tsx @@ -15,11 +15,11 @@ const Loader: React.FC = ({ backdrop = true }) => { presentationStyle="overFullScreen" transparent={true} > - + {/* */} - + {/* */} ) : ( diff --git a/front/src/screens/onboardingAndProfile/profile.component.tsx b/front/src/screens/onboardingAndProfile/profile.component.tsx index ddceb928f..64d851353 100644 --- a/front/src/screens/onboardingAndProfile/profile.component.tsx +++ b/front/src/screens/onboardingAndProfile/profile.component.tsx @@ -21,6 +21,7 @@ import { CommonText, CustomButton, Datepicker, + GraphQLLoader, Icomoon, IcomoonIcons, SecondaryText, @@ -28,6 +29,8 @@ import { } from "../../components/baseComponents"; import TrackerHandler from "../../components/tracker/trackerHandler.component"; import { + CalendarDbQueries, + FetchPoliciesConstants, Formats, Labels, PlatformConstants, @@ -36,6 +39,7 @@ import { import { USER_SITUATIONS } from "../../constants/profile.constants"; import { Colors, FontWeight, Margins, Paddings, Sizes } from "../../styles"; import type { + Event, ProfileGender, RootStackParamList, UserContext, @@ -48,8 +52,11 @@ import { TndNotificationUtils, TrackerUtils, } from "../../utils"; -import { NotificationType } from "../../utils/notifications/notification.util"; +import { NotificationType, cancelScheduleEventsNotification, getAllNotificationsByType, scheduleEventsNotification } from "../../utils/notifications/notification.util"; import { checkErrorOnProfile } from "../../utils/step/step.util"; +import { useEvents } from "../../hooks"; +import { gql, useLazyQuery, useQuery } from "@apollo/client"; +import { formattedEvents } from "../../utils/events/event.util"; interface Props { navigation: StackNavigationProp; @@ -109,6 +116,23 @@ const Profile: FC = ({ navigation }) => { setGender(genderStored ?? genderEmpty); }; + const [fetchEvents, { loading, error, data, called, refetch }] = useLazyQuery( + gql(CalendarDbQueries.ALL_EVENTS), + { + fetchPolicy: FetchPoliciesConstants.CACHE_AND_NETWORK, + onCompleted: async (data) => { + const evenements = (data as { evenements: Event[] }).evenements; + const events = formattedEvents(evenements, childBirthday); + await cancelScheduleEventsNotification(); + await scheduleEventsNotification(events); + navigateToRoot(); + }, + onError: (e: any) => { + console.warn(e); + }, + } + ); + useEffect(() => { const initDataWithStorageValue = async () => { const userSituationsStored = (await StorageUtils.getObjectValue( @@ -192,9 +216,10 @@ const Profile: FC = ({ navigation }) => { const validateForm = useCallback(async () => { const checkedUserSituation = StepUtils.getCheckedUserSituationOrUndefined(userSituations); - const error = checkErrorOnProfile(checkedUserSituation, childBirthday); - if (error) { - Alert.alert(Labels.warning, error, [{ text: "OK" }]); + const errorOnProfile = checkErrorOnProfile(checkedUserSituation, childBirthday); + + if (errorOnProfile) { + Alert.alert(Labels.warning, errorOnProfile, [{ text: "OK" }]); return; } @@ -235,7 +260,6 @@ const Profile: FC = ({ navigation }) => { const notifs = await NotificationUtils.getAllNotificationsByType( NotificationType.tnd ); - console.log(notifs); const isFirstTime = notifs.length === 0; void TndNotificationUtils.scheduleTndNotifications( childBirthday, @@ -249,7 +273,12 @@ const Profile: FC = ({ navigation }) => { // Annule la notification 'NextStep' et supprime les données concernant l'étape courante await resetNextStep(); - navigateToRoot(); + if(checkedUserSituation?.childBirthdayRequired && childBirthday) { + await fetchEvents(); + } else { + await cancelScheduleEventsNotification(); + navigateToRoot(); + } }, [childBirthday, navigateToRoot, userSituations, gender]); const scrollViewRef = React.useRef(null); @@ -293,161 +322,167 @@ const Profile: FC = ({ navigation }) => { }; return ( - - - - - - - - - - - - - {Labels.profile.title} - - - {Labels.profile.subTitle} - - - {userSituations.map((situation, index) => ( - - - - {situation.label} - - - - {situation.isChecked && - situation.childBirthdayRequired && - datePickerIsReady && ( - - - {situation.childBirthdayLabel} - - - 0 - ? new Date(childBirthday) - : undefined - } - onChange={onUpdatedDate} - color={Colors.primaryYellow} - /> - - - )} - - - ))} - - - - {`${Labels.profile.gender.select} :`} + <> + {loading ? + : null + } + + + + + + + + + + + + + + {Labels.profile.title} + + + {Labels.profile.subTitle} - - {genders.map((item, index) => ( - + + {userSituations.map((situation, index) => ( + - - {item.label} - + {situation.label} + + + {situation.isChecked && + situation.childBirthdayRequired && + datePickerIsReady && ( + + + {situation.childBirthdayLabel} + + + 0 + ? new Date(childBirthday) + : undefined + } + onChange={onUpdatedDate} + color={Colors.primaryYellow} + /> + + + )} + ))} - - - - - - } - action={onCloseButtonPressed} - /> - - - + + + {`${Labels.profile.gender.select} :`} + + + {genders.map((item, index) => ( + + + + {item.label} + + + + ))} + + + + + + + } + action={onCloseButtonPressed} + /> + + + + - - - + + + ); };