Skip to content

Commit

Permalink
Merge pull request #27 from WilliamCallao/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
WilliamCallao authored Jul 14, 2024
2 parents 7d29f48 + 671d50c commit 8d721e5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 32 deletions.
35 changes: 23 additions & 12 deletions src/screens/NotesScreen/ClientPaymentScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,29 @@ const ClientPaymentScreen = ({ route }) => {
fetchData();
};

const renderItem = ({ item, index }) => (
<Cascading
delay={index > 6 ? 0 : 400 + 80 * index}
animationKey={animationKey}
>
{selectedOption === 'Pendientes' ? (
<NoteItem note={item} onSelect={() => { }} />
) : (
<PaidNoteItem note={item} onEdit={handleEditNote} onDelete={handleDeleteNote} serverDate={serverDate} clientName={itemClient.nombre} />
)}
</Cascading>
);
const renderItem = ({ item, index }) => {
const pendingNote = clientData.notas_pendientes.find(note => note.nro_nota === item.pago_a_nota);

return (
<Cascading
delay={index > 6 ? 0 : 400 + 80 * index}
animationKey={animationKey}
>
{selectedOption === 'Pendientes' ? (
<NoteItem note={item} onSelect={() => { }} />
) : (
<PaidNoteItem
note={item}
pendingNote={pendingNote}
onEdit={handleEditNote}
onDelete={handleDeleteNote}
serverDate={serverDate}
clientName={itemClient.nombre}
/>
)}
</Cascading>
);
};

const keyExtractor = (item, index) => {
return item.nro_nota ? item.nro_nota.toString() : index.toString();
Expand Down
70 changes: 52 additions & 18 deletions src/screens/NotesScreen/PaidNoteItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import { View, StyleSheet, TouchableOpacity, ActivityIndicator, Alert, TextInput } from 'react-native';
import { theme } from '../../assets/Theme';
import StyledText from '../../utils/StyledText';
Expand All @@ -10,9 +10,11 @@ import useNotasCobradasStore from '../../stores/notasCobradasStore';

const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));

