Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
map_UT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anael Lacour
map_UT
Commits
f339b739
Commit
f339b739
authored
2 years ago
by
Antoine Marquis
Browse files
Options
Downloads
Patches
Plain Diff
equipment and simple fetch on new_place
parent
d383ad22
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/pages/newPlace/newPlace.js
+50
-5
50 additions, 5 deletions
frontend/src/pages/newPlace/newPlace.js
with
50 additions
and
5 deletions
frontend/src/pages/newPlace/newPlace.js
+
50
−
5
View file @
f339b739
import
{
useState
}
from
"
react
"
;
import
{
TextInput
,
View
,
Text
,
Button
,
StyleSheet
,
Dimensions
,
ScrollView
,
TouchableOpacity
}
from
"
react-native
"
;
import
{
baseIPAddress
}
from
"
../../../constants/server
"
;
import
{
window
}
from
"
../../../constants/Layout
"
;
import
{
TextInput
,
View
,
Text
,
StyleSheet
,
Dimensions
,
ScrollView
,
TouchableOpacity
,
Checkbox
}
from
"
react-native
"
;
import
{
baseIPAddress
,
newPlacePath
}
from
"
../../../constants/server
"
;
import
{
SelectInput
}
from
"
../../components/form/select
"
;
export
default
function
NewPlace
()
{
...
...
@@ -12,21 +11,60 @@ export default function NewPlace() {
const
[
placesRestantes
,
setplacesRestantes
]
=
useState
(
""
);
const
[
prix
,
setprix
]
=
useState
(
""
);
const
[
type
,
settype
]
=
useState
(
""
);
const
[
equip
,
setequip
]
=
useState
({});
const
[
isMainCity
,
setIsMainCity
]
=
useState
(
true
);
const
[
isMainType
,
setIsMainType
]
=
useState
(
true
);
const
cityList
=
[
"
Compiègne
"
,
"
Margny
"
,
"
Venette
"
]
const
typeList
=
[
"
Maison
"
,
"
Appartement
"
,
"
Studio
"
]
const
equipmentList
=
[
"
wifi
"
,
"
canap
"
]
{
let
dic
=
{}
equipmentList
.
forEach
(
element
=>
{
dic
[
element
]
=
false
});
setequip
(
dic
)
}
function
createPlace
()
{
if
(
!
address
||
!
city
||
!
name
||
!
prix
||
!
type
)
{
//Render error
/**
* If a necessary var is undefined, render a user friendly error
*/
return
}
/**
* Création de l'object JSON
*/
let
place
=
{
"
formatted_address
"
:
[
address
,
city
].
join
(
"
,
"
),
"
name
"
:
name
,
"
place_restant
"
:
placesRestantes
,
"
price
"
:
prix
,
"
types
"
:
type
,
"
equipment
"
:
equip
}
/**
* Appel du back avec fetch
* Either render an error or go to the next page
*/
let
ans
=
fetch
(
baseIPAddress
+
newPlacePath
,
{
method
:
"
post
"
,
body
:
JSON
.
stringify
(
place
)
})
}
console
.
log
(
"
Attente de la request
"
)
function
modifyElement
(
map
,
i
,
newVal
)
{
map
[
i
]
=
newVal
return
map
}
...
...
@@ -65,6 +103,13 @@ export default function NewPlace() {
<
TouchableOpacity
style
=
{{
borderRadius
:
1
,
backgroundColor
:
"
black
"
,
padding
:
10
,
width
:
180
}}
onPress
=
{
createPlace
}
>
<
Text
style
=
{{
fontSize
:
16
,
color
:
"
white
"
,
fontWeight
:
"
bold
"
,
textAlign
:
"
center
"
}}
>
Ajouter
le
logement
<
/Text
>
<
/TouchableOpacity
>
<
View
style
=
{{
flexDirection
:
"
row
"
}}
>
{
equipmentList
.
map
((
item
)
=>
{
return
(
<
Checkbox
value
=
{
equip
[
item
]}
onValueChange
=
{(
val
)
=>
setequip
(
modifyElement
(
val
))}
/
>
)
})}
<
/View
>
<
/ScrollView
>
<
/View
>
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment