Browse Source

fix | get factories by userId

merge-requests/158/head
Kurmansky 3 years ago
parent
commit
098a1bb015
  1. 18
      ios/Podfile.lock
  2. 4
      ios/taskme.xcodeproj/project.pbxproj
  3. 15287
      package-lock.json
  4. 4
      src/api/factories/requests.ts
  5. 7
      src/modules/account/hooks/use-account-editor.hook.ts
  6. 9
      src/modules/account/screens/account.screen.tsx
  7. 10
      src/modules/contacts/hooks/use-contact-detail.hook.ts
  8. 2
      src/modules/contacts/screens/contact-detail.screen.tsx
  9. 1
      src/services/domain/auth.service.ts
  10. 11
      src/services/domain/factories.service.ts

18
ios/Podfile.lock

@ -549,7 +549,7 @@ SPEC CHECKSUMS: @@ -549,7 +549,7 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
FBLazyVector: c71c5917ec0ad2de41d5d06a5855f6d5eda06971
FBReactNativeSpec: db3c5050c0e55e54339535438f466df9603f4a12
FBReactNativeSpec: 1b104089c962a23178ab10f7d072921d46a48d43
Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c
@ -560,8 +560,8 @@ SPEC CHECKSUMS: @@ -560,8 +560,8 @@ SPEC CHECKSUMS:
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
Permission-Camera: 1f383e3f9a38ba393c63ba9b09a4726f94eda769
Permission-PhotoLibrary: 9b75dcdaa23295b99cbe655113aee41bae4c5d52
Permission-Camera: 0db4fd6e1c556c1cf47f38b989a8084cea3ec3dd
Permission-PhotoLibrary: 9dcf80d1353d81b9f1e210c34291591236aaf2b6
RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c
RCTRequired: d34bf57e17cb6e3b2681f4809b13843c021feb6c
RCTTypeSafety: 8dab4933124ed39bb0c1d88d74d61b1eb950f28f
@ -575,10 +575,10 @@ SPEC CHECKSUMS: @@ -575,10 +575,10 @@ SPEC CHECKSUMS:
React-jsinspector: 34e23860273a23695342f58eed3ffd3ba10c31e0
react-native-clear-cache: 28bce59b33cd809e0afe903786787b4409d1c1fb
react-native-date-picker: 201b481c94dcb7678f4712477ad026dd7793305b
react-native-netinfo: 877946c7b4eb85a639cf1ea31333dadc2be999a1
react-native-netinfo: 3d3769f0d65de15c83a9bf1346f8be71de5a24bf
react-native-orientation-locker: 998c0744e26624407dac068c04c605b4af7304a2
react-native-pager-view: f21658a2e12eced35ef998250375e4e4dc9b8487
react-native-safe-area-context: 8465df05de8106c584b117f0e027e17174d6e02e
react-native-pager-view: 5ab4d0b4b44d89f77310cb3eb8129745f274ce55
react-native-safe-area-context: 61c8c484a3a9e7d1fda19f7b1794b35bbfd2262a
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
React-perflogger: cc76a4254d19640f1d8ad1c66fdee800414b805c
React-RCTActionSheet: 7448f049318d8d7e8a9a1ebb742ada721757eea8
@ -592,12 +592,12 @@ SPEC CHECKSUMS: @@ -592,12 +592,12 @@ SPEC CHECKSUMS:
React-RCTVibration: c7f845861e79eae13dc1e8217a3cf47a3945b504
React-runtimeexecutor: 493d9abb8b23c3f84e19ae221eeba92cadcb70dc
ReactCommon: 8fea6422328e2fc093e25c9fac67adbcf0f04fb4
RNCAsyncStorage: 0f655864a81214d1c5a9bf0faf79d86dc25c383e
RNCAsyncStorage: e8b8d6320a0dd90eb610fb0d0b1ef90596697c69
RNCPicker: c3a3d481bec16624ed84a3c2a64c92fdc5515960
RNDeviceInfo: 0d6865ab0a57d9192bdd4e4f5894340b846c3e53
RNDeviceInfo: cc7de0772378f85d8f36ae439df20f05c590a651
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNImageCropPicker: 448d3c6e923fde3466b49caf3c2457c2a0ba02dd
RNPermissions: b3588a19e12bff03fe21bc46911fd32343666dc0
RNPermissions: 4b54095940aea8c03fa3e6c92d4ac3647b31ed4e
RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e
RNSVG: 8ba35cbeb385a52fd960fd28db9d7d18b4c2974f
RNVectorIcons: f67a1abce2ec73e62fe4606e8110e95a832bc859