const PaidNoteItem = ({ note, onEdit, onDelete, serverDate, clientName }) => {
// console.log("----Client-Payment-Screem----");
const PaidNoteItem = ({ note, pendingNote, onEdit, onDelete, serverDate, clientName }) => {
// console.log("----Paid-Note-Item-Note---");
// console.log(JSON.stringify(note, null, 2));
// console.log("----Paid-Note-Item-PendingNote---");
// console.log(JSON.stringify(pendingNote, null, 2));
const [isModalVisible, setIsModalVisible] = useState(false);
const [isEditModalVisible, setIsEditModalVisible] = useState(false);
const [isProcessing, setIsProcessing] = useState(false);
Expand Down Expand Up @@ -49,7 +51,7 @@ const PaidNoteItem = ({ note, onEdit, onDelete, serverDate, clientName }) => {
pago_a_nota: note.pago_a_nota,
fecha_registro: note.fecha_registro,
nombre_cliente: clientName,
cobrador_id: note.cobrador_id // Ensure cobrador_id is included in the note object
cobrador_id: note.cobrador_id
}
});
if (response.status === 200) {
Expand Down Expand Up @@ -85,7 +87,7 @@ const PaidNoteItem = ({ note, onEdit, onDelete, serverDate, clientName }) => {
monto,
observaciones,
nombre_cliente: clientName,
cobrador_id: note.cobrador_id // Ensure cobrador_id is included in the note object
cobrador_id: note.cobrador_id
});
if (response.status === 200) {
setSuccessMessage('Nota cobrada editada correctamente');
Expand Down Expand Up @@ -124,7 +126,6 @@ const PaidNoteItem = ({ note, onEdit, onDelete, serverDate, clientName }) => {
<StyledText regularText>{note.nro_factura}</StyledText>
</View>
{note.observaciones && note.observaciones.length > 0 && (

<View style={styles.observationsContainer}>
<StyledText regularText>Observaciones:</StyledText>
<StyledText regularText style={styles.observationsText}>{note.observaciones}</StyledText>
Expand Down Expand Up @@ -164,13 +165,13 @@ const PaidNoteItem = ({ note, onEdit, onDelete, serverDate, clientName }) => {
style={[styles.modalButton, { backgroundColor: 'red' }]}
onPress={() => setIsModalVisible(false)}
>
<StyledText style={styles.modalButtonText}>Cancelar</StyledText>
<StyledText regularWhiteText style={styles.modalButtonText}>Cancelar</StyledText>
</TouchableOpacity>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: 'green' }]}
onPress={handleDelete}
>
<StyledText style={styles.modalButtonText}>Confirmar</StyledText>
<StyledText regularWhiteText style={styles.modalButtonText}>Confirmar</StyledText>
</TouchableOpacity>
</View>
</>
Expand All @@ -194,36 +195,50 @@ const PaidNoteItem = ({ note, onEdit, onDelete, serverDate, clientName }) => {
</>
) : (
<>
<StyledText regularBlackText style={styles.modalText}>Editar Nota Cobrada</StyledText>
{true && (
<View style={{marginTop:20, alignItems:'center', marginBottom:15}}>
<View style={styles.textLine}>
<StyledText regularBlackText>Cobro a Nota:</StyledText>
<StyledText regularBlackText> {pendingNote.nro_nota}</StyledText>
</View>
<View style={styles.textLine}>
<StyledText regularBlackText>Saldo Actual:</StyledText>
<StyledText regularBlackText> {pendingNote.saldo_pendiente} Bs</StyledText>
</View>
</View>
)}
<View style={styles.inputContainer}>
<StyledText regularText style={styles.inputLabel}>Monto:</StyledText>
<StyledText regularText style={styles.inputLabel}>Monto Cobrado: (Bs)</StyledText>
<TextInput
style={styles.input}
value={monto}
onChangeText={setMonto}
keyboardType="numeric"
/>
</View>
<View style={styles.inputContainer}>
<StyledText regularText style={styles.inputLabel}>Observaciones:</StyledText>
<View style={styles.inputContainer2}>
<StyledText regularText style={styles.inputLabel2}>Observaciones:</StyledText>
</View>
<View style={styles.inputContainer2}>
<TextInput
style={styles.input}
style={styles.input2}
value={observaciones}
onChangeText={setObservaciones}
maxLength={45}
/>
</View>
<View style={styles.modalButtonContainer}>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: 'red' }]}
onPress={() => setIsEditModalVisible(false)}
>
<StyledText style={styles.modalButtonText}>Cancelar</StyledText>
<StyledText regularWhiteText>Cancelar</StyledText>
</TouchableOpacity>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: 'green' }]}
onPress={handleEdit}
>
<StyledText style={styles.modalButtonText}>Confirmar</StyledText>
<StyledText regularWhiteText>Confirmar</StyledText>
</TouchableOpacity>
</View>
</>
Expand Down Expand Up @@ -314,20 +329,39 @@ const styles = StyleSheet.create({
inputContainer: {
flexDirection: 'row',
alignItems: 'center',
marginVertical: 10,
marginTop: 20,
},
inputLabel: {
flex: 1,
flex: 2,
marginRight: 10,
},
input: {
flex: 2,
flex: 1,
padding: 10,
borderWidth: 1,
borderRadius: 5,
borderColor: theme.colors.secondaryText,
color: theme.colors.black,
},
inputContainer2: {
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'flex-start',
marginVertical: 2,
},
inputLabel2: {
flex: 1,
},
input2: {
padding: 10,
flexDirection: 'row',
flex:1,
borderWidth: 1,
borderRadius: 5,
borderColor: theme.colors.secondaryText,
color: theme.colors.black,
marginBottom:20,
},
observationsContainer: {
flex: 1,
},
Expand Down
10 changes: 8 additions & 2 deletions src/utils/StyledText.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ const styles = StyleSheet.create({
fontSize: regularTextSize,
color: theme.colors.secondaryText,
},
regularBlackText: { // Nuevo estilo
regularWhiteText: {
fontSize: regularTextSize,
alignSelf: 'center',
color: "white",
},
regularBlackText: {
fontSize: regularTextSize,
color: theme.colors.black,
},
Expand Down Expand Up @@ -67,7 +72,7 @@ const styles = StyleSheet.create({
});

const StyledText = ({
children, style, bill, boldCenterText, regularText, boldText, buttonText, boldTextUpper, initial, regularBlackText, regularIntenceText, balance, money, ...rest
children, style, bill, boldCenterText, regularWhiteText, regularText, boldText, buttonText, boldTextUpper, initial, regularBlackText, regularIntenceText, balance, money, ...rest
}) => {
const customStyles = [
regularText && styles.regularText,
Expand All @@ -81,6 +86,7 @@ const StyledText = ({
money && styles.money,
boldCenterText && styles.boldCenterText,
bill && styles.bill,
regularWhiteText && styles.regularWhiteText,
style,
].filter(Boolean);

Expand Down

0 comments on commit 8d721e5

Please sign in to comment.