correction anomalies

This commit is contained in:
Rochas
2025-12-13 22:51:09 +01:00
parent ee72368b94
commit 9b34feb43e
2 changed files with 35 additions and 32 deletions

View File

@@ -4,7 +4,7 @@ import SetStatus from '@/components/setStatus';
import { ThemedView, } from '@/components/theme/themed-view';
import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
import React from 'react';
import { StyleSheet, View,Text } from 'react-native';
import { StyleSheet, View,Text, ScrollView } from 'react-native';
import { useChantier } from '../ContextChantier';
import Anomaly from '@/components/anomaly';
@@ -26,9 +26,13 @@ export default function Home() {
<View style={{width:"100%", position: 'absolute',marginLeft:"50%"}}>
<SetStatus></SetStatus>
</View>
<ScrollView>
<View style={{paddingTop:60}}>
<ChantierSummary style={styles.summary} data={{ chantier }} />
<Anomaly style={styles.anomaly} data={{chantier}}/>
{role === "chef"}
</View>
</ScrollView>
</View>
</ThemedView>
@@ -43,7 +47,6 @@ const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
paddingTop : 60,
},
header: {
flex: 1,

View File

@@ -1,7 +1,7 @@
import { Chantier } from '@/class/class';
import { ThemedView } from '@/components/theme/themed-view';
import React, { use, useEffect, useState } from 'react';
import { TouchableOpacity, StyleProp, StyleSheet, View, Image, ViewStyle,Text, TextInput } from 'react-native';
import { TouchableOpacity, StyleProp, StyleSheet, View, Image, ViewStyle,Text, TextInput, ScrollView } from 'react-native';
import { ThemedText } from './theme/themed-text';
import { deleteAnomalie, addAnomalie, getChantiers } from '@/services/ressourcesService';
import { useChantier } from '@/app/ContextChantier';
@@ -63,18 +63,6 @@ export default function Anomaly({data,style}: Props) {
{data.chantier ? (
<ThemedView lvl={4} style={styles.anomaliesContainer}>
<ThemedText style={styles.anomaliesTitle}>Anomalies</ThemedText>
{data.chantier.anomalies.length > 0 ? (
data.chantier.anomalies.map((anomaly, index) => (
<ThemedView key={index} lvl={2} style={styles.anomalyItem}>
<ThemedText style={styles.anomalyText}> {anomaly}</ThemedText>
<TouchableOpacity onPress={() => handleDelete(anomaly)} style={styles.deleteButton}>
<Text style={styles.deleteText}></Text>
</TouchableOpacity>
</ThemedView>
))
) : (
<ThemedText style={styles.noAnomaly}>Aucune anomalie</ThemedText>
) }
{/* Add Anomaly Section */}
<View style={styles.addContainer}>
<TextInput style={styles.input} placeholder="Nouvelle anomalie..." value={newAnomaly} onChangeText={setNewAnomaly} />
@@ -88,6 +76,20 @@ export default function Anomaly({data,style}: Props) {
<Image source={{ uri: imageUri }} style={styles.image} />
)}
</View>
{data.chantier.anomalies.length > 0 ? (
data.chantier.anomalies.map((anomaly, index) => (
<ThemedView key={index} lvl={2} style={styles.anomalyItem}>
<ThemedText style={styles.anomalyText}> {anomaly}</ThemedText>
<TouchableOpacity onPress={() => handleDelete(anomaly)} style={styles.deleteButton}>
<Text style={styles.deleteText}></Text>
</TouchableOpacity>
</ThemedView>
))
) : (
<ThemedText style={styles.noAnomaly}>Aucune anomalie</ThemedText>
) }
</ThemedView>
): null}
</View>
@@ -99,7 +101,6 @@ const styles = StyleSheet.create({
anomaliesContainer: {
padding: 5,
borderRadius: 10,
//height: 150,
},
anomaliesTitle: {
fontSize: 16,
@@ -138,7 +139,6 @@ const styles = StyleSheet.create({
},
//add anomaly styles
addContainer: {
marginTop: 10,
marginLeft: 2,
flexDirection: "row",
alignItems: "center"