4
ios/taskme.xcodeproj/project.pbxproj

@ -613,7 +613,7 @@ @@ -613,7 +613,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
@ -678,7 +678,7 @@ @@ -678,7 +678,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

15287
package-lock.json generated

File diff suppressed because it is too large Load Diff

4
src/api/factories/requests.ts

@ -2,6 +2,6 @@ import http from '../http.service' @@ -2,6 +2,6 @@ import http from '../http.service'
import { ApiResponse } from '../http.types'
import { IGetMyFactoriesResponse } from './responses.interface'
export const fetchMyFactoriesReq = (): ApiResponse<IGetMyFactoriesResponse> => {
return http.get<IGetMyFactoriesResponse>('factories')
export const fetchMyFactoriesReq = (params: { userId: number }): ApiResponse<IGetMyFactoriesResponse> => {
return http.get<IGetMyFactoriesResponse>('factories', { params })
}

7
src/modules/account/hooks/use-account-editor.hook.ts

@ -66,7 +66,7 @@ export const useAccountEditor = () => { @@ -66,7 +66,7 @@ export const useAccountEditor = () => {
submit()
}, 300)
},
notAllowBtnAction: () => {},
notAllowBtnAction: () => { },
})
})
@ -79,13 +79,13 @@ export const useAccountEditor = () => { @@ -79,13 +79,13 @@ export const useAccountEditor = () => {
appEvents.emit('openInfoModal', {
title: 'Успіх!',
message: 'Дані оновлені.',
onPressOk: () => {},
onPressOk: () => { },
})
} catch (e: any) {
appEvents.emit('openInfoModal', {
title: 'Сталась помилка!',
message: 'Спробуйте будь-ласка пізніше.',
onPressOk: () => {},
onPressOk: () => { },
})
} finally {
setLoading(false)
@ -124,6 +124,7 @@ export const useAccountEditor = () => { @@ -124,6 +124,7 @@ export const useAccountEditor = () => {
}
return {
userId: account.id,
form,
submit: preSubmit,
isLoading,

9
src/modules/account/screens/account.screen.tsx

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import React, { FC } from 'react'
import React, { FC, useEffect } from 'react'
import {
Keyboard,
StyleSheet,
@ -29,13 +29,14 @@ import { PartialTheme } from '@/shared/themes/interfaces' @@ -29,13 +29,14 @@ import { PartialTheme } from '@/shared/themes/interfaces'
import { useTheme } from '@/shared/hooks/use-theme.hook'
import { useSelector } from 'react-redux'
import { selectMyFactoryName } from '@/store/account'
import { factoriesService } from '@/services/domain/factories.service'
interface IProps extends IRouteParams {}
export const AccountScreen: FC<IProps> = ({ navigation }) => {
const { styles } = useTheme(createStyles)
const { form, submit, isLoading, removeAvatar } = useAccountEditor()
const { userId, form, submit, isLoading, removeAvatar } = useAccountEditor()
const myFactoryName = useSelector(selectMyFactoryName)
const { logout } = useAuthorization({})
const { scrollRef, onFocusLastElement, onBlurLastElement } =
@ -57,6 +58,10 @@ export const AccountScreen: FC<IProps> = ({ navigation }) => { @@ -57,6 +58,10 @@ export const AccountScreen: FC<IProps> = ({ navigation }) => {
}, 200)
}
useEffect(() => {
factoriesService.loadFactories(userId)
}, [])
return (
<ScreenLayout
needScroll

10
src/modules/contacts/hooks/use-contact-detail.hook.ts

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
import { useSelector } from 'react-redux';
import { appEvents, hasImageUrl, IContactDetail } from '@/shared'
import { contactsService } from '@/services/domain'
import { useEffect, useMemo, useState } from 'react'
@ -5,16 +6,21 @@ import { getContactDetailConfig } from '../configs' @@ -5,16 +6,21 @@ import { getContactDetailConfig } from '../configs'
import { createFullName, isSoonBirthday } from '@/shared/helpers'
import { Linking } from 'react-native';
import { ContactDetailFieldType } from '../enums'
import { selectMyFactoryName } from '@/store/account';
import { factoriesService } from '@/services/domain/factories.service';
export const useContactDetail = (id: number) => {
const [isLoading, setLoad] = useState<boolean>(false)
const [contactDetail, setContact] = useState<IContactDetail>(null)
const contactFactory = useSelector(selectMyFactoryName)
const fetchContactDetail = async () => {
try {
setLoad(true)
const { data: contactDetail } = await contactsService.fetchDetail({
contactId: id,
contactId: String(id),
})
setContact(contactDetail)
@ -28,6 +34,7 @@ export const useContactDetail = (id: number) => { @@ -28,6 +34,7 @@ export const useContactDetail = (id: number) => {
useEffect(() => {
fetchContactDetail()
factoriesService.loadFactories(id)
}, [])
const prepareContactInfoToRender = useMemo(() => {
@ -52,6 +59,7 @@ export const useContactDetail = (id: number) => { @@ -52,6 +59,7 @@ export const useContactDetail = (id: number) => {
innerPhoneNumber: contactDetailInfo?.innerPhoneNumber,
isSoonBirthday: isSoonBirthday(contactDetailInfo?.dateOfBirth),
email: contactDetail?.email,
factoryName: contactFactory
}
}
}, [contactDetail])

2
src/modules/contacts/screens/contact-detail.screen.tsx

@ -59,7 +59,7 @@ export const ContactDetailScreen: FC<IProps> = ({ navigation, route }) => { @@ -59,7 +59,7 @@ export const ContactDetailScreen: FC<IProps> = ({ navigation, route }) => {
avatarTextStyle={styles.avatarText}
text={contact?.fullName}
textStyle={styles.avatarTitle}
subTitle={contact?.position}
subTitle={`${contact?.factoryName} ${contact?.position}`}
maxHeight={$size(200, 190)}
maxWidth={$size(200, 190)}
indicator={avatarBirthdayIndicator}

1
src/services/domain/auth.service.ts

@ -65,7 +65,6 @@ const loadDataAfterAuth = async () => { @@ -65,7 +65,6 @@ const loadDataAfterAuth = async () => {
permissionsService.loadPermissionsForUsers(),
taxonomiesService.fetchGroups(),
taxonomiesService.fetchReasons(),
factoriesService.loadFactories(),
])
}

11
src/services/domain/factories.service.ts

@ -2,11 +2,14 @@ import { fetchMyFactoriesReq } from '@/api/factories/requests' @@ -2,11 +2,14 @@ import { fetchMyFactoriesReq } from '@/api/factories/requests'
import { SaveFactories } from '@/store/account'
import { simpleDispatch } from '@/store/store-helpers'
const loadFactories = async () => {
const loadFactories = async (userId: number) => {
try {
const { data } = await fetchMyFactoriesReq()
if (data) simpleDispatch(new SaveFactories({ factories: data }))
} catch (e) {}
const { data: factories } = await fetchMyFactoriesReq({ userId })
if (factories) simpleDispatch(new SaveFactories({ factories }))
} catch (err) {
console.log(err)
}
}
export const factoriesService = {

Loading…
Cancel
Save