diff --git a/src/App.jsx b/src/App.jsx
index 4da5841a4d..05ac72215f 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -54,307 +54,308 @@ const queryClient = new QueryClient();
// creating theme
const lightTheme = createTheme({
- palette: {
- mode: 'light',
- },
+ palette: {
+ mode: 'light',
+ },
});
const darkTheme = createTheme({
- palette: {
- mode: 'dark',
- },
+ palette: {
+ mode: 'dark',
+ },
});
const App = ({ updatePwa }) => {
- const setVisitorID = useSetRecoilState(visitorIDState);
- const setApiHost = useSetRecoilState(apiHostState);
+ const setVisitorID = useSetRecoilState(visitorIDState);
+ const setApiHost = useSetRecoilState(apiHostState);
- const isOnline = useRecoilValue(isOnlineState);
- const isLight = useRecoilValue(isLightThemeState);
- const appSnackOpen = useRecoilValue(appSnackOpenState);
- const isCongAccountConnected = useRecoilValue(congAccountConnectedState);
- const congRole = useRecoilValue(congRoleState);
+ const isOnline = useRecoilValue(isOnlineState);
+ const isLight = useRecoilValue(isLightThemeState);
+ const appSnackOpen = useRecoilValue(appSnackOpenState);
+ const isCongAccountConnected = useRecoilValue(congAccountConnectedState);
+ const congRole = useRecoilValue(congRoleState);
- const [activeTheme, setActiveTheme] = useState(darkTheme);
- const [isLoading, setIsLoading] = useState(true);
- const [isSupported, setIsSupported] = useState(true);
+ const [activeTheme, setActiveTheme] = useState(darkTheme);
+ const [isLoading, setIsLoading] = useState(true);
+ const [isSupported, setIsSupported] = useState(true);
- const secretaryRole = congRole.includes('secretary');
- const lmmoRole = congRole.includes('lmmo') || congRole.includes('lmmo-backup');
- const publicTalkCoordinatorRole = congRole.includes('public_talk_coordinator');
- const coordinatorRole = congRole.includes('coordinator');
- const adminRole = congRole.includes('admin');
- const elderRole =
- congRole.includes('elder') || secretaryRole || lmmoRole || coordinatorRole || publicTalkCoordinatorRole;
- const msRole = congRole.includes('ms');
- const publisherRole = congRole.includes('publisher') || msRole || elderRole;
+ const secretaryRole = congRole.includes('secretary');
+ const lmmoRole = congRole.includes('lmmo') || congRole.includes('lmmo-backup');
+ const publicTalkCoordinatorRole = congRole.includes('public_talk_coordinator');
+ const coordinatorRole = congRole.includes('coordinator');
+ const adminRole = congRole.includes('admin');
+ const elderRole =
+ congRole.includes('elder') || secretaryRole || lmmoRole || coordinatorRole || publicTalkCoordinatorRole;
+ const msRole = congRole.includes('ms');
+ const publisherRole = congRole.includes('publisher') || msRole || elderRole;
- const router = createHashRouter([
- {
- element: ,
- errorElement: ,
- children: [
- { path: '/', element: },
- {
- path: '/schedules/view/:weekToFormat',
- element: ,
- },
- {
- path: '/user-settings',
- element: ,
- },
- {
- element: ,
- children: [
- { path: '/user-field-service-reports', element: },
- { path: '/user-bible-studies', element: },
- ],
- },
- {
- element: ,
- children: [
- {
- path: '/persons',
- element: ,
- },
- {
- path: '/persons/:id',
- element: ,
- },
- {
- element: (
-
- ),
- children: [
- {
- path: '/persons/new',
- element: ,
- },
- {
- element: ,
- children: [
- {
- path: '/schedules',
- element: ,
- },
- {
- path: '/schedules/:schedule',
- element: ,
- },
- {
- path: '/schedules/:schedule/:weekToFormat',
- element: ,
- },
- {
- path: '/assignment-form',
- element: ,
- },
- ],
- },
- {
- element: (
-
- ),
- children: [
- {
- path: '/source-materials',
- element: ,
- },
- {
- path: '/source-materials/:weekToFormat',
- element: ,
- },
- ],
- },
- {
- element: ,
- children: [
- {
- path: '/field-service-group',
- element: ,
- },
- {
- path: '/meeting-attendance-record',
- element: ,
- },
- {
- path: '/field-service-report',
- element: ,
- },
- {
- path: '/branch-office-reports',
- element: ,
- },
- {
- path: '/pending-field-service-reports',
- element: ,
- },
- ],
- },
- {
- element: ,
- children: [
- {
- path: '/public-talks',
- element: ,
- },
- {
- path: '/visiting-speakers',
- element: ,
- },
- ],
- },
- {
- element: (
-
- ),
- children: [
- {
- path: '/weekend-schedules',
- element: ,
- },
- ],
- },
- ],
- },
- {
- path: '/congregation-settings',
- element: ,
- },
- {
- element: ,
- children: [
- {
- path: '/administration',
- element: ,
- },
- {
- path: '/administration/members/:id',
- element: ,
- },
- ],
- },
- ],
- },
- { path: '*', element: },
- ],
- },
- ]);
+ const router = createHashRouter([
+ {
+ element: ,
+ errorElement: ,
+ children: [
+ { path: '/', element: },
+ {
+ path: '/schedules/view/:weekToFormat',
+ element: ,
+ },
+ {
+ path: '/user-settings',
+ element: ,
+ },
+ {
+ element: ,
+ children: [
+ { path: '/user-field-service-reports', element: },
+ { path: '/user-bible-studies', element: },
+ ],
+ },
+ {
+ element: ,
+ children: [
+ {
+ path: '/persons',
+ element: ,
+ },
+ {
+ path: '/persons/:id',
+ element: ,
+ },
+ {
+ element: (
+
+ ),
+ children: [
+ {
+ path: '/persons/new',
+ element: ,
+ },
+ {
+ element: ,
+ children: [
+ {
+ path: '/schedules',
+ element: ,
+ },
+ {
+ path: '/schedules/:schedule',
+ element: ,
+ },
+ {
+ path: '/schedules/:schedule/:weekToFormat',
+ element: ,
+ },
+ {
+ path: '/assignment-form',
+ element: ,
+ },
+ ],
+ },
+ {
+ element: (
+
+ ),
+ children: [
+ {
+ path: '/source-materials',
+ element: ,
+ },
+ {
+ path: '/source-materials/:weekToFormat',
+ element: ,
+ },
+ ],
+ },
+ {
+ element: ,
+ children: [
+ {
+ path: '/field-service-group',
+ element: ,
+ },
+ {
+ path: '/meeting-attendance-record',
+ element: ,
+ },
+ {
+ path: '/field-service-report',
+ element: ,
+ },
+ {
+ path: '/branch-office-reports',
+ element: ,
+ },
+ {
+ path: '/pending-field-service-reports',
+ element: ,
+ },
+ ],
+ },
+ {
+ element: ,
+ children: [
+ {
+ path: '/public-talks',
+ element: ,
+ },
+ {
+ path: '/visiting-speakers',
+ element: ,
+ },
+ ],
+ },
+ {
+ element: (
+
+ ),
+ children: [
+ {
+ path: '/weekend-schedules',
+ element: ,
+ },
+ ],
+ },
+ ],
+ },
+ {
+ path: '/congregation-settings',
+ element: ,
+ },
+ {
+ element: ,
+ children: [
+ {
+ path: '/administration',
+ element: ,
+ },
+ {
+ path: '/administration/members/:id',
+ element: ,
+ },
+ ],
+ },
+ ],
+ },
+ { path: '*', element: },
+ ],
+ },
+ ]);
- useEffect(() => {
- if (isLight) {
- setActiveTheme(lightTheme);
- } else {
- setActiveTheme(darkTheme);
- }
- }, [isLight]);
+ useEffect(() => {
+ if (isLight) {
+ setActiveTheme(lightTheme);
+ } else {
+ setActiveTheme(darkTheme);
+ }
+ }, [isLight]);
- useEffect(() => {
- const getUserID = async () => {
- try {
- const fp = await FingerprintJS.load();
- const result = await fp.get();
+ useEffect(() => {
+ const getUserID = async () => {
+ try {
+ const fp = await FingerprintJS.load();
+ const result = await fp.get();
- const visitorId = result.visitorId;
- setVisitorID(visitorId);
- backupWorkerInstance.setVisitorID(visitorId);
+ const visitorId = result.visitorId;
+ setVisitorID(visitorId);
+ backupWorkerInstance.setVisitorID(visitorId);
- console.info('CPE: Fingerprint: Device visitor id has been set');
- } catch (error) {
- console.error(`CPE: Fingerprint: ${error}`);
- }
- };
+ console.info('CPE: Fingerprint: Device visitor id has been set');
+ } catch (error) {
+ console.error(`CPE: Fingerprint: ${error}`);
+ }
+ };
- if (isOnline) getUserID();
- }, [setVisitorID, isOnline]);
+ if (isOnline) getUserID();
+ }, [setVisitorID, isOnline]);
- useEffect(() => {
- let apiHost;
- if (import.meta.env.DEV || window.location.host.indexOf('localhost') !== -1) {
- if (import.meta.env.VITE_BACKEND_API) {
- apiHost = import.meta.env.VITE_BACKEND_API;
- } else {
- apiHost = 'http://localhost:8000/';
- }
- } else {
- apiHost = 'https://api.sws2apps.com/';
- }
+ useEffect(() => {
+ let apiHost;
- setApiHost(apiHost);
- backupWorkerInstance.setApiHost(apiHost);
+ if (import.meta.env.VITE_BACKEND_API) {
+ apiHost = import.meta.env.VITE_BACKEND_API;
+ } else {
+ if (import.meta.env.DEV || window.location.host.indexOf('localhost') !== -1) {
+ apiHost = 'http://localhost:8000/';
+ } else {
+ apiHost = 'https://api.sws2apps.com/';
+ }
+ }
- console.info(`CPE: API: The client API is set to: ${apiHost}`);
- }, [setApiHost]);
+ setApiHost(apiHost);
+ backupWorkerInstance.setApiHost(apiHost);
- useEffect(() => {
- const checkBrowser = () => {
- if (!('Worker' in window)) {
- setIsSupported(false);
- console.error(`CPE: Browser Not Supported: Web Worker is not supported in this device`);
- return;
- }
+ console.info(`CPE: API: The client API is set to: ${apiHost}`);
+ }, [setApiHost]);
- if (!('crypto' in window)) {
- setIsSupported(false);
- console.error(`CPE: Browser Not Supported: Web Crypto is not supported in this device`);
- return;
- }
+ useEffect(() => {
+ const checkBrowser = () => {
+ if (!('Worker' in window)) {
+ setIsSupported(false);
+ console.error(`CPE: Browser Not Supported: Web Worker is not supported in this device`);
+ return;
+ }
- if (!crypto.randomUUID || typeof crypto.randomUUID !== 'function') {
- setIsSupported(false);
- console.error(`CPE: Browser Not Supported: Web Crypto RandomUUID is not supported in this device`);
- return;
- }
+ if (!('crypto' in window)) {
+ setIsSupported(false);
+ console.error(`CPE: Browser Not Supported: Web Crypto is not supported in this device`);
+ return;
+ }
- if (!indexedDB) {
- setIsSupported(false);
- console.error(`CPE: Browser Not Supported: IndexedDb is not supported in this device`);
- return;
- }
+ if (!crypto.randomUUID || typeof crypto.randomUUID !== 'function') {
+ setIsSupported(false);
+ console.error(`CPE: Browser Not Supported: Web Crypto RandomUUID is not supported in this device`);
+ return;
+ }
- if (!('serviceWorker' in navigator)) {
- setIsSupported(false);
- console.error(`CPE: Browser Not Supported: Service Worker is not supported in this device`);
- }
- };
+ if (!indexedDB) {
+ setIsSupported(false);
+ console.error(`CPE: Browser Not Supported: IndexedDb is not supported in this device`);
+ return;
+ }
- checkBrowser();
- setIsLoading(false);
- }, []);
+ if (!('serviceWorker' in navigator)) {
+ setIsSupported(false);
+ console.error(`CPE: Browser Not Supported: Service Worker is not supported in this device`);
+ }
+ };
- if (isLoading) {
- return ;
- }
+ checkBrowser();
+ setIsLoading(false);
+ }, []);
- return (
- <>
- {!isSupported && (
-
- You are using unsupported browser for the Congregation Program for Everyone app. Make sure that your browser
- is up to date, or try to use another browser.
-
- )}
- {isSupported && (
-
-
-
-
- {appSnackOpen && }
- }>
-
-
-
-
- )}
- >
- );
+ if (isLoading) {
+ return ;
+ }
+
+ return (
+ <>
+ {!isSupported && (
+
+ You are using unsupported browser for the Congregation Program for Everyone app. Make sure that your browser
+ is up to date, or try to use another browser.
+
+ )}
+ {isSupported && (
+
+
+
+
+ {appSnackOpen && }
+ }>
+
+
+
+
+ )}
+ >
+ );
};
export default App;