Skip to content

Commit

Permalink
Merge pull request #742 from stasgm/old_selectors
Browse files Browse the repository at this point in the history
Old selectors
  • Loading branch information
sunnycreature authored Jan 9, 2024
2 parents ce164be + eec1baa commit 7b7dc2d
Show file tree
Hide file tree
Showing 61 changed files with 2,811 additions and 378 deletions.
2 changes: 1 addition & 1 deletion apps/app-bc-movement/eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"buildType": "apk"
}
},
"production": {"node": "16.14.0"}
"production": {"node": "18.14.0"}
}
}
2 changes: 1 addition & 1 deletion apps/app-bc-movement/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"expo-constants": "~14.4.2",
"expo-font": "~11.4.0",
"expo-status-bar": "~1.6.0",
"expo-updates": "~0.18.17",
"expo-updates": "~0.18.19",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.6",
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.4.3",
"version": "0.4.4",
"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": 35
"versionCode": 36
},
"web": {
"favicon": "./assets/favicon.png"
Expand Down
2 changes: 1 addition & 1 deletion apps/app-fp-movement/eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"buildType": "apk"
}
},
"production": {"node": "16.14.0"}
"production": {"node": "18.14.0"}
},
"submit": {
"production": {}
Expand Down
4 changes: 2 additions & 2 deletions apps/app-fp-movement/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"expo-constants": "~14.4.2",
"expo-font": "~11.4.0",
"expo-status-bar": "~1.6.0",
"expo-updates": "~0.18.17",
"expo-updates": "~0.18.19",
"mathjs": "^11.11.1",
"nanoid": "^3.3.4",
"react": "18.2.0",
Expand All @@ -80,7 +80,7 @@
},
"devDependencies": {
"@babel/core": "^7.22.17",
"@babel/runtime": "^7.23.6",
"@babel/runtime": "^7.18.3",
"@config/eslint-config": "*",
"@config/eslint-config-react": "*",
"@config/eslint-config-react-native": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const FreeShipmentListScreen = () => {
</MediumText>
</View>
),
sentDate: i.sentDate,
}) as IListItemProps,
);
}, [list, status, sortDateType.id]);
Expand Down
151 changes: 117 additions & 34 deletions apps/app-fp-movement/src/screens/FreeShipment/FreeShipmentViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
getBarcode,
getDocToSend,
getLineGood,
getNextDocNumber,
getRemGoodListByContact,
getUpdatedLine,
} from '../../utils/helpers';
Expand Down Expand Up @@ -227,6 +228,37 @@ export const FreeShipmentViewScreen = () => {
navigation.navigate('FreeShipmentEdit', { id, isCurr });
}, [navigation, id, isCurr]);

const handleCopyDoc = useCallback(async () => {
if (!doc) {
return;
}
setScreenState('copying');
await sleep(1);
const newId = generateId();

const newDocDate = new Date().toISOString();

const freeShipments = docList.filter((i) =>
isCurr ? i.documentType.name === 'currFreeShipment' : i.documentType.name === 'freeShipment',
);
const newNumber = getNextDocNumber(freeShipments);

const newDoc: IFreeShipmentDocument = {
...doc,
id: newId,
number: newNumber,
status: 'DRAFT',
documentDate: newDocDate,
creationDate: newDocDate,
editionDate: newDocDate,
};

docDispatch(documentActions.addDocument(newDoc));
navigation.navigate('FreeShipmentView', { id: newId, isCurr });

setScreenState('copied');
}, [doc, docList, docDispatch, navigation, isCurr]);

