tell me other things
This commit is contained in:
@@ -5,8 +5,8 @@ import {logout} from "../features/auth/authSlice";
|
||||
import {store} from "../redux/store";
|
||||
|
||||
const apiClient = axios.create({
|
||||
// baseURL: 'https://assemblr.denco.store',
|
||||
baseURL: 'http://192.168.1.101:5000',
|
||||
baseURL: 'https://assemblr.denco.store',
|
||||
// baseURL: 'http://192.168.1.101:5000',
|
||||
});
|
||||
|
||||
apiClient.interceptors.request.use(async (config) => {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import apiClient from "./apiClient";
|
||||
import {Order} from "../types/order";
|
||||
import * as inspector from "inspector";
|
||||
import {OrderStatus} from "../features/ordersFilter/ordersFilterSlice";
|
||||
import {ShippingWarehouse} from "../types/shippingWarehouse";
|
||||
|
||||
const router = '/orders';
|
||||
|
||||
@@ -17,8 +19,20 @@ const ordersApi = {
|
||||
let response = await apiClient.get(`${router}/getOrders`, {params})
|
||||
return response.data;
|
||||
},
|
||||
getOrdersByProduct: async (productId: number): Promise<Order[]> => {
|
||||
let response = await apiClient.get(`${router}/getByProductId?productId=${productId}`);
|
||||
getOrdersByProduct: async (params: {
|
||||
productId: number,
|
||||
orderBy: "createdOn" | "shipmentDate",
|
||||
desc: boolean,
|
||||
status: OrderStatus,
|
||||
shipmentDate: string,
|
||||
shippingWarehouse: ShippingWarehouse
|
||||
}): Promise<Order[]> => {
|
||||
let response = await apiClient.get(`${router}/getByProductId`, {
|
||||
params: {
|
||||
...params,
|
||||
shippingWarehouse: params.shippingWarehouse.id
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
getOrderById: async (orderId: number): Promise<Order> => {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 40 KiB |
BIN
src/assets/icons/filter.png
Normal file
BIN
src/assets/icons/filter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@@ -40,6 +40,9 @@ const OrderCard: FC<Props> = ({onPress, onSelect, order}) => {
|
||||
<DText>Селлер: {order.sellerName}</DText>
|
||||
<DText>Маркетплейс: {order.marketplaceName}</DText>
|
||||
<DText>Товаров в заказе: {order.products.length}</DText>
|
||||
<DText>Создан: {order.createdOn}</DText>
|
||||
<DText>Отгрузка: {order.shipmentDate}</DText>
|
||||
|
||||
</View>
|
||||
<View style={styles.descriptionStatus}>
|
||||
<DText>
|
||||
|
||||
@@ -12,10 +12,11 @@ const SortingButton: FC<Props> = ({onPress}) => {
|
||||
return (
|
||||
<TouchableOpacity onPress={onPress}>
|
||||
<View style={styles.container}>
|
||||
|
||||
<View style={styles.imageWrapper}>
|
||||
<Image style={styles.image} source={require('assets/icons/sorting.png')}/>
|
||||
<Image style={styles.image} source={require('assets/icons/filter.png')}/>
|
||||
</View>
|
||||
<DText>Сортировка</DText>
|
||||
<DText>Фильтр</DText>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -27,7 +28,7 @@ const styles = StyleSheet.create({
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
columnGap: responsiveWidth(1)
|
||||
columnGap: responsiveWidth(1),
|
||||
},
|
||||
imageWrapper: {
|
||||
width: RFPercentage(3),
|
||||
|
||||
@@ -51,7 +51,6 @@ export const assembly = createSlice({
|
||||
},
|
||||
confirmAssembly: (state) => {
|
||||
if (!state.assembly) return;
|
||||
|
||||
state.assembly.state = ASSEMBLY_STATE.CONFIRMED;
|
||||
state.localState = ASSEMBLY_STATE.CONFIRMED;
|
||||
},
|
||||
|
||||
@@ -50,7 +50,7 @@ export interface OrdersFilterState {
|
||||
const initialState: OrdersFilterState = {
|
||||
isVisible: false,
|
||||
orderBy: "shipmentDate",
|
||||
desc: true,
|
||||
desc: false,
|
||||
shipmentDate: (new Date()).toISOString(),
|
||||
status: OrderStatus.AWAITING_PACKAGING,
|
||||
page: 0,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {Button, StyleSheet, Text, View} from "react-native";
|
||||
import {useAppDispatch} from "../../redux/store";
|
||||
import {RootState, useAppDispatch} from "../../redux/store";
|
||||
import * as process from "process";
|
||||
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
|
||||
import SearchBar from "../../components/SearchBar/SearchBar";
|
||||
import {useDispatch} from "react-redux";
|
||||
import {NavigationProp, useNavigation} from "@react-navigation/native";
|
||||
import {useDispatch, useSelector} from "react-redux";
|
||||
import {NavigationProp, useFocusEffect, useNavigation, useNavigationState} from "@react-navigation/native";
|
||||
import {TabNavigatorParamList} from "../MainScreen/MainScreen";
|
||||
import {FlashList} from "@shopify/flash-list";
|
||||
import {Order} from "../../types/order";
|
||||
@@ -15,23 +15,41 @@ 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";
|
||||
|
||||
function BarcodeScreen() {
|
||||
const dispatch = useDispatch();
|
||||
const navigator = useNavigation<NavigationProp<TabNavigatorParamList, 'Home'>>();
|
||||
const [orders, setOrders] = useState<Order[]>([]);
|
||||
const [productId, setProductId] = useState(-1);
|
||||
const {orders, isUpdating} = useBarcodeOrders({productId});
|
||||
|
||||
const isScanModalVisible = useSelector((state: RootState) => state.scanModal.isVisible);
|
||||
const navigator = useNavigation<NavigationProp<TabNavigatorParamList, 'Home'>>();
|
||||
const navigationState = useNavigationState((state) => state);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(openScanModal());
|
||||
}, []);
|
||||
console.log("state changed")
|
||||
if (!navigationState.history) return;
|
||||
// @ts-ignore
|
||||
let currentTabKey: string = navigationState.history[navigationState.history.length - 1].key;
|
||||
if (currentTabKey.startsWith("Barcode")) if (!isScanModalVisible) dispatch(openScanModal());
|
||||
}, [navigationState]);
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<SearchBar onProductSelected={product => {
|
||||
ordersApi.getOrdersByProduct(product.productId).then(setOrders)
|
||||
setProductId(product.productId);
|
||||
}}/>
|
||||
<SortingButton onPress={() => {
|
||||
dispatch(openOrdersFilterModal());
|
||||
}}
|
||||
/>
|
||||
<View style={styles.content}>
|
||||
{orders.length > 0 ? <FlashList
|
||||
{orders.length > 0 || isUpdating ? <FlashList
|
||||
refreshing={isUpdating}
|
||||
onRefresh={() => {
|
||||
}}
|
||||
keyboardShouldPersistTaps={"never"}
|
||||
data={orders}
|
||||
keyExtractor={(item: Order) => item.orderNumber.toString()}
|
||||
|
||||
47
src/screens/BarcodeScreen/useBarcodeOrders.tsx
Normal file
47
src/screens/BarcodeScreen/useBarcodeOrders.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import {useSelector} from "react-redux";
|
||||
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;
|
||||
}
|
||||
const useBarcodeOrders = (props: Props) => {
|
||||
const [orders, setOrders] = useState<Order[]>([]);
|
||||
const [isUpdating, setIsUpdating] = useState(false);
|
||||
const {productId} = props;
|
||||
const {
|
||||
orderBy,
|
||||
isVisible,
|
||||
desc,
|
||||
shipmentDate,
|
||||
status,
|
||||
shippingWarehouse
|
||||
} = useSelector((state: RootState) => state.ordersFilter);
|
||||
const fetchOrders = async (): Promise<Order[]> => {
|
||||
return ordersApi.getOrdersByProduct({productId, orderBy, shipmentDate, status, shippingWarehouse, desc});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (isVisible || productId < 0) return;
|
||||
setOrders([]);
|
||||
setIsUpdating(true);
|
||||
fetchOrders().then((fetchedOrders) => {
|
||||
setOrders(fetchedOrders);
|
||||
setIsUpdating(false);
|
||||
});
|
||||
}, [
|
||||
productId,
|
||||
isVisible,
|
||||
desc,
|
||||
orderBy,
|
||||
shipmentDate,
|
||||
status,
|
||||
shippingWarehouse]);
|
||||
|
||||
return {orders, isUpdating}
|
||||
}
|
||||
|
||||
export default useBarcodeOrders;
|
||||
@@ -99,7 +99,7 @@ function MainScreen() {
|
||||
name: tabScreen.name,
|
||||
component: tabScreen.component,
|
||||
icon: tabScreen.icon,
|
||||
hidden: tabScreen.hidden
|
||||
hidden: tabScreen.hidden,
|
||||
})}/>
|
||||
)}
|
||||
</Tab.Navigator>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {View, Image, StyleSheet, TouchableOpacity} from "react-native";
|
||||
import {View, Image, StyleSheet, TouchableOpacity, ScrollView} from "react-native";
|
||||
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
|
||||
import DText from "../../components/DText/DText";
|
||||
import {RFPercentage} from "react-native-responsive-fontsize";
|
||||
@@ -8,7 +8,7 @@ import React, {FC, useEffect, useState} from "react";
|
||||
import {useDispatch, useSelector} from "react-redux";
|
||||
import {RootState} from "../../redux/store";
|
||||
import {closeLoadingModal, openLoadingModal, setLoadingText} from "../../features/loadingModal/loadingModalSlice";
|
||||
import {useNavigation} from "@react-navigation/native";
|
||||
import {NavigationProp, useNavigation} from "@react-navigation/native";
|
||||
import printingApi from "../../api/printingApi";
|
||||
import PrintingService from "../../utils/PrintingService";
|
||||
import OrderProductsList from "../../components/OrderCard/OrderProductsList";
|
||||
@@ -31,7 +31,7 @@ import {RenderTargetOptions} from "@shopify/flash-list";
|
||||
import {createOnShouldStartLoadWithRequest} from "react-native-webview/lib/WebViewShared";
|
||||
import assemblyApi from "../../api/assemblyApi";
|
||||
import Toast from "react-native-toast-message";
|
||||
import mainScreen from "../MainScreen/MainScreen";
|
||||
import mainScreen, {TabNavigatorParamList} from "../MainScreen/MainScreen";
|
||||
import toast from "../../components/Toast/Toast";
|
||||
import {openImageZoomModal, setImages} from "../../features/imageZoomModal/loadingModalSlice";
|
||||
|
||||
@@ -42,16 +42,11 @@ type AssemblyPeriod = {
|
||||
}
|
||||
|
||||
const NoOrderScreen: FC = () => {
|
||||
|
||||
|
||||
return (
|
||||
<View style={noOrderStyles.container}>
|
||||
<DText style={noOrderStyles.title}>Заказ не выбран!</DText>
|
||||
<View style={noOrderStyles.buttonWrapper}>
|
||||
<BasicButton onPress={() => {
|
||||
// @ts-ignore
|
||||
navigator.navigate("Box");
|
||||
}} label={"На главную"}/>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -74,7 +69,8 @@ type OrderScreenProps = {
|
||||
order: Order;
|
||||
}
|
||||
const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
const navigator = useNavigation();
|
||||
const navigator = useNavigation<NavigationProp<TabNavigatorParamList, 'Barcode'>>();
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const assembly = useSelector((state: RootState) => state.assembly.assembly);
|
||||
const assemblyState = useSelector((state: RootState) => state.assembly.localState);
|
||||
@@ -96,7 +92,6 @@ const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
})
|
||||
if (ok) {
|
||||
dispatch(confirmAssembly());
|
||||
|
||||
} else {
|
||||
setSkipConfirmButtonVisible(true);
|
||||
}
|
||||
@@ -109,7 +104,6 @@ const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
onPress={() => setAcceptModalVisible(true)}
|
||||
label={"Начать сборку"}/>)
|
||||
case ASSEMBLY_STATE.ASSEMBLING_PRODUCTS:
|
||||
|
||||
return (<BasicButton
|
||||
containerStyle={styles.buttonContainer}
|
||||
label={"Отметить как собранный"}
|
||||
@@ -142,7 +136,6 @@ const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
case ASSEMBLY_STATE.CONFIRMED:
|
||||
return (
|
||||
<>
|
||||
|
||||
<BasicButton
|
||||
onPress={() => printLabel()}
|
||||
containerStyle={styles.buttonContainer}
|
||||
@@ -161,6 +154,7 @@ const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
text2: message
|
||||
});
|
||||
dispatch(endAssembly());
|
||||
navigator.navigate('Barcode');
|
||||
})
|
||||
}}/>
|
||||
</>
|
||||
@@ -201,7 +195,17 @@ const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
text2: 'Неудалось обновить состояние текущей сборки на сервере'
|
||||
})
|
||||
});
|
||||
|
||||
switch (assemblyState) {
|
||||
case ASSEMBLY_STATE.CONFIRMED:
|
||||
printLabel();
|
||||
break;
|
||||
case ASSEMBLY_STATE.ASSEMBLING_PRODUCTS:
|
||||
if (!selectedProduct) return;
|
||||
if (order.products.length == 1) {
|
||||
dispatch(setAssembled({orderProductId: selectedProduct.databaseId}));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, [assemblyState]);
|
||||
useEffect(() => {
|
||||
if (!order) return;
|
||||
@@ -230,17 +234,20 @@ const OrderScreen: FC<OrderScreenProps> = ({order}) => {
|
||||
</View>
|
||||
<View style={styles.contentContainer}>
|
||||
<View style={styles.dataContainer}>
|
||||
<DTitle style={styles.contentTitle}>Заказ</DTitle>
|
||||
<DText>Номер заказа: {order.orderNumber}</DText>
|
||||
<DText>Маркетплейс: {order.marketplaceName}</DText>
|
||||
<DText>Селлер: {order.sellerName}</DText>
|
||||
<DText>{}</DText>
|
||||
<DTitle style={styles.contentTitle}>Товар</DTitle>
|
||||
<DText>Артикул DENCO: {selectedProduct?.dencoArticle}</DText>
|
||||
<DText>Поставщик: {selectedProduct?.supplierName}</DText>
|
||||
<DText>Номер товара: {0}</DText>
|
||||
{/*<DText>{}</DText>*/}
|
||||
{/*<DTitle style={styles.contentTitle}>Сборка</DTitle>*/}
|
||||
<ScrollView>
|
||||
<DTitle style={styles.contentTitle}>Заказ</DTitle>
|
||||
<DText>Номер заказа: {order.orderNumber}</DText>
|
||||
<DText>Маркетплейс: {order.marketplaceName}</DText>
|
||||
<DText>Селлер: {order.sellerName}</DText>
|
||||
<DText>Создан: {order.createdOn}</DText>
|
||||
<DText>Отгрузка: {order.shipmentDate}</DText>
|
||||
<DText>{}</DText>
|
||||
<DTitle style={styles.contentTitle}>Товар</DTitle>
|
||||
<DText>Арт. DENCO: {selectedProduct?.dencoArticle}</DText>
|
||||
<DText>Арт. поставщика: {selectedProduct?.supplierArticle}</DText>
|
||||
<DText>Фасовка: {selectedProduct?.inBlock} шт.</DText>
|
||||
<DText>Поставщик: {selectedProduct?.supplierName}</DText>
|
||||
</ScrollView>
|
||||
|
||||
</View>
|
||||
<View style={styles.buttonsContainer}>
|
||||
|
||||
@@ -6,8 +6,8 @@ export type OrderProduct = {
|
||||
assembled: boolean;
|
||||
shipped: boolean
|
||||
imageUrl: string;
|
||||
|
||||
|
||||
supplierArticle: string;
|
||||
inBlock: number;
|
||||
};
|
||||
|
||||
export enum BaseMarketplace {
|
||||
@@ -24,5 +24,7 @@ export type Order = {
|
||||
sellerName: string;
|
||||
products: OrderProduct[];
|
||||
status: number;
|
||||
shipmentDate: string;
|
||||
createdOn: string;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user