From 546f3e685f1c45271e9a8f8e263db0c57f6e29b1 Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Thu, 23 Nov 2023 13:54:36 +0200 Subject: [PATCH 01/14] added svg to danger zone --- apps/mobile/app/components/svgs/icons.tsx | 11 +++++++++++ .../Authenticated/SettingScreen/Team/QuitTeam.tsx | 8 +++++--- .../Authenticated/SettingScreen/Team/RemoveTeam.tsx | 8 +++++--- .../SettingScreen/components/UserRemoveAccount.tsx | 8 +++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apps/mobile/app/components/svgs/icons.tsx b/apps/mobile/app/components/svgs/icons.tsx index 5f6841602..23726c97c 100644 --- a/apps/mobile/app/components/svgs/icons.tsx +++ b/apps/mobile/app/components/svgs/icons.tsx @@ -981,3 +981,14 @@ export const moreButtonDark = ` `; + +// Settings Screen Icons // + +export const danGerZoneRemoveUserIcon = ` + + + + + + +`; diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/Team/QuitTeam.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/Team/QuitTeam.tsx index bea60c733..ae48c404a 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/Team/QuitTeam.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/Team/QuitTeam.tsx @@ -1,12 +1,14 @@ /* eslint-disable react-native/no-inline-styles */ /* eslint-disable react-native/no-color-literals */ import React from 'react'; -import { View, Text, Image, TouchableOpacity, StyleSheet, TouchableWithoutFeedback } from 'react-native'; +import { View, Text, TouchableOpacity, StyleSheet, TouchableWithoutFeedback } from 'react-native'; import { useOrganizationTeam } from '../../../../services/hooks/useOrganization'; import { translate } from '../../../../i18n'; import { typography, useAppTheme } from '../../../../theme'; import { observer } from 'mobx-react-lite'; import useAuthenticateUser from '../../../../services/hooks/features/useAuthentificateUser'; +import { SvgXml } from 'react-native-svg'; +import { danGerZoneRemoveUserIcon } from '../../../../components/svgs/icons'; const QuitTheTeam = observer(({ onDismiss }: { onDismiss: () => unknown }) => { const { colors, dark } = useAppTheme(); @@ -23,8 +25,8 @@ const QuitTheTeam = observer(({ onDismiss }: { onDismiss: () => unknown }) => { onDismiss()}> - - + + diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/Team/RemoveTeam.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/Team/RemoveTeam.tsx index 77774601a..551b46e33 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/Team/RemoveTeam.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/Team/RemoveTeam.tsx @@ -1,12 +1,14 @@ /* eslint-disable react-native/no-color-literals */ /* eslint-disable react-native/no-inline-styles */ import React from 'react'; -import { View, Text, Image, TouchableOpacity, StyleSheet, TouchableWithoutFeedback } from 'react-native'; +import { View, Text, TouchableOpacity, StyleSheet, TouchableWithoutFeedback } from 'react-native'; import { useOrganizationTeam } from '../../../../services/hooks/useOrganization'; import { translate } from '../../../../i18n'; import { typography, useAppTheme } from '../../../../theme'; import { useStores } from '../../../../models'; import { observer } from 'mobx-react-lite'; +import { SvgXml } from 'react-native-svg'; +import { danGerZoneRemoveUserIcon } from '../../../../components/svgs/icons'; const RemoveTeam = observer(({ onDismiss }: { onDismiss: () => unknown }) => { const { colors, dark } = useAppTheme(); @@ -29,8 +31,8 @@ const RemoveTeam = observer(({ onDismiss }: { onDismiss: () => unknown }) => { onDismiss()}> - - + + diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/components/UserRemoveAccount.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/components/UserRemoveAccount.tsx index 4b34ed9cd..a2f438888 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/components/UserRemoveAccount.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/components/UserRemoveAccount.tsx @@ -1,11 +1,13 @@ /* eslint-disable react-native/no-color-literals */ /* eslint-disable react-native/no-inline-styles */ import React, { useCallback } from 'react'; -import { Image, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native'; +import { StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native'; import { translate } from '../../../../i18n'; import { useUser } from '../../../../services/hooks/features/useUser'; import { useOrganizationTeam } from '../../../../services/hooks/useOrganization'; import { typography, useAppTheme } from '../../../../theme'; +import { SvgXml } from 'react-native-svg'; +import { danGerZoneRemoveUserIcon } from '../../../../components/svgs/icons'; const UserRemoveAccount = ({ onDismiss, @@ -36,8 +38,8 @@ const UserRemoveAccount = ({ onDismiss()}> - - + + From 21713d142453e84f01cc0191f7b1af9a61aa47cb Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Thu, 23 Nov 2023 14:27:35 +0200 Subject: [PATCH 02/14] added filter and gallery icons as svg --- apps/mobile/app/components/svgs/icons.tsx | 34 +++++++++++++++++++ .../ProfileScreen/components/TaskFilter.tsx | 10 +++--- .../components/ChangeTeamLogo.tsx | 8 ++--- .../components/ChangeUserAvatar.tsx | 8 ++--- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/apps/mobile/app/components/svgs/icons.tsx b/apps/mobile/app/components/svgs/icons.tsx index 23726c97c..453537650 100644 --- a/apps/mobile/app/components/svgs/icons.tsx +++ b/apps/mobile/app/components/svgs/icons.tsx @@ -650,6 +650,28 @@ export const pauseStatusIconLarge = ` `; +// Profile Screen // + +export const filterLightIcon = ` + + + + + + + +`; + +export const filterDarkIcon = ` + + + + + + + +`; + // Task Screen // // Task Title export const tickIconLight = ` `; + +export const galleryLightIcon = ` + + + +`; + +export const galleryDarkIcon = ` + + + +`; diff --git a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskFilter.tsx b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskFilter.tsx index 6d383f85d..92e10947a 100644 --- a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskFilter.tsx +++ b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskFilter.tsx @@ -1,5 +1,5 @@ /* eslint-disable react-native/no-inline-styles */ -import { Text, TouchableOpacity, Image, View, TextStyle, ViewStyle, Dimensions } from 'react-native'; +import { Text, TouchableOpacity, View, TextStyle, ViewStyle, Dimensions } from 'react-native'; import React, { useState } from 'react'; import { typography, useAppTheme } from '../../../../theme'; import { translate } from '../../../../i18n'; @@ -8,6 +8,8 @@ import ProfileTabs from './ProfileTabs'; import AssignTaskFormModal from './AssignTaskSection'; import FilterPopup from './FilterPopup'; import { ITaskFilter } from '../../../../services/hooks/features/useTaskFilters'; +import { SvgXml } from 'react-native-svg'; +import { filterDarkIcon, filterLightIcon } from '../../../../components/svgs/icons'; const TaskFilter = ({ profile, hook }: { profile: IUserProfile; hook: ITaskFilter }) => { const { colors, dark } = useAppTheme(); @@ -47,11 +49,7 @@ const TaskFilter = ({ profile, hook }: { profile: IUserProfile; hook: ITaskFilte style={{ ...$filterButton, borderColor: colors.border }} onPress={() => setShowFilterPopup(true)} > - {dark ? ( - - ) : ( - - )} + {dark ? : } {translate('tasksScreen.filter')} diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeTeamLogo.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeTeamLogo.tsx index 89202877b..2bb5e8be6 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeTeamLogo.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeTeamLogo.tsx @@ -25,6 +25,8 @@ import { useOrganizationTeam } from '../../../../services/hooks/useOrganization' import { useStores } from '../../../../models'; import { observer } from 'mobx-react-lite'; import LoadingModal from '../../../../components/LoadingModal'; +import { SvgXml } from 'react-native-svg'; +import { galleryDarkIcon, galleryLightIcon } from '../../../../components/svgs/icons'; const ChangeTeamLogo = observer(({ onDismiss, onExtend }: { onDismiss: () => unknown; onExtend: () => unknown }) => { const { colors, dark } = useAppTheme(); @@ -109,9 +111,7 @@ const ChangeTeamLogo = observer(({ onDismiss, onExtend }: { onDismiss: () => unk setSelectedImage(null); }, [onDismiss]); - const image = dark - ? require('../../../../../assets/images/new/image-dark.png') - : require('../../../../../assets/images/new/image-light.png'); + const galleryImage = dark ? : ; return ( <> @@ -132,7 +132,7 @@ const ChangeTeamLogo = observer(({ onDismiss, onExtend }: { onDismiss: () => unk pickImageFromGalery()}> - + {galleryImage} {translate('settingScreen.changeAvatar.selectFromGalery')} diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeUserAvatar.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeUserAvatar.tsx index 95ad33707..a16992a10 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeUserAvatar.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/components/ChangeUserAvatar.tsx @@ -26,6 +26,8 @@ import mime from 'mime'; import LoadingModal from '../../../../components/LoadingModal'; import useAuthenticateUser from '../../../../services/hooks/features/useAuthentificateUser'; import { IUser } from '../../../../services/interfaces/IUserData'; +import { SvgXml } from 'react-native-svg'; +import { galleryDarkIcon, galleryLightIcon } from '../../../../components/svgs/icons'; interface IFileInfo { size: number; @@ -137,9 +139,7 @@ const ChangeUserAvatar = ({ onDismiss, onExtend }: { onDismiss: () => unknown; o setSelectedImage(null); }, [onDismiss]); - const image = dark - ? require('../../../../../assets/images/new/image-dark.png') - : require('../../../../../assets/images/new/image-light.png'); + const galleryImage = dark ? : ; return ( <> @@ -160,7 +160,7 @@ const ChangeUserAvatar = ({ onDismiss, onExtend }: { onDismiss: () => unknown; o pickImageFromGalery()}> - + {galleryImage} {translate('settingScreen.changeAvatar.selectFromGalery')} From f87f402fb043c51000304a65d29c3ae36da26369 Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Thu, 23 Nov 2023 16:07:34 +0200 Subject: [PATCH 03/14] adjusted font sizes according to the screen width, and aligned titles with issue type icon --- .../ProfileScreen/components/ListCardItem.tsx | 10 ++++++++-- .../ProfileScreen/components/TaskTitleDisplay.tsx | 15 ++++++++++----- .../TeamScreen/components/TaskInfo.tsx | 12 +++++++----- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx index 446b8a2a2..1a64862f0 100644 --- a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx +++ b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx @@ -110,8 +110,14 @@ export const ListItemContent: React.FC = observer((props) => { - navigateToTask(props.task?.id)}> - + navigateToTask(props.task?.id)} style={{ width: '80%' }}> + diff --git a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskTitleDisplay.tsx b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskTitleDisplay.tsx index 1d71109b6..f3413ac74 100644 --- a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskTitleDisplay.tsx +++ b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskTitleDisplay.tsx @@ -1,7 +1,7 @@ /* eslint-disable react-native/no-inline-styles */ /* eslint-disable react-native/no-color-literals */ import React, { FC, useState } from 'react'; -import { View, StyleSheet, Text, TextInput, TouchableOpacity, ActivityIndicator } from 'react-native'; +import { View, StyleSheet, Text, TextInput, TouchableOpacity, ActivityIndicator, Dimensions } from 'react-native'; import { limitTextCharaters } from '../../../../helpers/sub-text'; import { ITeamTask } from '../../../../services/interfaces/ITask'; import { typography, useAppTheme } from '../../../../theme'; @@ -15,6 +15,8 @@ interface Props { navigateToTask: (taskId: string) => void; } +const { width: screenWidth } = Dimensions.get('screen'); + const TaskTitleDisplay: FC = ({ editMode, setEditMode, task, navigateToTask }) => { const { colors } = useAppTheme(); const { updateTask } = useTeamTasks(); @@ -65,7 +67,11 @@ const TaskTitleDisplay: FC = ({ editMode, setEditMode, task, navigateToTa #{task.number} - + {limitTextCharaters({ text: task.title, numChars: 43 @@ -78,7 +84,7 @@ const TaskTitleDisplay: FC = ({ editMode, setEditMode, task, navigateToTa }; const styles = StyleSheet.create({ - container: {}, + container: { width: '90%' }, titleContainer: { flexDirection: 'row', width: '100%' @@ -93,8 +99,7 @@ const styles = StyleSheet.create({ totalTimeTitle: { color: '#7E7991', fontFamily: typography.secondary.medium, - fontSize: 14, - maxWidth: '78%' + fontSize: screenWidth * 0.0327 }, wrapTitleInput: { alignItems: 'center', diff --git a/apps/mobile/app/screens/Authenticated/TeamScreen/components/TaskInfo.tsx b/apps/mobile/app/screens/Authenticated/TeamScreen/components/TaskInfo.tsx index cac6b7229..668cd282c 100644 --- a/apps/mobile/app/screens/Authenticated/TeamScreen/components/TaskInfo.tsx +++ b/apps/mobile/app/screens/Authenticated/TeamScreen/components/TaskInfo.tsx @@ -2,7 +2,7 @@ /* eslint-disable react-native/no-inline-styles */ /* eslint-disable react-native/no-color-literals */ import React, { useCallback, useState } from 'react'; -import { ActivityIndicator, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'; +import { ActivityIndicator, StyleSheet, Text, TextInput, TouchableOpacity, View, Dimensions } from 'react-native'; import { limitTextCharaters } from '../../../../helpers/sub-text'; import { typography, useAppTheme } from '../../../../theme'; import { useTeamTasks } from '../../../../services/hooks/features/useTeamTasks'; @@ -10,6 +10,7 @@ import { I_TeamMemberCardHook } from '../../../../services/hooks/features/useTea import { Feather } from '@expo/vector-icons'; import IssuesModal from '../../../../components/IssuesModal'; +const { width: screenWidth } = Dimensions.get('screen'); const TaskInfo = ({ memberInfo, editMode, @@ -65,12 +66,12 @@ const TaskInfo = ({ return ( setEditMode(true)} onPress={onPressIn}> - + {task ? ( - + #{task?.taskNumber}{' '} {limitTextCharaters({ text: task.title, @@ -87,20 +88,21 @@ export default TaskInfo; const styles = StyleSheet.create({ inputTitle: { + fontSize: screenWidth * 0.0327, minHeight: 30, width: '80%' }, otherText: { color: '#282048', fontFamily: typography.fonts.PlusJakartaSans.semiBold, - fontSize: 14, + fontSize: screenWidth * 0.0327, fontStyle: 'normal', width: '95%' }, taskNumberStyle: { color: '#7B8089', fontFamily: typography.primary.semiBold, - fontSize: 14 + fontSize: screenWidth * 0.0327 }, wrapBugIcon: { alignItems: 'center', From 1e11e04b092f55c4ffa0f23007f628e6d922034f Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Thu, 23 Nov 2023 16:35:43 +0200 Subject: [PATCH 04/14] added correct labels to filter modals --- .../ProfileScreen/components/TaskLabelFilter.tsx | 9 +++++++-- .../ProfileScreen/components/TaskPriorityFilter.tsx | 9 +++++++-- .../ProfileScreen/components/TaskSizeFilter.tsx | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskLabelFilter.tsx b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskLabelFilter.tsx index eb6ba5c96..21120cda0 100644 --- a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskLabelFilter.tsx +++ b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/TaskLabelFilter.tsx @@ -24,6 +24,7 @@ import { useTaskLabels } from '../../../../services/hooks/features/useTaskLabels import { ITaskLabelItem } from '../../../../services/interfaces/ITaskLabel'; import { StatusType } from './FilterPopup'; import { BlurView } from 'expo-blur'; +import { translate } from '../../../../i18n'; interface TaskLabelFilterProps { showLabelPopup: boolean; @@ -48,7 +49,9 @@ const TaskStatusFilter: FC = observer( setShowLabelPopup(!showLabelPopup)}> - Labels + + {translate('settingScreen.labelScreen.labels')} + {selectedLabels.length === 0 ? null : ( )} @@ -92,7 +95,9 @@ const TaskStatusFilterDropDown: FC = observer( ]} > - Statuses + + {translate('settingScreen.labelScreen.labels')} + = observer( setShowPriorityPopup(!showPriorityPopup)}> - Priorities + + {translate('settingScreen.priorityScreen.priorities')} + {selectedPriorities.length === 0 ? null : ( )} @@ -93,7 +96,9 @@ const TaskStatusFilterDropDown: FC = observer( ]} > - Statuses + + {translate('settingScreen.priorityScreen.priorities')} + = observer( setShowSizePopup(!showSizePopup)}> - Sizes + + {translate('settingScreen.sizeScreen.sizes')} + {selectedSizes.length === 0 ? null : ( )} @@ -92,7 +95,9 @@ const TaskStatusFilterDropDown: FC = observer( ]} > - Statuses + + {translate('settingScreen.sizeScreen.sizes')} + Date: Thu, 23 Nov 2023 17:45:43 +0200 Subject: [PATCH 05/14] conditionally rendering options icon in team member cards --- .../Authenticated/TeamScreen/components/ListCardItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx b/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx index fd11307d5..74a11c19d 100644 --- a/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx +++ b/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx @@ -298,7 +298,7 @@ const ListCardItem: React.FC = observer((props) => { > - ) : ( + ) : memberInfo.isAuthTeamManager || memberInfo.isAuthUser ? ( props.setOpenMenuIndex(props.openMenuIndex === props.index ? null : props.index) @@ -310,7 +310,7 @@ const ListCardItem: React.FC = observer((props) => { )} - )} + ) : null} } From 1b3360dd5a1788acf8e4c0ccb705d06ad9deed26 Mon Sep 17 00:00:00 2001 From: Badal Khatri <81486442+badalkhatri0924@users.noreply.github.com> Date: Fri, 24 Nov 2023 00:30:07 +0530 Subject: [PATCH 06/14] Call Backend API based of optional NEXT_PUBLIC_GAUZY_API_SERVER_URL Variable (#1847) * Call Backend API based of optional NEXT_PUBLIC_GAUZY_API_SERVER_URL variable * Update .env * fix: Direct API * Optional ENV updated * Updated GET API * Update .env * Update .env.sample --------- Co-authored-by: Ruslan K --- apps/mobile/app/services/client/fetch.ts | 5 +- apps/web/.env | 2 +- apps/web/.env.sample | 2 +- .../web/app/services/client/api/task-sizes.ts | 7 +-- apps/web/app/services/client/axios.ts | 46 +++++++++++++++++-- .../services/server/requests/task-sizes.ts | 6 +-- apps/web/pages/api/task-sizes/index.tsx | 4 +- 7 files changed, 56 insertions(+), 16 deletions(-) diff --git a/apps/mobile/app/services/client/fetch.ts b/apps/mobile/app/services/client/fetch.ts index b701439b9..a9e5ca351 100644 --- a/apps/mobile/app/services/client/fetch.ts +++ b/apps/mobile/app/services/client/fetch.ts @@ -1,5 +1,4 @@ import Config from '../../config'; -import { getToken } from '../api/tokenHandler'; export function serverFetch({ path, @@ -22,7 +21,7 @@ export function serverFetch({ }; if (bearer_token) { - headers['authorization'] = `Bearer ${bearer_token}`; + headers.authorization = `Bearer ${bearer_token}`; } if (tenantId) { @@ -31,7 +30,7 @@ export function serverFetch({ const datas: { body?: string } = {}; if (body) { - datas['body'] = JSON.stringify(body); + datas.body = JSON.stringify(body); } return fetch((Config.API_URL || '') + path, { diff --git a/apps/web/.env b/apps/web/.env index b78e951dc..409ebce1b 100644 --- a/apps/web/.env +++ b/apps/web/.env @@ -1,7 +1,7 @@ RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=false -NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.gauzy.co GAUZY_API_SERVER_URL=https://api.gauzy.co/api +NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.gauzy.co NEXT_PUBLIC_GA_MEASUREMENT_ID= # CAPTCHA Settings diff --git a/apps/web/.env.sample b/apps/web/.env.sample index 2cb957307..61cbba1e7 100644 --- a/apps/web/.env.sample +++ b/apps/web/.env.sample @@ -1,7 +1,7 @@ RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=false -NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.gauzy.co GAUZY_API_SERVER_URL=https://api.gauzy.co/api +NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.gauzy.co NEXT_PUBLIC_GA_MEASUREMENT_ID= # CAPTCHA Settings diff --git a/apps/web/app/services/client/api/task-sizes.ts b/apps/web/app/services/client/api/task-sizes.ts index 15d4a5425..153210226 100644 --- a/apps/web/app/services/client/api/task-sizes.ts +++ b/apps/web/app/services/client/api/task-sizes.ts @@ -1,5 +1,5 @@ import { CreateResponse, DeleteResponse, ITaskSizesCreate } from '@app/interfaces'; -import api from '../axios'; +import api, { get } from '../axios'; export function createTaskSizesAPI(data: ITaskSizesCreate, tenantId?: string) { return api.post>('/task-sizes', data, { @@ -21,6 +21,7 @@ export function deleteTaskSizesAPI(id: string) { return api.delete(`/task-sizes/${id}`); } -export function getTaskSizesList(tenantId: string, organizationId: string, activeTeamId: string | null) { - return api.get(`/task-sizes?tenantId=${tenantId}&organizationId=${organizationId}&activeTeamId=${activeTeamId}`); +export async function getTaskSizesList(tenantId: string, organizationId: string, activeTeamId: string | null) { + const endpoint = `/task-sizes?tenantId=${tenantId}&organizationId=${organizationId}&organizationTeamId=${activeTeamId}`; + return get(endpoint, true); } diff --git a/apps/web/app/services/client/axios.ts b/apps/web/app/services/client/axios.ts index 019ec76e9..216232ef2 100644 --- a/apps/web/app/services/client/axios.ts +++ b/apps/web/app/services/client/axios.ts @@ -1,5 +1,5 @@ import { API_BASE_URL, DEFAULT_APP_PATH } from '@app/constants'; -import { getActiveTeamIdCookie } from '@app/helpers/cookies'; +import { getAccessTokenCookie, getActiveTeamIdCookie } from '@app/helpers/cookies'; import axios, { AxiosResponse } from 'axios'; const api = axios.create({ @@ -7,7 +7,6 @@ const api = axios.create({ withCredentials: true, timeout: 60 * 1000 }); - api.interceptors.request.use( async (config: any) => { const cookie = getActiveTeamIdCookie(); @@ -22,7 +21,6 @@ api.interceptors.request.use( Promise.reject(error); } ); - api.interceptors.response.use( (response: AxiosResponse) => response, async (error: { response: AxiosResponse }) => { @@ -36,4 +34,46 @@ api.interceptors.response.use( } ); +const apiDirect = axios.create({ + baseURL: `${process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL}/api`, + timeout: 60 * 1000 +}); +apiDirect.interceptors.request.use( + async (config: any) => { + const cookie = getAccessTokenCookie(); + + if (cookie) { + config.headers['Authorization'] = `Bearer ${cookie}`; + } + + return config; + }, + (error: any) => { + Promise.reject(error); + } +); +apiDirect.interceptors.response.use( + (response: AxiosResponse) => { + return { + ...response, + data: response + }; + }, + async (error: { response: AxiosResponse }) => { + const statusCode = error.response?.status; + + if (statusCode === 401) { + window.location.assign(DEFAULT_APP_PATH); + } + + return Promise.reject(error); + } +); + +function get(endpoint: string, isDirect: boolean) { + return isDirect && process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL ? apiDirect.get(endpoint) : api.get(endpoint); +} + export default api; + +export { apiDirect, get }; diff --git a/apps/web/app/services/server/requests/task-sizes.ts b/apps/web/app/services/server/requests/task-sizes.ts index 0de33a623..6e63055e3 100644 --- a/apps/web/app/services/server/requests/task-sizes.ts +++ b/apps/web/app/services/server/requests/task-sizes.ts @@ -52,12 +52,12 @@ export function getTaskSizesListRequest( { organizationId, tenantId, - activeTeamId - }: { tenantId: string; organizationId: string; activeTeamId: string | null }, + organizationTeamId + }: { tenantId: string; organizationId: string; organizationTeamId: string | null }, bearer_token: string ) { return serverFetch({ - path: `/task-sizes?tenantId=${tenantId}&organizationId=${organizationId}&organizationTeamId=${activeTeamId}`, + path: `/task-sizes?tenantId=${tenantId}&organizationId=${organizationId}&organizationTeamId=${organizationTeamId}`, method: 'GET', bearer_token }); diff --git a/apps/web/pages/api/task-sizes/index.tsx b/apps/web/pages/api/task-sizes/index.tsx index d015c1c84..393b0c084 100644 --- a/apps/web/pages/api/task-sizes/index.tsx +++ b/apps/web/pages/api/task-sizes/index.tsx @@ -7,12 +7,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (!user) return $res(); - const { activeTeamId } = req.query; + const { organizationTeamId } = req.query; const par = { tenantId, organizationId, - activeTeamId: (activeTeamId as string) || null + organizationTeamId: (organizationTeamId as string) || null }; switch (req.method) { From a229b90a403c3f2bc62fdad79cf54c1a9c81eacf Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Fri, 24 Nov 2023 12:05:29 +0200 Subject: [PATCH 07/14] fixed code filed for iOS devices, and reduced card options dropdown height --- apps/mobile/app/components/CodeField.tsx | 8 ++++++-- .../Authenticated/TeamScreen/components/ListCardItem.tsx | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/mobile/app/components/CodeField.tsx b/apps/mobile/app/components/CodeField.tsx index f6a8bb23c..d67f9b811 100644 --- a/apps/mobile/app/components/CodeField.tsx +++ b/apps/mobile/app/components/CodeField.tsx @@ -1,7 +1,7 @@ /* eslint-disable react-native/no-inline-styles */ /* eslint-disable react-native/no-color-literals */ import React, { FC, useEffect, useState } from 'react'; -import { View, StyleSheet, Text } from 'react-native'; +import { View, StyleSheet, Text, Dimensions, PixelRatio, Platform } from 'react-native'; import { colors, typography, useAppTheme } from '../theme'; import { CodeField, Cursor, useBlurOnFulfill, useClearByFocusCell } from 'react-native-confirmation-code-field'; @@ -12,6 +12,9 @@ interface ICodeField { defaultValue?: string; } +const { height: screeHeight } = Dimensions.get('screen'); +const screenDimension = PixelRatio.get(); + export const CodeInputField: FC = (props) => { const { onChange, editable, length = 6 } = props; const { colors } = useAppTheme(); @@ -54,7 +57,8 @@ export const CodeInputField: FC = (props) => { flexDirection: 'column', justifyContent: 'center', alignItems: 'center', - lineHeight: 52 + lineHeight: + Platform.OS === 'ios' ? screeHeight * 0.055 * (screenDimension / 3) : undefined } ]} onLayout={getCellOnLayoutHandler(index)} diff --git a/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx b/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx index 74a11c19d..d2a526455 100644 --- a/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx +++ b/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx @@ -201,7 +201,7 @@ const ListCardItem: React.FC = observer((props) => { ...(props.index !== props.openMenuIndex ? { display: 'none' } : {}) }} > - + {(memberInfo.isAuthTeamManager || memberInfo.isAuthUser) && taskEdition.task && ( Date: Fri, 24 Nov 2023 17:23:33 +0530 Subject: [PATCH 08/14] fix: #1867 Improved API performance issue for timer status API --- apps/web/app/hooks/features/useTimer.ts | 7 +++++-- apps/web/app/hooks/useQuery.ts | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/web/app/hooks/features/useTimer.ts b/apps/web/app/hooks/features/useTimer.ts index 0a2edc8a2..f29ed1358 100644 --- a/apps/web/app/hooks/features/useTimer.ts +++ b/apps/web/app/hooks/features/useTimer.ts @@ -161,7 +161,7 @@ export function useTimer() { const { firstLoad, firstLoadData: firstLoadTimerData } = useFirstLoad(); // Queries - const { queryCall, loading } = useQuery(getTimerStatusAPI); + const { queryCall, loading, loadingRef } = useQuery(getTimerStatusAPI); const { queryCall: toggleQueryCall } = useQuery(toggleTimerAPI); const { queryCall: startTimerQueryCall } = useQuery(startTimerAPI); const { queryCall: stopTimerQueryCall, loading: stopTimerLoading } = useQuery(stopTimerAPI); @@ -187,6 +187,9 @@ export function useTimer() { const getTimerStatus = useCallback( (deepCheck?: boolean) => { + if (loadingRef.current) { + return; + } return queryCall().then((res) => { if (res.data && !isEqual(timerStatus, res.data)) { setTimerStatus((t) => { @@ -199,7 +202,7 @@ export function useTimer() { return res; }); }, - [timerStatus, setTimerStatus, queryCall] + [timerStatus, setTimerStatus, queryCall, loadingRef] ); const toggleTimer = useCallback( diff --git a/apps/web/app/hooks/useQuery.ts b/apps/web/app/hooks/useQuery.ts index 3746dda58..a1517755f 100644 --- a/apps/web/app/hooks/useQuery.ts +++ b/apps/web/app/hooks/useQuery.ts @@ -2,21 +2,28 @@ import { useCallback, useRef, useState } from 'react'; export function useQuery Promise>(queryFunction: T) { const [loading, setLoading] = useState(false); + const loadingRef = useRef(false); const infiniteLoading = useRef(false); const queryCall = useCallback((...params: Parameters) => { setLoading(true); + loadingRef.current = true; const promise = queryFunction(...params); promise.finally(() => { - !infiniteLoading.current && setLoading(false); + if (!infiniteLoading.current) { + setLoading(false); + + loadingRef.current = false; + } }); promise.catch(() => { setLoading(false); + loadingRef.current = false; }); return promise; // eslint-disable-next-line react-hooks/exhaustive-deps }, []) as T; - return { queryCall, loading, infiniteLoading }; + return { queryCall, loading, infiniteLoading, loadingRef }; } From b0cc238b20d5d4dc3b0235b6cc149645833d38a2 Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Fri, 24 Nov 2023 16:12:27 +0200 Subject: [PATCH 09/14] fixed profile screen card shadow for androids, also fixed estimate mode exit --- .../ProfileScreen/components/ListCardItem.tsx | 2 +- .../TeamScreen/components/ListCardItem.tsx | 69 +++++++++++-------- .../TimerScreen/components/EstimateTime.tsx | 21 ++---- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx index 1a64862f0..226e6cecd 100644 --- a/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx +++ b/apps/mobile/app/screens/Authenticated/ProfileScreen/components/ListCardItem.tsx @@ -315,7 +315,7 @@ export default ListCardItem; const styles = StyleSheet.create({ cardContainer: { borderRadius: 14, - elevation: 24, + elevation: 5, shadowColor: '#000', shadowOffset: { width: 0, height: 12 }, shadowOpacity: 0.05, diff --git a/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx b/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx index d2a526455..55f90ce24 100644 --- a/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx +++ b/apps/mobile/app/screens/Authenticated/TeamScreen/components/ListCardItem.tsx @@ -2,7 +2,7 @@ /* eslint-disable react-native/no-color-literals */ /* eslint-disable react-native/no-inline-styles */ import React, { useState } from 'react'; -import { View, ViewStyle, TouchableOpacity, StyleSheet, TouchableWithoutFeedback } from 'react-native'; +import { View, ViewStyle, TouchableOpacity, StyleSheet, TouchableWithoutFeedback, Platform } from 'react-native'; import { Ionicons, Entypo } from '@expo/vector-icons'; // COMPONENTS @@ -32,6 +32,7 @@ import { translate } from '../../../../i18n'; import { useTimer } from '../../../../services/hooks/useTimer'; import { SettingScreenNavigationProp } from '../../../../navigators/AuthenticatedNavigator'; import { getTimerStatusValue } from '../../../../helpers/get-timer-status'; +import { useClickOutside } from 'react-native-click-outside'; export type ListItemProps = { member: OT_Member; @@ -54,6 +55,7 @@ export interface Props extends ListItemProps { export const ListItemContent: React.FC = observer(({ memberInfo, taskEdition, onPressIn }) => { // HOOKS const { colors, dark } = useAppTheme(); + const clickOutsideTaskEstimationInputRef = useClickOutside(() => taskEdition.setEstimateEditMode(false)); return ( = observer(({ memberInfo, - { + if (Platform.OS === 'android' && taskEdition.estimateEditMode) { + event.stopPropagation(); + taskEdition.setEstimateEditMode(false); + } }} > - - - + + + + - - - + + + - {memberInfo.memberTask && taskEdition.estimateEditMode ? ( - - + + + ) : ( + taskEdition.setEstimateEditMode(true)} /> - - ) : ( - taskEdition.setEstimateEditMode(true)} - /> - )} - + )} + + @@ -353,7 +365,6 @@ const styles = StyleSheet.create({ }, estimate: { alignItems: 'center', - backgroundColor: '#E8EBF8', borderRadius: 5, flexDirection: 'row', justifyContent: 'space-between', diff --git a/apps/mobile/app/screens/Authenticated/TimerScreen/components/EstimateTime.tsx b/apps/mobile/app/screens/Authenticated/TimerScreen/components/EstimateTime.tsx index 659d9c4ef..69faf6040 100644 --- a/apps/mobile/app/screens/Authenticated/TimerScreen/components/EstimateTime.tsx +++ b/apps/mobile/app/screens/Authenticated/TimerScreen/components/EstimateTime.tsx @@ -174,15 +174,7 @@ const EstimateTime: FC = ({ setEditEstimate, currentTask, setEstimateTime {' m'} - {showCheckIcon && ( - handleSubmit()} - /> - )} + {showCheckIcon && handleSubmit()} />} {isLoading ? : null} ); @@ -197,8 +189,8 @@ const styles = StyleSheet.create({ borderRadius: 8, flexDirection: 'row', justifyContent: 'space-between', - marginLeft: 'auto', - marginRight: 10 + marginLeft: 'auto' + // marginRight: 10 }, estimateInput: { fontFamily: typography.fonts.PlusJakartaSans.semiBold, @@ -207,16 +199,11 @@ const styles = StyleSheet.create({ textAlign: 'center' }, loading: { - position: 'absolute', - right: -18 + marginLeft: 2 }, suffix: { fontFamily: typography.fonts.PlusJakartaSans.semiBold, fontSize: 14 }, - thickIconStyle: { - position: 'absolute', - right: -26 - }, wrapDash: { flexDirection: 'row', justifyContent: 'space-between', paddingLeft: 2 } }); From 20f6aaa5f178230c25354394c0e5552f29666e30 Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Fri, 24 Nov 2023 19:49:20 +0530 Subject: [PATCH 10/14] WIP: API Perfornamce Improvement --- apps/web/app/hooks/features/useOrganizationTeams.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/web/app/hooks/features/useOrganizationTeams.ts b/apps/web/app/hooks/features/useOrganizationTeams.ts index 74c46fff2..db57f7567 100644 --- a/apps/web/app/hooks/features/useOrganizationTeams.ts +++ b/apps/web/app/hooks/features/useOrganizationTeams.ts @@ -158,8 +158,12 @@ function useUpdateOrganizationTeam() { * It returns an object with all the data and functions needed to manage the teams in the organization */ export function useOrganizationTeams() { - const { loading, queryCall } = useQuery(getOrganizationTeamsAPI); - const { loading: loadingTeam, queryCall: queryCallTeam } = useQuery(getOrganizationTeamAPI); + const { loading, queryCall, loadingRef } = useQuery(getOrganizationTeamsAPI); + const { + loading: loadingTeam, + queryCall: queryCallTeam, + loadingRef: loadingRefTeam + } = useQuery(getOrganizationTeamAPI); const { teams, setTeams, setTeamsUpdate, teamsRef } = useTeamsState(); const activeTeam = useRecoilValue(activeTeamState); @@ -222,6 +226,10 @@ export function useOrganizationTeams() { ); const loadTeamsData = useCallback(() => { + if (loadingRef.current || loadingRefTeam.current) { + return; + } + let teamId = getActiveTeamIdCookie(); setActiveTeamId(teamId); @@ -273,6 +281,7 @@ export function useOrganizationTeams() { } } }); + return res; }); // eslint-disable-next-line react-hooks/exhaustive-deps From 88e2d53314209769dfc28970a8a20103e97bf928 Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Fri, 24 Nov 2023 21:19:09 +0530 Subject: [PATCH 11/14] Task Size API Updated --- apps/web/app/hooks/features/useTaskSizes.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/web/app/hooks/features/useTaskSizes.ts b/apps/web/app/hooks/features/useTaskSizes.ts index 884fd38ed..1d19f6fae 100644 --- a/apps/web/app/hooks/features/useTaskSizes.ts +++ b/apps/web/app/hooks/features/useTaskSizes.ts @@ -13,7 +13,7 @@ export function useTaskSizes() { const [user] = useRecoilState(userState); const activeTeamId = useRecoilValue(activeTeamIdState); - const { loading, queryCall } = useQuery(getTaskSizesList); + const { loading, queryCall, loadingRef } = useQuery(getTaskSizesList); const { loading: createTaskSizesLoading, queryCall: createQueryCall } = useQuery(createTaskSizesAPI); const { loading: deleteTaskSizesLoading, queryCall: deleteQueryCall } = useQuery(deleteTaskSizesAPI); const { loading: editTaskSizesLoading, queryCall: editQueryCall } = useQuery(editTaskSizesAPI); @@ -31,6 +31,10 @@ export function useTaskSizes() { }, [loading, firstLoad, setTaskSizesFetching]); const loadTaskSizes = useCallback(() => { + if (loadingRef.current) { + return; + } + const teamId = getActiveTeamIdCookie(); queryCall( user?.tenantId as string, @@ -43,7 +47,7 @@ export function useTaskSizes() { return res; }); - }, [user, activeTeamId, setTaskSizes, taskSizes, queryCall]); + }, [user, activeTeamId, setTaskSizes, taskSizes, queryCall, loadingRef]); useEffect(() => { if (!firstLoad) return; From dab0976b00f1fe251fb79517f46fecfbdf0c9111 Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Fri, 24 Nov 2023 21:29:49 +0530 Subject: [PATCH 12/14] Task Size/Priority/Stats API Updated --- apps/web/app/hooks/features/useTaskLabels.ts | 5 ++++- apps/web/app/hooks/features/useTaskPriorities.ts | 8 ++++++-- apps/web/app/hooks/features/useTaskStatus.ts | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/web/app/hooks/features/useTaskLabels.ts b/apps/web/app/hooks/features/useTaskLabels.ts index ff35a6318..0e0be0685 100644 --- a/apps/web/app/hooks/features/useTaskLabels.ts +++ b/apps/web/app/hooks/features/useTaskLabels.ts @@ -17,7 +17,7 @@ export function useTaskLabels() { const [user] = useRecoilState(userState); const activeTeamId = useRecoilValue(activeTeamIdState); - const { loading, queryCall } = useQuery(getTaskLabelsList); + const { loading, queryCall, loadingRef } = useQuery(getTaskLabelsList); const { loading: createTaskLabelsLoading, queryCall: createQueryCall } = useQuery(createTaskLabelsAPI); const { loading: deleteTaskLabelsLoading, queryCall: deleteQueryCall } = useQuery(deleteTaskLabelsAPI); const { loading: editTaskLabelsLoading, queryCall: editQueryCall } = useQuery(editTaskLabelsAPI); @@ -34,6 +34,9 @@ export function useTaskLabels() { }, [loading, firstLoad, setTaskLabelsFetching]); const loadTaskLabels = useCallback(() => { + if (loadingRef.current) { + return; + } const teamId = getActiveTeamIdCookie(); queryCall( user?.tenantId as string, diff --git a/apps/web/app/hooks/features/useTaskPriorities.ts b/apps/web/app/hooks/features/useTaskPriorities.ts index cc27f0984..d6bd22e50 100644 --- a/apps/web/app/hooks/features/useTaskPriorities.ts +++ b/apps/web/app/hooks/features/useTaskPriorities.ts @@ -17,7 +17,7 @@ export function useTaskPriorities() { const [user] = useRecoilState(userState); const activeTeamId = useRecoilValue(activeTeamIdState); - const { loading, queryCall } = useQuery(getTaskPrioritiesList); + const { loading, queryCall, loadingRef } = useQuery(getTaskPrioritiesList); const { loading: createTaskPrioritiesLoading, queryCall: createQueryCall } = useQuery(createTaskPrioritiesAPI); const { loading: deleteTaskPrioritiesLoading, queryCall: deleteQueryCall } = useQuery(deleteTaskPrioritiesAPI); const { loading: editTaskPrioritiesLoading, queryCall: editQueryCall } = useQuery(editTaskPrioritiesAPI); @@ -34,6 +34,10 @@ export function useTaskPriorities() { }, [loading, firstLoad, setTaskPrioritiesFetching]); const loadTaskPriorities = useCallback(() => { + if (loadingRef.current) { + return; + } + const teamId = getActiveTeamIdCookie(); queryCall( user?.tenantId as string, @@ -46,7 +50,7 @@ export function useTaskPriorities() { return res; }); - }, [user, activeTeamId, setTaskPriorities, taskPriorities, queryCall]); + }, [user, activeTeamId, setTaskPriorities, taskPriorities, queryCall, loadingRef]); useEffect(() => { if (!firstLoad) return; diff --git a/apps/web/app/hooks/features/useTaskStatus.ts b/apps/web/app/hooks/features/useTaskStatus.ts index a11495330..8757bba49 100644 --- a/apps/web/app/hooks/features/useTaskStatus.ts +++ b/apps/web/app/hooks/features/useTaskStatus.ts @@ -17,7 +17,7 @@ export function useTaskStatus() { const [user] = useRecoilState(userState); const activeTeamId = useRecoilValue(activeTeamIdState); - const { loading, queryCall } = useQuery(getTaskStatusList); + const { loading, queryCall, loadingRef } = useQuery(getTaskStatusList); const { loading: createTaskStatusLoading, queryCall: createQueryCall } = useQuery(createTaskStatusAPI); const { loading: deleteTaskStatusLoading, queryCall: deleteQueryCall } = useQuery(deleteTaskStatusAPI); const { loading: editTaskStatusLoading, queryCall: editQueryCall } = useQuery(editTaskStatusAPI); @@ -33,6 +33,9 @@ export function useTaskStatus() { }, [loading, firstLoad, setTaskStatusFetching]); const loadTaskStatusData = useCallback(() => { + if (loadingRef.current) { + return; + } const teamId = getActiveTeamIdCookie(); queryCall( user?.tenantId as string, @@ -44,7 +47,7 @@ export function useTaskStatus() { } return res; }); - }, [user, activeTeamId, setTaskStatus, taskStatus, queryCall]); + }, [user, activeTeamId, setTaskStatus, taskStatus, queryCall, loadingRef]); useEffect(() => { if (!firstLoad) return; From fadeee22fdd185ab0ef34384182e90b850ecf47b Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Fri, 24 Nov 2023 21:44:21 +0530 Subject: [PATCH 13/14] Auth, Team Task, Sync Timer APIs Updated --- apps/web/app/hooks/features/useAuthenticateUser.ts | 11 +++++++++-- apps/web/app/hooks/features/useTeamTasks.ts | 7 +++++-- apps/web/app/hooks/features/useTimer.ts | 10 +++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/apps/web/app/hooks/features/useAuthenticateUser.ts b/apps/web/app/hooks/features/useAuthenticateUser.ts index af6e7d305..974b13fca 100644 --- a/apps/web/app/hooks/features/useAuthenticateUser.ts +++ b/apps/web/app/hooks/features/useAuthenticateUser.ts @@ -16,13 +16,20 @@ export const useAuthenticateUser = (defaultUser?: IUser) => { const { isTeamManager } = useIsMemberManager(user); - const { queryCall: refreshUserQueryCall, loading: refreshUserLoading } = useQuery(getAuthenticatedUserDataAPI); + const { + queryCall: refreshUserQueryCall, + loading: refreshUserLoading, + loadingRef: refreshUserLoadingRef + } = useQuery(getAuthenticatedUserDataAPI); const updateUserFromAPI = useCallback(() => { + if (refreshUserLoadingRef.current) { + return; + } refreshUserQueryCall().then((res) => { setUser(res.data.user); }); - }, [refreshUserQueryCall, setUser]); + }, [refreshUserQueryCall, setUser, refreshUserLoadingRef]); $user.current = useMemo(() => { return user || $user.current; diff --git a/apps/web/app/hooks/features/useTeamTasks.ts b/apps/web/app/hooks/features/useTeamTasks.ts index 111ea3f52..577cc7d01 100644 --- a/apps/web/app/hooks/features/useTeamTasks.ts +++ b/apps/web/app/hooks/features/useTeamTasks.ts @@ -45,7 +45,7 @@ export function useTeamTasks() { const { firstLoad, firstLoadData: firstLoadTasksData } = useFirstLoad(); // Queries hooks - const { queryCall, loading } = useQuery(getTeamTasksAPI); + const { queryCall, loading, loadingRef } = useQuery(getTeamTasksAPI); const { queryCall: getTasksByIdQueryCall, loading: getTasksByIdLoading } = useQuery(getTasksByIdAPI); const { queryCall: deleteQueryCall, loading: deleteLoading } = useQuery(deleteTaskAPI); @@ -104,12 +104,15 @@ export function useTeamTasks() { const loadTeamTasksData = useCallback( (deepCheck?: boolean) => { + if (loadingRef.current) { + return; + } return queryCall().then((res) => { deepCheckAndUpdateTasks(res?.data?.items || [], deepCheck); return res; }); }, - [queryCall, deepCheckAndUpdateTasks] + [queryCall, deepCheckAndUpdateTasks, loadingRef] ); // Global loading state diff --git a/apps/web/app/hooks/features/useTimer.ts b/apps/web/app/hooks/features/useTimer.ts index f29ed1358..38eb65a5e 100644 --- a/apps/web/app/hooks/features/useTimer.ts +++ b/apps/web/app/hooks/features/useTimer.ts @@ -165,7 +165,11 @@ export function useTimer() { const { queryCall: toggleQueryCall } = useQuery(toggleTimerAPI); const { queryCall: startTimerQueryCall } = useQuery(startTimerAPI); const { queryCall: stopTimerQueryCall, loading: stopTimerLoading } = useQuery(stopTimerAPI); - const { queryCall: syncTimerQueryCall, loading: syncTimerLoading } = useQuery(syncTimerAPI); + const { + queryCall: syncTimerQueryCall, + loading: syncTimerLoading, + loadingRef: syncTimerLoadingRef + } = useQuery(syncTimerAPI); // const wasRunning = timerStatus?.running || false; const timerStatusRef = useSyncRef(timerStatus); @@ -220,13 +224,13 @@ export function useTimer() { ); const syncTimer = useCallback(() => { - if (syncTimerLoading) { + if (syncTimerLoading || syncTimerLoadingRef.current) { return; } return syncTimerQueryCall(timerStatus?.lastLog?.source || TimerSource.TEAMS).then((res) => { return res; }); - }, [syncTimerQueryCall, timerStatus, syncTimerLoading]); + }, [syncTimerQueryCall, timerStatus, syncTimerLoading, syncTimerLoadingRef]); // Loading states useEffect(() => { From 8c0238ea6d6bb9b487cffa0506ba088146e5c39f Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Fri, 24 Nov 2023 21:53:59 +0530 Subject: [PATCH 14/14] fix: Build Issue --- apps/web/app/hooks/features/useTeamTasks.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/app/hooks/features/useTeamTasks.ts b/apps/web/app/hooks/features/useTeamTasks.ts index 577cc7d01..d8755c3f6 100644 --- a/apps/web/app/hooks/features/useTeamTasks.ts +++ b/apps/web/app/hooks/features/useTeamTasks.ts @@ -105,7 +105,9 @@ export function useTeamTasks() { const loadTeamTasksData = useCallback( (deepCheck?: boolean) => { if (loadingRef.current) { - return; + return new Promise((response) => { + response(true); + }); } return queryCall().then((res) => { deepCheckAndUpdateTasks(res?.data?.items || [], deepCheck);