feat: add confirmCurrent method to assemblyApi and enhance BarcodeScreen functionality
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import apiClient from "./apiClient";
|
||||
import {Assembly} from "../types/assembly";
|
||||
import {closeCancelAssemblyModal} from "../features/cancelAssemblyModal/cancelAssemblyModalSlice";
|
||||
|
||||
const router = '/assembly';
|
||||
export type CreateAssemblyResponse = {
|
||||
@@ -39,6 +38,10 @@ const assemblyApi = {
|
||||
let response = await apiClient.post(`${router}/confirm`, {assemblyId});
|
||||
return response.data;
|
||||
},
|
||||
confirmCurrent: async (): Promise<{ ok: boolean, message: string }> => {
|
||||
let response = await apiClient.post(`${router}/confirmCurrent`);
|
||||
return response.data;
|
||||
},
|
||||
cancelById: async (assemblyId: number): Promise<{ ok: boolean, message: string }> => {
|
||||
let response = await apiClient.post(`${router}/cancelById`, {assemblyId});
|
||||
return response.data;
|
||||
|
||||
BIN
src/assets/icons/settings/check.png
Normal file
BIN
src/assets/icons/settings/check.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -221,9 +221,7 @@ const ConfirmedButtons = () => {
|
||||
dispatch(showReward({reward}));
|
||||
dispatch(fetchBalance())
|
||||
dispatch(refreshTransactions())
|
||||
|
||||
}
|
||||
|
||||
dispatch(endAssembly());
|
||||
navigator.navigate('Barcode');
|
||||
})
|
||||
|
||||
@@ -11,7 +11,6 @@ import AssemblyControls from "./AssemblyControls";
|
||||
import AcceptAssemblyModal from "./AcceptAssemblyModal";
|
||||
import assemblyApi, {CreateAssemblyResponse} from "../../api/assemblyApi";
|
||||
import {setAssembly, startAssembly} from "../../features/assembly/assemblySlice";
|
||||
import {ScanCrptContextProvider} from "./contexts/ScanCrptContext";
|
||||
|
||||
type Props = {
|
||||
order: Order;
|
||||
@@ -32,7 +31,8 @@ const AssemblyView = (props: Props) => {
|
||||
<View style={styles.viewContainer}>
|
||||
<View style={styles.topSection}>
|
||||
<AssemblyProductSelect order={order}/>
|
||||
<ProductImageView imageUrl={state.selectedProduct?.imageUrl}/>
|
||||
<ProductImageView
|
||||
imageUrl={state.selectedProduct ? state.selectedProduct.imageUrl : order.products[0].imageUrl}/>
|
||||
</View>
|
||||
<View style={styles.bottomSection}>
|
||||
<OrderInfoView
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import {Button, StyleSheet, Text, View} from "react-native";
|
||||
import {RootState, useAppDispatch} from "../../redux/store";
|
||||
import * as process from "process";
|
||||
import {StyleSheet, View} from "react-native";
|
||||
import {RootState} from "../../redux/store";
|
||||
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
|
||||
import SearchBar from "../../components/SearchBar/SearchBar";
|
||||
import {useDispatch, useSelector} from "react-redux";
|
||||
import {NavigationProp, useFocusEffect, useNavigation, useNavigationState} from "@react-navigation/native";
|
||||
import {NavigationProp, useNavigation, useNavigationState} from "@react-navigation/native";
|
||||
import {TabNavigatorParamList} from "../MainScreen/MainScreen";
|
||||
import {FlashList} from "@shopify/flash-list";
|
||||
import {Order} from "../../types/order";
|
||||
@@ -13,9 +12,7 @@ import {setOrder} from "../../features/assembly/assemblySlice";
|
||||
import flashListSeparator from "../../components/FlashListSeparator/FlashListSeparator";
|
||||
import {useEffect, useState} from "react";
|
||||
import {openScanModal} from "../../features/scanModal/scanModalSlice";
|
||||
import ordersApi from "../../api/ordersApi";
|
||||
import DTitle from "../../components/DTitle/DTitle";
|
||||
import {useNormalizedSnapPoints} from "@gorhom/bottom-sheet/lib/typescript/hooks";
|
||||
import SortingButton from "../../components/SortingButton/SortingButton";
|
||||
import useBarcodeOrders from "./useBarcodeOrders";
|
||||
import {openOrdersFilterModal} from "../../features/ordersFilter/ordersFilterSlice";
|
||||
@@ -23,15 +20,17 @@ import {openOrdersFilterModal} from "../../features/ordersFilter/ordersFilterSli
|
||||
function BarcodeScreen() {
|
||||
const dispatch = useDispatch();
|
||||
const [productId, setProductId] = useState(-1);
|
||||
const {orders, isUpdating} = useBarcodeOrders({productId});
|
||||
const {orders, isUpdating,refresh} = useBarcodeOrders({productId});
|
||||
|
||||
const isScanModalVisible = useSelector((state: RootState) => state.scanModal.isVisible);
|
||||
const navigator = useNavigation<NavigationProp<TabNavigatorParamList, 'Home'>>();
|
||||
const navigationState = useNavigationState((state) => state);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("state changed")
|
||||
if (!navigationState.history) return;
|
||||
if (productId < 0) return;
|
||||
console.log('refreshing orders for productId:', productId);
|
||||
refresh();
|
||||
// @ts-ignore
|
||||
let currentTabKey: string = navigationState.history[navigationState.history.length - 1].key;
|
||||
if (currentTabKey.startsWith("Barcode")) if (!isScanModalVisible) dispatch(openScanModal({}));
|
||||
@@ -49,6 +48,7 @@ function BarcodeScreen() {
|
||||
{orders.length > 0 || isUpdating ? <FlashList
|
||||
refreshing={isUpdating}
|
||||
onRefresh={() => {
|
||||
refresh()
|
||||
}}
|
||||
keyboardShouldPersistTaps={"never"}
|
||||
data={orders}
|
||||
|
||||
@@ -3,8 +3,6 @@ import {RootState} from "../../redux/store";
|
||||
import {useEffect, useState} from "react";
|
||||
import {Order} from "../../types/order";
|
||||
import ordersApi from "../../api/ordersApi";
|
||||
import {setOrderBy} from "../../features/ordersFilter/ordersFilterSlice";
|
||||
import {setOrder} from "../../features/assembly/assemblySlice";
|
||||
|
||||
export type Props = {
|
||||
productId: number;
|
||||
@@ -25,14 +23,17 @@ const useBarcodeOrders = (props: Props) => {
|
||||
const fetchOrders = async (): Promise<Order[]> => {
|
||||
return ordersApi.getOrdersByProduct({productId, orderBy, shipmentDate, status, shippingWarehouse, city, desc});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (isVisible || productId < 0) return;
|
||||
const refresh = () => {
|
||||
setOrders([]);
|
||||
setIsUpdating(true);
|
||||
fetchOrders().then((fetchedOrders) => {
|
||||
setOrders(fetchedOrders);
|
||||
setIsUpdating(false);
|
||||
});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (isVisible || productId < 0) return;
|
||||
refresh()
|
||||
}, [
|
||||
productId,
|
||||
isVisible,
|
||||
@@ -40,9 +41,14 @@ const useBarcodeOrders = (props: Props) => {
|
||||
orderBy,
|
||||
shipmentDate,
|
||||
status,
|
||||
shippingWarehouse]);
|
||||
shippingWarehouse,
|
||||
]);
|
||||
|
||||
return {orders, isUpdating}
|
||||
return {
|
||||
orders,
|
||||
refresh,
|
||||
isUpdating
|
||||
}
|
||||
}
|
||||
|
||||
export default useBarcodeOrders;
|
||||
@@ -37,9 +37,6 @@ const SettingsView: FC = () => {
|
||||
showsHorizontalScrollIndicator={false}
|
||||
contentContainerStyle={styles.actionsCarousel}
|
||||
>
|
||||
<SettingsElement icon={require('assets/icons/settings/withdraw.png')} title={'Вывод'}/>
|
||||
<SettingsElement icon={require('assets/icons/settings/statistics.png')} title={'Статистика'}/>
|
||||
<SettingsElement icon={require('assets/icons/settings/printer.png')} title={'Принтеры'}/>
|
||||
<SettingsElement onPress={() => {
|
||||
assemblyApi.cancel().then(response => {
|
||||
|
||||
@@ -51,6 +48,17 @@ const SettingsView: FC = () => {
|
||||
dispatch(reset());
|
||||
})
|
||||
}} icon={require('assets/icons/settings/close.png')} title={'Отменить сборку'}/>
|
||||
<SettingsElement onPress={() => {
|
||||
assemblyApi.confirmCurrent().then(response => {
|
||||
|
||||
Toast.show({
|
||||
type: response.ok ? "success" : "error",
|
||||
text1: "Закрытие сборки",
|
||||
text2: response.message,
|
||||
});
|
||||
dispatch(reset());
|
||||
})
|
||||
}} icon={require('assets/icons/settings/check.png')} title={'Закрыть сборку'}/>
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user