Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/trochas/mmm-projet
This commit is contained in:
@@ -9,7 +9,7 @@ import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 're
|
||||
import { useChantier } from '@/app/ContextChantier';
|
||||
import { useRessources } from '@/app/ContextRessource';
|
||||
import { useUser } from '@/app/ContextUser';
|
||||
import { getRessources, getUsers, addChantier } from '@/services/ressourcesService';
|
||||
import { getRessources, getUsers, addChantier , addRessources} from '@/services/ressourcesService';
|
||||
import { Chantier, Ressources, User } from '@/class/class';
|
||||
import { ThemedText } from '@/components/theme/themed-text';
|
||||
import { ThemedButton } from '@/components/theme/themed-button';
|
||||
@@ -58,20 +58,40 @@ export default function AddRessource({ressourceType, ...otherProps }: Props) {
|
||||
}
|
||||
|
||||
async function onConfirm(): Promise<void> {
|
||||
//TODO
|
||||
//await changeChantierStatus(chantier.id,tempStatus)
|
||||
//Il faut changer le UX
|
||||
//setChantier({...chantier,etat: tempStatus})
|
||||
if(isValidRessource()){
|
||||
try{
|
||||
setLoading(true);
|
||||
const nouvelleRessource : Ressources = {
|
||||
id : '',
|
||||
name: nom,
|
||||
type : ressourceType,
|
||||
quantity : parseInt(quantite),
|
||||
available_quantity : parseInt(quantite),
|
||||
Image : "",
|
||||
allocation : [],
|
||||
};
|
||||
const id = await addRessources(nouvelleRessource);
|
||||
|
||||
if(id){
|
||||
setRessources([...ressources,{...nouvelleRessource, id}]);
|
||||
setOpenConfirmation(false);
|
||||
setNom('');
|
||||
setQuantite('');
|
||||
setQuantiteDisponible('');
|
||||
}
|
||||
}catch(error){
|
||||
}finally{
|
||||
setOpenConfirmation(false);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onCancel(): void {
|
||||
setOpenConfirmation(false);
|
||||
}
|
||||
function isValidRessource():Boolean{
|
||||
return nom!= "" && quantite != "" && quantiteDisponible != ""
|
||||
return nom!= "" && quantite != ""
|
||||
}
|
||||
|
||||
const renderValidationScreen = () => {
|
||||
@@ -98,8 +118,7 @@ export default function AddRessource({ressourceType, ...otherProps }: Props) {
|
||||
</View>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const renderInut = (name : string, preFill : string, value : string, setValue : ((text:string) => void),numeric:boolean) => {
|
||||
return (
|
||||
|
||||
@@ -66,7 +66,7 @@ export default function Anomaly({data,style}: Props) {
|
||||
{data.chantier.anomalies.length > 0 ? (
|
||||
data.chantier.anomalies.map((anomaly, index) => (
|
||||
<ThemedView key={index} lvl={2} style={styles.anomalyItem}>
|
||||
<ThemedText>• {anomaly}</ThemedText>
|
||||
<ThemedText style={styles.anomalyText}>• {anomaly}</ThemedText>
|
||||
<TouchableOpacity onPress={() => handleDelete(anomaly)} style={styles.deleteButton}>
|
||||
<Text style={styles.deleteText}>✕</Text>
|
||||
</TouchableOpacity>
|
||||
@@ -99,7 +99,7 @@ const styles = StyleSheet.create({
|
||||
anomaliesContainer: {
|
||||
padding: 5,
|
||||
borderRadius: 10,
|
||||
height: 150,
|
||||
//height: 150,
|
||||
},
|
||||
anomaliesTitle: {
|
||||
fontSize: 16,
|
||||
@@ -107,10 +107,16 @@ const styles = StyleSheet.create({
|
||||
marginBottom: 8,
|
||||
},
|
||||
anomalyItem: {
|
||||
flexDirection: "row",
|
||||
alignItems: "flex-start",
|
||||
padding: 8,
|
||||
marginBottom: 5,
|
||||
borderRadius: 8,
|
||||
},
|
||||
anomalyText: {
|
||||
flex: 1,
|
||||
marginLeft: 5,
|
||||
},
|
||||
noAnomaly: {
|
||||
fontStyle: "italic",
|
||||
opacity: 0.7,
|
||||
@@ -133,6 +139,7 @@ const styles = StyleSheet.create({
|
||||
//add anomaly styles
|
||||
addContainer: {
|
||||
marginTop: 10,
|
||||
marginLeft: 2,
|
||||
flexDirection: "row",
|
||||
alignItems: "center"
|
||||
},
|
||||
@@ -144,6 +151,7 @@ const styles = StyleSheet.create({
|
||||
marginRight: 8,
|
||||
},
|
||||
addButton: {
|
||||
color: "white",
|
||||
paddingVertical: 8,
|
||||
paddingHorizontal: 12,
|
||||
borderRadius: 8,
|
||||
|
||||
Reference in New Issue
Block a user