diff --git a/release.config.cjs b/release.config.cjs deleted file mode 100644 index ebd9ab95f3..0000000000 --- a/release.config.cjs +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @type {import('semantic-release').GlobalConfig} - */ - -module.exports = { - branches: ['main'], - plugins: [ - [ - '@semantic-release/commit-analyzer', - { - preset: 'angular', - releaseRules: [{ type: 'build', scope: 'deps', release: false }], - }, - ], - [ - '@semantic-release/release-notes-generator', - { - preset: 'angular', - writerOpts: { - transform: (commit, context) => { - if (commit.type === 'build' && commit.scope === 'deps') { - commit.type = 'Dependencies'; - } - return commit; - }, - groupBy: 'type', - commitGroupsSort: 'title', - commitsSort: ['scope', 'subject'], - noteGroupsSort: 'title', - notesSort: compareFunc, - }, - }, - ], - '@semantic-release/changelog', - [ - '@semantic-release/npm', - { - npmPublish: false, - }, - ], - [ - '@semantic-release/git', - { - assets: ['package.json', 'CHANGELOG.md'], - message: - 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}', - }, - ], - '@semantic-release/github', - ], -}; diff --git a/release.config.json b/release.config.json new file mode 100644 index 0000000000..c24cfcec5c --- /dev/null +++ b/release.config.json @@ -0,0 +1,22 @@ +{ + "branches": ["main"], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + [ + "@semantic-release/npm", + { + "npmPublish": false + } + ], + [ + "@semantic-release/git", + { + "assets": ["package.json", "CHANGELOG.md"], + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ], + "@semantic-release/github" + ] +} diff --git a/src/features/congregation/app_access/congregation_admin/useCongregationAdmin.tsx b/src/features/congregation/app_access/congregation_admin/useCongregationAdmin.tsx index a5dabf029c..16aea6a191 100644 --- a/src/features/congregation/app_access/congregation_admin/useCongregationAdmin.tsx +++ b/src/features/congregation/app_access/congregation_admin/useCongregationAdmin.tsx @@ -28,10 +28,6 @@ const useCongregationAdmin = (users: CongregationUserType[]) => { return t('tr_serviceOverseer'); } - if (roles.includes('field_service_group_overseer')) { - return t('tr_serviceGroupOverseerRole'); - } - if (roles.includes('midweek_schedule')) { return t('tr_midweekMeetingOverseer'); } @@ -52,7 +48,7 @@ const useCongregationAdmin = (users: CongregationUserType[]) => { user.profile.firstname.value, fullnameOption ), - person_role: getUserMainRole(user.profile.cong_role), + person_role: getUserMainRole(user.profile?.cong_role || []), }; }); }, [users, fullnameOption, getUserMainRole]); diff --git a/src/features/congregation/app_access/user_details/profile_settings/useProfileSettings.tsx b/src/features/congregation/app_access/user_details/profile_settings/useProfileSettings.tsx index 2798c83603..c20ddcac00 100644 --- a/src/features/congregation/app_access/user_details/profile_settings/useProfileSettings.tsx +++ b/src/features/congregation/app_access/user_details/profile_settings/useProfileSettings.tsx @@ -51,7 +51,7 @@ const useProfileSettings = () => { const newUser = structuredClone(user); newUser.profile.user_local_uid = value.person_uid; - const userRole = newUser.profile.cong_role; + const userRole = newUser.profile?.cong_role || []; const person = personsActive.find( (record) => record.person_uid === value.person_uid diff --git a/src/features/congregation/app_access/user_details/user_additional_rights/useUserAdditionalRights.tsx b/src/features/congregation/app_access/user_details/user_additional_rights/useUserAdditionalRights.tsx index 1f913b76b7..7ab43b5cd6 100644 --- a/src/features/congregation/app_access/user_details/user_additional_rights/useUserAdditionalRights.tsx +++ b/src/features/congregation/app_access/user_details/user_additional_rights/useUserAdditionalRights.tsx @@ -17,6 +17,8 @@ const useUserAdditionalRights = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('midweek_schedule'); } @@ -45,6 +47,8 @@ const useUserAdditionalRights = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('weekend_schedule'); } @@ -73,6 +77,8 @@ const useUserAdditionalRights = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('public_talk_schedule'); } @@ -101,6 +107,8 @@ const useUserAdditionalRights = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('attendance_tracking'); } @@ -124,18 +132,20 @@ const useUserAdditionalRights = () => { }; useEffect(() => { - const isMidweek = user.profile.cong_role.includes('midweek_schedule'); + const isMidweek = + user.profile.cong_role?.includes('midweek_schedule') ?? false; setIsMidweek(isMidweek); - const isWeekend = user.profile.cong_role.includes('weekend_schedule'); + const isWeekend = + user.profile.cong_role?.includes('weekend_schedule') ?? false; setIsWeekend(isWeekend); - const isPublicTalk = user.profile.cong_role.includes( - 'public_talk_schedule' - ); + const isPublicTalk = + user.profile.cong_role?.includes('public_talk_schedule') ?? false; setIsPublicTalk(isPublicTalk); - const isAttendance = user.profile.cong_role.includes('attendance_tracking'); + const isAttendance = + user.profile.cong_role?.includes('attendance_tracking') ?? false; setIsAttendance(isAttendance); }, [user]); diff --git a/src/features/congregation/app_access/user_details/user_main_roles/useUserMainRoles.tsx b/src/features/congregation/app_access/user_details/user_main_roles/useUserMainRoles.tsx index 800a6f5c8a..3d31e4943c 100644 --- a/src/features/congregation/app_access/user_details/user_main_roles/useUserMainRoles.tsx +++ b/src/features/congregation/app_access/user_details/user_main_roles/useUserMainRoles.tsx @@ -22,6 +22,8 @@ const useUserMainRoles = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('admin'); } @@ -51,6 +53,8 @@ const useUserMainRoles = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('coordinator'); } @@ -79,6 +83,8 @@ const useUserMainRoles = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('secretary'); } @@ -107,6 +113,8 @@ const useUserMainRoles = () => { const newUser = structuredClone(user); + newUser.profile.cong_role = newUser.profile.cong_role || []; + if (value) { newUser.profile.cong_role.push('service_overseer'); } @@ -130,16 +138,18 @@ const useUserMainRoles = () => { }; useEffect(() => { - const isCoordinator = user.profile.cong_role.includes('coordinator'); + const isCoordinator = + user.profile.cong_role?.includes('coordinator') ?? false; setIsCoordinator(isCoordinator); - const isSecretary = user.profile.cong_role.includes('secretary'); + const isSecretary = user.profile.cong_role?.includes('secretary') ?? false; setIsSecretary(isSecretary); - const isAdmin = user.profile.cong_role.includes('admin'); + const isAdmin = user.profile.cong_role.includes('admin') ?? false; setIsAdmin(isAdmin); - const isFieldOverseer = user.profile.cong_role.includes('service_overseer'); + const isFieldOverseer = + user.profile.cong_role?.includes('service_overseer') ?? false; setIsServiceOverseer(isFieldOverseer); }, [user]); diff --git a/src/features/whats_new/useWhatsNew.tsx b/src/features/whats_new/useWhatsNew.tsx index b6ee5c7e1b..228b504236 100644 --- a/src/features/whats_new/useWhatsNew.tsx +++ b/src/features/whats_new/useWhatsNew.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { SwiperRef } from 'swiper/react'; import { useRecoilValue } from 'recoil'; import { useAppTranslation } from '@hooks/index'; @@ -22,12 +22,25 @@ const useWhatsNew = () => { const [improvements, setImprovements] = useState([]); const [currentImage, setCurrentImage] = useState(0); + const releases = useMemo(() => { + return i18n.options.resources[appLang].releases as ReleaseNoteType; + }, [appLang, i18n]); + + const version = useMemo(() => { + const releasesDates = Object.keys(releases); + return releasesDates.sort().reverse().at(0); + }, [releases]); + const handleClose = () => { setOpen(false); if (!isDemo) { - const version = import.meta.env.PACKAGE_VERSION; - localStorage.setItem(STORAGE_KEY, JSON.stringify({ [version]: false })); + const saved = localStorage.getItem(STORAGE_KEY); + const lsVersion = (saved ? JSON.parse(saved) : {}) as UpdateStatusType; + + lsVersion[version] = false; + + localStorage.setItem(STORAGE_KEY, JSON.stringify(lsVersion)); } }; @@ -57,7 +70,6 @@ const useWhatsNew = () => { const checkReleaseNotes = () => { let showUpdate = true; - const version = import.meta.env.PACKAGE_VERSION; const tmp = localStorage.getItem(STORAGE_KEY); if (tmp) { @@ -68,9 +80,6 @@ const useWhatsNew = () => { } if (showUpdate) { - const releases = i18n.options.resources[appLang] - .releases as ReleaseNoteType; - const { improvements, images } = releases[version] || releases['next']; const formattedImprovements = Object.values(improvements); @@ -84,7 +93,7 @@ const useWhatsNew = () => { }; checkReleaseNotes(); - }, [appLang, i18n]); + }, [appLang, i18n, version, releases]); useEffect(() => { const loadImage = (src: string) =>