ebanutsya
This commit is contained in:
@@ -3,6 +3,7 @@ import {StyleSheet, TouchableOpacity, Text, View, StyleProp, ViewStyle, GestureR
|
||||
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
|
||||
import {RFPercentage} from "react-native-responsive-fontsize";
|
||||
import DText from "../DText/DText";
|
||||
import DTitle from "../DTitle/DTitle";
|
||||
|
||||
type Props = {
|
||||
label: string;
|
||||
@@ -15,10 +16,11 @@ type Props = {
|
||||
|
||||
const BasicButton: FC<Props> = ({label, onPress, containerStyle, style, isUnset = false, disabled = false}) => {
|
||||
return (
|
||||
<TouchableOpacity style={{flex: 1}} disabled={disabled} onPress={onPress}>
|
||||
|
||||
<View style={[styles.container, style, disabled ? {backgroundColor: "#A0A0A0"} : {}]}>
|
||||
<DText style={styles.text}>{label}</DText>
|
||||
<TouchableOpacity style={containerStyle} disabled={disabled} onPress={onPress}>
|
||||
<View style={[styles.container, style, disabled ? {backgroundColor: "#A0A0A0"} : {}, containerStyle]}>
|
||||
<View style={styles.textWrapper}>
|
||||
<DText style={styles.text}>{label}</DText>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
</TouchableOpacity>
|
||||
@@ -33,15 +35,15 @@ const styles = StyleSheet.create({
|
||||
alignContent: "center",
|
||||
backgroundColor: '#2478F8',
|
||||
borderRadius: responsiveWidth(1),
|
||||
padding: responsiveWidth(2),
|
||||
flex: 1
|
||||
padding: responsiveWidth(3),
|
||||
},
|
||||
text: {
|
||||
color: "white",
|
||||
fontSize: RFPercentage(2),
|
||||
textAlignVertical: "center",
|
||||
textAlign: "center"
|
||||
}
|
||||
textAlign: "center",
|
||||
},
|
||||
textWrapper: {}
|
||||
});
|
||||
|
||||
export default BasicButton;
|
||||
65
src/components/Modals/AcceptModal/AcceptModal.tsx
Normal file
65
src/components/Modals/AcceptModal/AcceptModal.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import {FC} 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 {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";
|
||||
import BasicButton from "../../BasicButton/BasicButton";
|
||||
|
||||
type Props = {
|
||||
visible: boolean;
|
||||
text: string;
|
||||
onAccepted: () => void;
|
||||
onRefused: () => void;
|
||||
}
|
||||
const AcceptModal: FC<Props> = ({visible, text, onAccepted, onRefused}) => {
|
||||
|
||||
return (
|
||||
<Modal isVisible={visible}>
|
||||
<View style={styles.container}>
|
||||
<DTitle style={{textAlign: "center"}}>{text}</DTitle>
|
||||
<View style={styles.buttonsWrapper}>
|
||||
<BasicButton style={[styles.button, styles.acceptButton]} label={"Да"}
|
||||
onPress={() => onAccepted()}/>
|
||||
<BasicButton style={[styles.button, styles.refuseButton]} label={"Нет"}
|
||||
onPress={() => onRefused()}/>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
alignSelf: "center",
|
||||
backgroundColor: background,
|
||||
width: responsiveWidth(80),
|
||||
height: responsiveHeight(50),
|
||||
borderRadius: responsiveWidth(2),
|
||||
paddingHorizontal: responsiveWidth(15),
|
||||
paddingVertical: responsiveHeight(10),
|
||||
justifyContent: "center",
|
||||
rowGap: responsiveHeight(5)
|
||||
},
|
||||
buttonsWrapper: {
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
},
|
||||
progressBar: {
|
||||
justifyContent: "center"
|
||||
},
|
||||
button: {
|
||||
paddingHorizontal: responsiveWidth(8)
|
||||
},
|
||||
acceptButton: {},
|
||||
refuseButton: {
|
||||
backgroundColor: "red"
|
||||
},
|
||||
})
|
||||
export default AcceptModal;
|
||||
37
src/components/Modals/ReprintModal/ReprintModal.tsx
Normal file
37
src/components/Modals/ReprintModal/ReprintModal.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import {FC, useState} from "react";
|
||||
import AcceptModal from "../AcceptModal/AcceptModal";
|
||||
import PrintingService from "../../../utils/PrintingService";
|
||||
import {useDispatch, useSelector} from "react-redux";
|
||||
import {RootState} from "../../../redux/store";
|
||||
import {closeReprintModal, openReprintModal} from "../../../features/reprintModal/reprintModalSlice";
|
||||
import PrintingApi from "../../../api/printingApi";
|
||||
import {closeLoadingModal, openLoadingModal} from "../../../features/loadingModal/loadingModalSlice";
|
||||
|
||||
|
||||
const ReprintModal: FC = () => {
|
||||
const printerName = useSelector((state: RootState) => state.printing.printerName);
|
||||
const order = useSelector((state: RootState) => state.assembly.order);
|
||||
const isVisible = useSelector((state: RootState) => state.reprintModal.isVisible);
|
||||
const dispatch = useDispatch();
|
||||
return (<AcceptModal
|
||||
visible={isVisible}
|
||||
text={"Неудалось распечатать этикетку, повторить попытку?"}
|
||||
onAccepted={() => {
|
||||
if (!printerName || !order) return;
|
||||
dispatch(closeReprintModal());
|
||||
dispatch(openLoadingModal());
|
||||
PrintingApi.getLabel(order.databaseId).then(pdfBytes => {
|
||||
PrintingService.getInstance().printPdf(printerName, pdfBytes).then(r => {
|
||||
dispatch(closeLoadingModal());
|
||||
if (r) dispatch(closeReprintModal());
|
||||
else dispatch(openReprintModal());
|
||||
});
|
||||
})
|
||||
}}
|
||||
onRefused={() => {
|
||||
dispatch(closeReprintModal())
|
||||
dispatch(closeLoadingModal());
|
||||
}}/>)
|
||||
}
|
||||
|
||||
export default ReprintModal;
|
||||
@@ -6,18 +6,20 @@ import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensi
|
||||
import DTitle from "../DTitle/DTitle";
|
||||
import {Order} from "../../types/order";
|
||||
import OrderProductsList from "./OrderProductsList";
|
||||
import {useDispatch} from "react-redux";
|
||||
import {setOrder} from "../../features/assembly/assemblySlice";
|
||||
|
||||
type Props = {
|
||||
onPress?: (event: GestureResponderEvent) => void
|
||||
onSelect: (order: Order) => void
|
||||
order: Order
|
||||
onSelect: (order: Order) => void
|
||||
|
||||
}
|
||||
const OrderCard: FC<Props> = React.memo(({onPress, onSelect, order}) => {
|
||||
|
||||
const OrderCard: FC<Props> = ({onPress, onSelect, order}) => {
|
||||
return (
|
||||
<TouchableOpacity onPress={() => {
|
||||
onSelect(order);
|
||||
<TouchableOpacity onPress={()=>{
|
||||
if (onSelect) onSelect(order);
|
||||
|
||||
}}>
|
||||
<View style={styles.container}><View style={styles.description}>
|
||||
<View style={styles.descriptionContent}>
|
||||
@@ -28,6 +30,7 @@ const OrderCard: FC<Props> = React.memo(({onPress, onSelect, order}) => {
|
||||
</View>
|
||||
<DText>Селлер: {order.sellerName}</DText>
|
||||
<DText>Маркетплейс: {order.marketplaceName}</DText>
|
||||
<DText>Товаров в заказе: {order.products.length}</DText>
|
||||
</View>
|
||||
<View style={styles.descriptionStatus}>
|
||||
<DText>
|
||||
@@ -40,13 +43,12 @@ const OrderCard: FC<Props> = React.memo(({onPress, onSelect, order}) => {
|
||||
</TouchableOpacity>
|
||||
|
||||
)
|
||||
})
|
||||
}
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: "white",
|
||||
display: "flex",
|
||||
borderRadius: RFPercentage(3),
|
||||
height: responsiveHeight(15),
|
||||
flexDirection: "row",
|
||||
padding: RFPercentage(2),
|
||||
flex: 1
|
||||
@@ -80,7 +82,6 @@ const styles = StyleSheet.create({
|
||||
marginLeft: responsiveHeight(1)
|
||||
},
|
||||
descriptionContent: {
|
||||
// backgroundColor: "green",
|
||||
flex: 1
|
||||
},
|
||||
descriptionStatus: {
|
||||
|
||||
@@ -14,9 +14,12 @@ const ScanModal: FC = () => {
|
||||
const visible = useSelector((state: RootState) => state.scanModal.isVisible);
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
if (visible) inputRef.current?.focus();
|
||||
// if (visible) inputRef.current?.focus();
|
||||
if (visible){
|
||||
dispatch(setScannedData('4750735280715'));
|
||||
dispatch(closeScanModal())
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
return (
|
||||
<Modal isVisible={visible}>
|
||||
<View style={styles.container}>
|
||||
|
||||
@@ -25,10 +25,12 @@ const SearchBar: FC<Props> = ({onSearch, onSupplierProductSelected}) => {
|
||||
const scannedData = useSelector((state: RootState) => state.scanModal.scannedData);
|
||||
useEffect(() => {
|
||||
if (!scannedData) return;
|
||||
barcodeApi.searchProducts(scannedData).then(setProducts);
|
||||
barcodeApi.searchProducts(scannedData).then((response) => {
|
||||
console.log("Response: " + response);
|
||||
setProducts(response)
|
||||
});
|
||||
}, [scannedData]);
|
||||
|
||||
const selectProductModalVisible = products.length > 0 && false;
|
||||
const selectProductModalVisible = products.length > 0;
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
|
||||
@@ -74,6 +76,7 @@ const styles = StyleSheet.create({
|
||||
borderRadius: 0,
|
||||
borderTopRightRadius: responsiveWidth(1),
|
||||
borderBottomRightRadius: responsiveWidth(1),
|
||||
paddingHorizontal: responsiveWidth(5)
|
||||
},
|
||||
scanImageWrapper: {
|
||||
paddingHorizontal: responsiveWidth(1),
|
||||
@@ -85,14 +88,13 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
textInput: {
|
||||
height: responsiveHeight(height),
|
||||
flex: 2,
|
||||
flex: 1,
|
||||
borderWidth: 1,
|
||||
borderColor: "#A5A5A5",
|
||||
borderTopLeftRadius: responsiveWidth(1),
|
||||
borderBottomLeftRadius: responsiveWidth(1),
|
||||
paddingLeft: responsiveHeight(2),
|
||||
fontSize: RFPercentage(2),
|
||||
// fontFamily: 'SF Pro Text'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user