Skip to content

Commit

Permalink
Merge pull request #716 from stasgm/predev
Browse files Browse the repository at this point in the history
Predev
  • Loading branch information
sunnycreature authored Oct 27, 2023
2 parents 82d6364 + e2d7170 commit 8a951f2
Show file tree
Hide file tree
Showing 221 changed files with 4,832 additions and 1,982 deletions.
15 changes: 9 additions & 6 deletions .env.dev.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ REACT_APP_SECRET_KEY=
# Ключ сайта для капчи
REACT_APP_SITE_KEY=

# Метка для названия образа админки
CLIENT_ENV=dev

# Порт хоста, на котором будет запущен веб-интерфейс
ADMIN_HOST_PORT=3656

# Порт контейнера, на котором будет запущен веб-интерфейс, 443 или 80
ADMIN_CONTAINER_PORT=443
# Порт контейнера, на котором будет запущен веб-интерфейс
ADMIN_CONTAINER_PORT=3000

# Протокол админки, если он https
ADMIN_HTTPS=true

# Протокол бэка в админке, если он https
ADMIN_BACKEND_HTTPS=true

# Хост для сервера
# Хост для сервера, IP компьютера или 'server.gdmn.app'
HOST='0.0.0.0'

# Порт, на котором приложение будет запущено для обработки HTTP-запросов
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
2. [Инструкция по GDMN Отдел снабжения](https://github.com/stasgm/gdmn-mob/blob/dev/docs/gdmn-appl-request/docs/README.md)
3. [Инструкция по GDMN Торговые агенты](https://github.com/stasgm/gdmn-mob/blob/dev/docs/gdmn-app-trade-agents/docs/README.md)
4. [Инструкция по GDMN Склад](https://github.com/stasgm/gdmn-mob/blob/dev/docs/gdmn-gd-movement/docs/README.md)
5. [Инструкция по докеру](https://github.com/stasgm/gdmn-mob/blob/dev/docs/gdmn-gd-movement/docs/docker/README.md)
5. [Инструкция по GDMN Отгрузка](https://github.com/stasgm/gdmn-mob/blob/dev/docs/gdmn-fp-movement/docs/README.md)
6. [Инструкция по докеру](https://github.com/stasgm/gdmn-mob/blob/dev/docs/gdmn-gd-movement/docs/docker/README.md)
1 change: 0 additions & 1 deletion apps/app-bc-movement/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const Root = () => {
}, [isInit]);

useEffect(() => {
// dispatch(authActions.init());
dispatch(appActions.loadGlobalDataFromDisc());
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down
47 changes: 30 additions & 17 deletions apps/app-fp-movement/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import { StatusBar } from 'expo-status-bar';
import {
appActions,
appSelectors,
authActions,
authSelectors,
documentActions,
referenceActions,
settingsActions,
useAuthThunkDispatch,
useDispatch,
useDocThunkDispatch,
useRefThunkDispatch,
Expand All @@ -31,14 +29,16 @@ import {

import { ActivityIndicator, Caption, Text } from 'react-native-paper';

import { IDocument, IReferences, ISettingsOption, IUserSettings } from '@lib/types';
import { IDocument, IReferences, IUserSettings } from '@lib/types';

import { sleep, dialCall } from '@lib/mobile-hooks';

import { TouchableOpacity, Linking, ScrollView, View } from 'react-native';

import Constants from 'expo-constants';

import { useSettingsThunkDispatch } from '@lib/store/src/settings/actions.async';

import { MoveNavigator } from './src/navigation/MoveNavigator';

import { store, useSelector as useFpSelector, fpMovementActions, useDispatch as useFpDispatch } from './src/store';
Expand Down Expand Up @@ -292,17 +292,14 @@ const Root = () => {
const dispatch = useDispatch();

//Загружаем в стор дополнительные настройки приложения
const authLoading = useSelector((state) => state.auth.loadingData);
const appDataLoading = appSelectors.selectLoading();
const isLogged = authSelectors.isLoggedWithCompany();
const fpLoading = useFpSelector((state) => state.fpMovement.loading);
const isDemo = useSelector((state) => state.auth.isDemo);
const connectionStatus = useSelector((state) => state.auth.connectionStatus);
const getReferences = useSelector((state) => state.settings?.data?.getReferences);
const { connectionStatus, isDemo, loadingData: authLoading, user } = useSelector((state) => state.auth);

const refDispatch = useRefThunkDispatch();
const docDispatch = useDocThunkDispatch();
const authDispatch = useAuthThunkDispatch();
const settingsDispatch = useSettingsThunkDispatch();

const getMessages = useCallback(async () => {
await sleep(ONE_SECOND_IN_MS);
Expand All @@ -314,22 +311,18 @@ const Root = () => {
await docDispatch(
documentActions.setDocuments(messageFpMovement.find((m) => m.body.type === 'DOCS')?.body.payload as IDocument[]),
);
await authDispatch(
authActions.setUserSettings(
await settingsDispatch(
settingsActions.setUserSettings(
messageFpMovement.find((m) => m.body.type === 'SETTINGS')?.body.payload as IUserSettings,
),
);
}, [authDispatch, docDispatch, refDispatch]);
}, [docDispatch, refDispatch, settingsDispatch]);

useEffect(() => {
//isInit - true при открытии приложения или при ручном сбросе настроек
//До загрузки данных пользователя устанавливаем настройки по умолчанию
if (appSettings && isInit) {
dispatch(settingsActions.addSettings(appSettings));
dispatch(
settingsActions.updateOption({
optionName: 'getReferences',
value: { ...getReferences, data: false } as ISettingsOption,
}),
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isInit]);
Expand All @@ -346,6 +339,26 @@ const Root = () => {
}, [dispatch, isLogged]);

const [loading, setLoading] = useState(true);
const [addSettings, setAddSettings] = useState('INIT');

useEffect(() => {
//После загрузки данных пользователя устанавливаем настройки поверх настроек по умолчанию и загруженных из памяти
//Необходимо при добавлении новых параметров
if (appDataLoading) {
if (addSettings === 'INIT') {
setAddSettings('ADDING');
}
} else if (addSettings === 'ADDING') {
dispatch(settingsActions.addSettings(appSettings));
setAddSettings('ADDED');
}
}, [addSettings, appDataLoading, dispatch]);

useEffect(() => {
if (user) {
setAddSettings('INIT');
}
}, [user]);

useEffect(() => {
//Для отрисовки при первом подключении
Expand Down
4 changes: 2 additions & 2 deletions apps/app-fp-movement/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "GDMN Отгрузка",
"slug": "gdmn-fp-movement",
"version": "0.1.4",
"version": "0.3.5",
"githubUrl": "https://github.com/stasgm/gdmn-mob",
"orientation": "default",
"icon": "./assets/icon.png",
Expand All @@ -26,7 +26,7 @@
"android": {
"package": "com.gsbelarus.fpmovement",
"permissions": ["CAMERA", "VIBRATE"],
"versionCode": 16
"versionCode": 29
},
"web": {
"favicon": "./assets/favicon.png"
Expand Down
Binary file added apps/app-fp-movement/assets/ok.wav
Binary file not shown.
128 changes: 128 additions & 0 deletions apps/app-fp-movement/src/components/QuantDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import React from 'react';
import { KeyboardTypeOptions, Text, View, StyleSheet } from 'react-native';
import { useTheme } from '@react-navigation/native';
import { Dialog, Button, TextInput } from 'react-native-paper';
import { LargeText } from '@lib/mobile-ui';

interface IProps {
visible: boolean;
textPack: string;
textPallet: string;
onChangeTextPack: (text: string) => void;
onChangeTextPallet: (text: string) => void;
onOk: () => void;
onCancel: () => void;
okLabel?: string;
errorMessage?: string;
okDisabled?: boolean;
cancelDisabled?: boolean;
keyboardType?: KeyboardTypeOptions;
isPack: boolean;
}

const QuantDialog = ({
visible,
textPack,
textPallet,
onChangeTextPack,
onChangeTextPallet,
onOk,
onCancel,
errorMessage,
okLabel = 'Ок',
okDisabled = false,
cancelDisabled = false,
keyboardType = 'default',
isPack = true,
}: IProps) => {
const { colors } = useTheme();

return (
<Dialog visible={visible} onDismiss={onCancel}>
<Dialog.Content>
<View style={localStyles.titleView}>
<LargeText style={localStyles.titleText}>
{isPack ? 'Количество коробок' : 'Количество коробок на поддоне'}
</LargeText>
</View>
<TextInput
theme={{
colors: {
primary: colors.primary,
text: colors.text,
placeholder: colors.primary,
},
}}
value={textPack}
onChangeText={(text) => onChangeTextPack(text)}
autoFocus
right={
!!textPack && (
<TextInput.Icon
name="close"
size={20}
style={localStyles.marginTop}
onPress={() => onChangeTextPack('')}
/>
)
}
keyboardType={keyboardType ? keyboardType : 'default'}
style={localStyles.height}
/>
{!!errorMessage && <Text style={{ color: colors.notification }}>{errorMessage}</Text>}
{!isPack && (
<>
<View style={localStyles.titleView}>
<LargeText style={localStyles.titleText}>Количество поддонов</LargeText>
</View>
<TextInput
theme={{
colors: {
primary: colors.primary,
text: colors.text,
placeholder: colors.primary,
},
}}
value={textPallet}
onChangeText={(text) => onChangeTextPallet(text)}
right={
!!textPallet && (
<TextInput.Icon
name="close"
size={20}
style={localStyles.marginTop}
onPress={() => onChangeTextPallet('')}
/>
)
}
keyboardType={keyboardType ? keyboardType : 'default'}
style={localStyles.height}
/>
</>
)}
</Dialog.Content>
<Dialog.Actions style={{ borderColor: colors.primary }}>
<Button
labelStyle={{ color: colors.primary }}
color={colors.primary}
onPress={onCancel}
disabled={cancelDisabled}
>
Отмена
</Button>
<Button labelStyle={{ color: colors.primary }} color={colors.primary} onPress={onOk} disabled={okDisabled}>
{okLabel}
</Button>
</Dialog.Actions>
</Dialog>
);
};

const localStyles = StyleSheet.create({
marginTop: { marginTop: 7 },
titleView: { flexDirection: 'row', alignItems: 'center', marginVertical: 10 },
titleText: { fontWeight: '600' },
height: { height: 40 },
});

export default QuantDialog;
32 changes: 21 additions & 11 deletions apps/app-fp-movement/src/components/SelectRefItemScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IReferenceData, ScreenState } from '@lib/types';

import { useDispatch } from '../store';
import { RefParamList } from '../navigation/Root/types';
import { IAddressStoreEntity } from '../store/app/types';

const SelectRefItemScreen = () => {
const navigation = useNavigation();
Expand All @@ -34,35 +35,44 @@ const SelectRefItemScreen = () => {
fieldName,
value,
clause,
clauseType,
refFieldName = 'name' || 'shcode',
descrFieldName,
} = useRoute<RouteProp<RefParamList, 'SelectRefItem'>>().params;

const refObj = refSelectors.selectByName<IReferenceData>(refName);

const list = useMemo(() => {
if (clause && refObj?.data) {
return refObj?.data.filter((item) => {
const newParams = Object.assign({}, clause);
let isAddressStoreFound = true;

Object.keys(clause).forEach((i) => {
if (i in item) {
if (typeof clause[i] !== 'object' && typeof item[i] !== 'object' && item[i] === clause[i]) {
if (
typeof clause[i] !== 'object' &&
typeof item[i] !== 'object' &&
(clauseType === 'boolean' ? Boolean(item[i]) === (clause[i] === 'true') : item[i] === clause[i])
) {
}
}
});
return extraPredicate(item, newParams);

isAddressStoreFound = newParams.isAddressStore
? newParams.isAddressStore === 'true'
? Boolean((item as IAddressStoreEntity).isAddressStore)
: !(item as IAddressStoreEntity).isAddressStore
: true;
delete newParams.isAddressStore;

return isAddressStoreFound && extraPredicate(item, newParams);
});
}
return refObj?.data?.sort((a, b) =>
a.sortOrder && b.sortOrder
? (a.sortOrder || 1) < (b.sortOrder || 1)
? -1
: 1
: a[refFieldName] < b[refFieldName]
? -1
: 1,
return refObj?.data?.sort(
(a, b) => (a.sortOrder || 1) - (b.sortOrder || 1) || a[refFieldName].localeCompare(b[refFieldName]),
);
}, [clause, refFieldName, refObj?.data]);
}, [clause, clauseType, refFieldName, refObj?.data]);

const title = refObj?.description || refObj?.name;

Expand Down
1 change: 1 addition & 0 deletions apps/app-fp-movement/src/navigation/Root/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type IRefSelectParams = {
fieldName: string;
value?: IReferenceData[];
clause?: Record<string, string>;
clauseType?: string;
isMulti?: boolean;
docType?: string;
refFieldName?: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/app-fp-movement/src/screens/Cells/components/Cells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Cells = ({

return (
<TouchableOpacity
key={item.name}
key={`${item.name}-${item.sortOrder}`}
style={[localStyles.buttons, backColorStyle]}
onPress={() =>
item.defaultGroup?.id && !item.barcode
Expand All @@ -91,7 +91,7 @@ const Cells = ({
({ data }: { data: ICellData[] }) => (
<View style={styles.flexDirectionRow}>
{data?.map((item) => (
<Cell key={item.name} item={item} />
<Cell key={`${item.name}-${item.sortOrder}`} item={item} />
))}
</View>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const FreeShipmentEditScreen = () => {

const doc = shipments?.find((e) => e.id === id);

const defaultDepart = useSelector((state) => state.auth.user?.settings?.depart?.data);
const defaultDepart = useSelector((state) => state.settings?.userData?.depart?.data);

const shipmentType = refSelectors
.selectByName<IReference<IDocumentType>>('documentType')
Expand Down
Loading

0 comments on commit 8a951f2

Please sign in to comment.