const handleDelete = useCallback(() => {
if (!id) {
return;
Expand Down Expand Up @@ -298,31 +330,64 @@ export const FreeShipmentViewScreen = () => {
};

const actionsMenu = useCallback(() => {
showActionSheet([
{
title: 'Ввести штрих-код',
onPress: handleShowDialog,
},
{
title: 'Отменить последнее сканирование',
onPress: hanldeCancelLastScan,
},
{
title: 'Редактировать данные',
onPress: handleEditDocHead,
},
{
title: 'Удалить документ',
type: 'destructive',
onPress: handleDelete,
},
{
title: 'Отмена',
type: 'cancel',
onPress: handleFocus,
},
]);
}, [showActionSheet, hanldeCancelLastScan, handleEditDocHead, handleDelete]);
showActionSheet(
isBlocked
? doc?.status === 'SENT'
? [
{
title: 'Копировать документ',
onPress: handleCopyDoc,
},
{
title: 'Отмена',
type: 'cancel',
},
]
: [
{
title: 'Копировать документ',
onPress: handleCopyDoc,
},
{
title: 'Удалить документ',
type: 'destructive',
onPress: handleDelete,
},
{
title: 'Отмена',
type: 'cancel',
},
]
: [
{
title: 'Ввести штрих-код',
onPress: handleShowDialog,
},
{
title: 'Отменить последнее сканирование',
onPress: hanldeCancelLastScan,
},
{
title: 'Редактировать данные',
onPress: handleEditDocHead,
},
{
title: 'Копировать документ',
onPress: handleCopyDoc,
},
{
title: 'Удалить документ',
type: 'destructive',
onPress: handleDelete,
},
{
title: 'Отмена',
type: 'cancel',
onPress: handleFocus,
},
],
);
}, [showActionSheet, isBlocked, doc?.status, handleCopyDoc, handleDelete, hanldeCancelLastScan, handleEditDocHead]);

const handleSaveDocument = useCallback(() => {
if (!doc) {
Expand All @@ -341,12 +406,15 @@ export const FreeShipmentViewScreen = () => {
() =>
isBlocked ? (
doc?.status === 'READY' ? (
<SendButton
onPress={() => setVisibleSendDialog(true)}
disabled={screenState !== 'idle' || loading || !lines?.length}
/>
<View style={styles.buttons}>
<SendButton
onPress={() => setVisibleSendDialog(true)}
disabled={screenState !== 'idle' || loading || !lines?.length}
/>
<MenuButton actionsMenu={actionsMenu} disabled={screenState !== 'idle'} />
</View>
) : (
doc?.status === 'DRAFT' && <SaveDocument onPress={handleSaveDocument} disabled={screenState !== 'idle'} />
<MenuButton actionsMenu={actionsMenu} disabled={screenState !== 'idle'} />
)
) : (
<View style={styles.buttons}>
Expand Down Expand Up @@ -580,9 +648,11 @@ export const FreeShipmentViewScreen = () => {
}, [scanned, ref, visibleDialog]);

useEffect(() => {
if (screenState === 'sent' || screenState === 'deleted') {
if (screenState === 'sent' || screenState === 'deleted' || screenState === 'copied') {
setScreenState('idle');
navigation.goBack();
if (screenState !== 'copied') {
navigation.goBack();
}
}
}, [navigation, screenState]);

Expand All @@ -595,11 +665,17 @@ export const FreeShipmentViewScreen = () => {
return <AppActivityIndicator />;
}

if (screenState === 'deleting' || screenState === 'sending') {
if (screenState === 'deleting' || screenState === 'sending' || screenState === 'copying') {
return (
<View style={styles.container}>
<View style={styles.containerCenter}>
<LargeText>{screenState === 'deleting' ? 'Удаление документа...' : 'Отправка документа...'}</LargeText>
<LargeText>
{screenState === 'deleting'
? 'Удаление документа...'
: screenState === 'copying'
? 'Копирование документа...'
: 'Отправка документа...'}
</LargeText>
<AppActivityIndicator style={{}} />
</View>
</View>
Expand All @@ -626,6 +702,13 @@ export const FreeShipmentViewScreen = () => {
<View style={styles.infoBlock}>
<MediumText>{doc.head.fromDepart?.name || ''}</MediumText>
<MediumText>{`№ ${doc.number} от ${getDateString(doc.documentDate)}`}</MediumText>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)} {new Date(doc.sentDate).toLocaleTimeString()}
</MediumText>
</View>
) : null}
</View>
</InfoBlock>
<LineTypes />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useState, useLayoutEffect, useMemo } from 'react';
import { ListRenderItem, SectionList, SectionListData, View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { useIsFocused, useNavigation } from '@react-navigation/native';

import { documentActions, useDocThunkDispatch, useSelector } from '@lib/store';
import {
Expand All @@ -19,6 +19,7 @@ import {
navBackDrawer,
SimpleDialog,
SendButton,
AppActivityIndicator,
} from '@lib/mobile-ui';

import { StackNavigationProp } from '@react-navigation/stack';
Expand Down Expand Up @@ -73,6 +74,7 @@ export const InventoryListScreen = () => {
subtitle: `№ ${i.number} на ${getDateString(i.documentDate)}` || '',
lineCount: i.lines.length,
errorMessage: i.errorMessage,
sentDate: i.sentDate,
}) as IListItemProps,
);
}, [status, list]);
Expand Down Expand Up @@ -179,6 +181,11 @@ export const InventoryListScreen = () => {
<SubTitle style={[styles.header, styles.sectionTitle]}>{section.title}</SubTitle>
);

const isFocused = useIsFocused();
if (!isFocused) {
return <AppActivityIndicator />;
}

return (
<AppScreen>
<FilterButtons status={status} onPress={setStatus} style={styles.marginBottom5} />
Expand Down
Loading

0 comments on commit 7b7dc2d

Please sign in to comment.