other means

This commit is contained in:
2023-11-09 05:50:30 +03:00
parent f015090143
commit fc06a86059
32 changed files with 353 additions and 143 deletions

View File

@@ -1,31 +1,21 @@
import {FC} from "react";
import {Props} from "react-native-paper";
import React, {FC, useState} from "react";
import {StyleSheet, View} from "react-native";
import {BottomSheetModalProvider} from "@gorhom/bottom-sheet";
import {useSelector} from "react-redux";
import {RootState} from "../../../redux/store";
import Modal from "react-native-modal";
import {background, blue} from "../../../css/colors";
import {background} from "../../../css/colors";
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
import * as Progress from 'react-native-progress';
import DTitle from "../../DTitle/DTitle";
import {RFPercentage} from "react-native-responsive-fontsize";
const LoadingModal: FC = () => {
const isVisible = useSelector((state: RootState) => state.loadingModal.isVisible);
const loadingText = useSelector((state: RootState) => state.loadingModal.loadingText);
const [ch, sCh] = useState(false);
return (
<Modal isVisible={isVisible}>
<View style={styles.container}>
<DTitle style={{textAlign: "center"}}>{loadingText}</DTitle>
<View style={styles.progressBarWrapper}>
<Progress.Circle size={RFPercentage(20)}
color={blue}
indeterminate={true}
style={styles.progressBar}
borderWidth={responsiveWidth(1)}
/>
</View>
</View>

View File

@@ -5,10 +5,11 @@ import DTitle from "../../DTitle/DTitle";
import DText from "../../DText/DText";
import {RFPercentage} from "react-native-responsive-fontsize";
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
import {Product} from "../../../types/product";
type Props = {
product: SupplierProduct;
onPress: (product: SupplierProduct) => void;
product: Product;
onPress: (product: Product) => void;
}
const SelectProductElement: FC<Props> = React.memo(({product, onPress}) => {
return (
@@ -24,18 +25,7 @@ const SelectProductElement: FC<Props> = React.memo(({product, onPress}) => {
<DText>{product.productName}</DText>
<DText style={{textAlign: "justify"}}>{}</DText>
{product.supplierName &&
<DText>Поставщик: {product.supplierName}</DText>
}
{product.supplierArticle &&
<DText>Артикул: {product.supplierArticle}</DText>
}
{product.inBlock &&
<DText>В блоке: {product.inBlock}</DText>
}
{product.shelfNumber &&
<DText>Номер полки: {product.shelfNumber}</DText>
}
<DText>Артикул DENCO: {product.dencoArticle}</DText>
</View>

View File

@@ -8,11 +8,12 @@ import FlashListSeparator from "../../FlashListSeparator/FlashListSeparator";
import DTitle from "../../DTitle/DTitle";
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
import {background} from "../../../css/colors";
import {Product} from "../../../types/product";
type Props = {
visible: boolean;
products: SupplierProduct[];
onSelected: (product: SupplierProduct) => void
products: Product[];
onSelected: (product: Product) => void
}
@@ -27,7 +28,7 @@ const SelectProductModal: FC<Props> = ({visible, products, onSelected}) => {
data={products}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
keyExtractor={(product) => product.supplierProductId.toString()}
keyExtractor={(product) => product.productId.toString()}
renderItem={(product) => <SelectProductElement product={product.item} onPress={onSelected}/>}
ItemSeparatorComponent={FlashListSeparator}
>

View File

@@ -13,12 +13,11 @@ import DateTimePicker from '@react-native-community/datetimepicker';
import {RootState} from "../../../redux/store";
import {
closeOrdersFilterModal,
OrderStatus,
orderStatuses,
setDesc,
setOrderBy, setShipmentDate, setStatus
setOrderBy, setShipmentDate, setShippingWarehouse, setStatus
} from "../../../features/ordersFilter/ordersFilterSlice";
import {retry} from "@reduxjs/toolkit/query";
import ShippingWarehouseSelect from "../../ShippingWarehouseSelect/ShippingWarehouseSelect";
export type SortingModalHandles = {
present: () => void;
@@ -49,6 +48,8 @@ const createRadioButton = (element: SortingModalElement) => {
const SortingModal = () => {
const state = useSelector((state: RootState) => state.ordersFilter);
const shipmentWarehouseSelectorState = useSelector((state: RootState) => state.shippingWarehouseSelect);
const elements = [
{id: 'createdOnAsc', value: 'createdOnAsc', label: 'Дата создания по возрастанию'},
{id: 'createdOnDesc', value: 'createdOnDesc', label: 'Дата создания по убыванию'},
@@ -73,6 +74,9 @@ const SortingModal = () => {
if (state.isVisible) present();
else dismiss();
}, [state.isVisible]);
useEffect(() => {
dispatch(setShippingWarehouse(shipmentWarehouseSelectorState.selectedShippingWarehouse));
}, [shipmentWarehouseSelectorState.selectedShippingWarehouse]);
return (
<BottomSheetModal
ref={modalRef}
@@ -99,26 +103,26 @@ const SortingModal = () => {
radioButtons={elements.map(createRadioButton)}/>
<View style={{
borderWidth: responsiveWidth(0.1),
borderRadius: responsiveWidth(1)
}}>
<View style={styles.selectors}>
<View style={styles.selector}>
<Picker selectedValue={state.status}
onValueChange={(value, event) => dispatch(setStatus(value))}>
{orderStatuses.map((status) => {
return (
<Picker.Item
key={status.key}
label={status.label}
value={status.key}
style={{fontSize: responsiveWidth(3)}}
/>
)
})}
</Picker>
</View>
<Picker selectedValue={state.status}
onValueChange={(value, event) => dispatch(setStatus(value))}>
{orderStatuses.map((status) => {
return (
<Picker.Item
key={status.key}
label={status.label}
value={status.key}
style={{fontSize: responsiveWidth(3)}}
/>
)
})}
</Picker>
<ShippingWarehouseSelect/>
</View>
<BasicButton onPress={() => setShowShipmentPicker(oldValue => !oldValue)}
label={"Выбрать дату отгрузки"}/>
{showShipmentPicker &&
@@ -162,7 +166,13 @@ const styles = StyleSheet.create({
marginTop: "auto"
},
selectors: {
rowGap: responsiveHeight(1)
},
selector: {
borderWidth: responsiveWidth(0.1),
borderRadius: responsiveWidth(1)
}
});

View File

@@ -14,11 +14,7 @@ const ScanModal: FC = () => {
const visible = useSelector((state: RootState) => state.scanModal.isVisible);
const dispatch = useDispatch();
useEffect(() => {
// if (visible) inputRef.current?.focus();
if (visible){
dispatch(setScannedData('4750735280715'));
dispatch(closeScanModal())
}
if (visible) inputRef.current?.focus();
}, [visible]);
return (
<Modal isVisible={visible}>

View File

@@ -9,17 +9,18 @@ import barcodeApi from "../../api/barcodeApi";
import {useDispatch, useSelector} from "react-redux";
import {openScanModal, setScannedData} from "../../features/scanModal/scanModalSlice";
import {RootState} from "../../redux/store";
import {Product} from "../../types/product";
type Props = {
onSearch?: (text: string) => void;
onSupplierProductSelected?: (supplierProduct: SupplierProduct) => void
onProductSelected?: (product: Product) => void
}
const SearchBar: FC<Props> = ({onSearch, onSupplierProductSelected}) => {
const SearchBar: FC<Props> = ({onSearch, onProductSelected}) => {
const dispatch = useDispatch();
const [searchInput, setSearchInput] = useState<string>("");
const textInputRef = useRef<TextInput>(null);
const [products, setProducts] = useState<SupplierProduct[]>([]);
const [products, setProducts] = useState<Product[]>([]);
const scannedData = useSelector((state: RootState) => state.scanModal.scannedData);
useEffect(() => {
@@ -28,14 +29,22 @@ const SearchBar: FC<Props> = ({onSearch, onSupplierProductSelected}) => {
setProducts(response)
});
}, [scannedData]);
const selectProductModalVisible = products.length > 0;
useEffect(() => {
if (products.length == 0 || products.length > 1 || !onProductSelected) return;
onProductSelected(products[0]);
setProducts([]);
dispatch(setScannedData(undefined));
}, [products]);
const selectProductModalVisible = products.length > 1;
return (
<View style={styles.container}>
<SelectProductModal visible={selectProductModalVisible} products={products} onSelected={(product) => {
if (onSupplierProductSelected) onSupplierProductSelected(product);
setProducts([]);
dispatch(setScannedData(undefined));
}}/>
<SelectProductModal visible={selectProductModalVisible}
products={products}
onSelected={(product) => {
if (onProductSelected) onProductSelected(product);
setProducts([]);
dispatch(setScannedData(undefined));
}}/>
<BasicButton onPress={() => {
if (!onSearch) return;
onSearch(searchInput);

View File

@@ -0,0 +1,44 @@
import {FC, useEffect} from "react";
import {useDispatch, useSelector} from "react-redux";
import {RootState} from "../../redux/store";
import {Picker} from "@react-native-picker/picker";
import generalApi from "../../api/generalApi";
import {
initializeShippingWarehouseSelect,
selectShippingWarehouse
} from "../../features/shippingWarehouseSelect/shippingWarehouseSelectSlice";
import {responsiveWidth} from "react-native-responsive-dimensions";
import {View} from "react-native";
const ShippingWarehouseSelect: FC = () => {
const state = useSelector((state: RootState) => state.shippingWarehouseSelect);
const dispatch = useDispatch();
useEffect(() => {
if (state.initialized) return;
generalApi.getShippingWarehouses().then(shippingWarehouses =>
dispatch(initializeShippingWarehouseSelect(shippingWarehouses)))
}, []);
return (
<View style={{
borderWidth: responsiveWidth(0.1),
borderRadius: responsiveWidth(1)
}}>
<Picker
selectedValue={state.selectedShippingWarehouse?.id}
onValueChange={(value, event) => dispatch(selectShippingWarehouse({shippingWarehouseId: value}))}
>
{state.shippingWarehouses.map(shippingWarehouse => (
<Picker.Item
key={shippingWarehouse.id}
label={shippingWarehouse.name}
value={shippingWarehouse.id}
style={{fontSize: responsiveWidth(3)}}
/>
))}
</Picker>
</View>
)
}
export default ShippingWarehouseSelect