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
e8769d69
Commit
e8769d69
authored
2 years ago
by
Antoine Marquis
Browse files
Options
Downloads
Patches
Plain Diff
Intelligence in select.js
parent
7ac5fb86
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/components/form/select.js
+12
-2
12 additions, 2 deletions
frontend/src/components/form/select.js
frontend/src/pages/newPlace/newPlace.js
+10
-23
10 additions, 23 deletions
frontend/src/pages/newPlace/newPlace.js
with
22 additions
and
25 deletions
frontend/src/components/form/select.js
+
12
−
2
View file @
e8769d69
import
{
View
,
Text
}
from
"
react-native
"
export
function
SelectInput
({
list
,
onChangeText
,
style
,
value
})
{
export
function
SelectInput
({
list
,
onChangeText
,
style
,
value
,
useOther
=
false
,
otherStr
=
"
Autre
"
,
SetIsMain
=
null
})
{
useOther
?
SetIsMain
(
otherStr
==
value
)
:
null
return
(
<
View
style
=
{{...
style
,
flexDirection
:
"
row
"
}}
>
{
list
.
map
((
item
)
=>
{
{
(
useOther
?
[...
list
,
otherStr
]
:
list
)
.
map
((
item
)
=>
{
const
fontColor
=
value
==
item
?
"
red
"
:
"
black
"
return
(
<
Text
...
...
This diff is collapsed.
Click to expand it.
frontend/src/pages/newPlace/newPlace.js
+
10
−
23
View file @
e8769d69
...
...
@@ -13,6 +13,12 @@ export default function NewPlace() {
const
[
prix
,
setprix
]
=
useState
(
""
);
const
[
type
,
settype
]
=
useState
(
""
);
const
[
isMainCity
,
setIsMainCity
]
=
useState
(
true
);
const
[
isMainType
,
setIsMainType
]
=
useState
(
true
);
const
cityList
=
[
"
Compiègne
"
,
"
Margny
"
,
"
Venette
"
]
const
typeList
=
[
"
Maison
"
,
"
Appartement
"
,
"
Studio
"
]
function
createPlace
()
{
if
(
!
address
||
!
city
||
!
name
||
!
prix
||
!
type
)
{
...
...
@@ -38,25 +44,6 @@ export default function NewPlace() {
marginBottom
:
15
}
})
const
cityList
=
[
"
Compiègne
"
,
"
Margny
"
,
"
Venette
"
,
"
Autre
"
]
const
typeList
=
[
"
Maison
"
,
"
Appartement
"
,
"
Studio
"
,
"
Autre
"
]
const
isMainCity
=
()
=>
{
let
is
=
false
cityList
.
forEach
(
element
=>
{
if
(
city
==
element
&&
city
!=
cityList
[
cityList
.
length
-
1
])
is
=
true
});
return
is
}
const
isMainType
=
()
=>
{
let
is
=
false
typeList
.
forEach
(
element
=>
{
if
(
type
==
element
&&
type
!=
typeList
[
typeList
.
length
-
1
])
is
=
true
});
return
is
}
return
(
<
View
style
=
{{
marginTop
:
20
,
backgroundColor
:
"
white
"
,
height
:
"
100%
"
}}
>
...
...
@@ -64,8 +51,8 @@ export default function NewPlace() {
<
Text
style
=
{
style
.
titles
}
>
Adresse
<
/Text
>
<
TextInput
style
=
{
style
.
input
}
onChangeText
=
{
setaddress
}
value
=
{
address
}
placeholder
=
"
Adresse
"
/>
<
TextInput
style
=
{
style
.
input
}
onChangeText
=
{
setcomp
}
value
=
{
comp
}
placeholder
=
"
Complément
"
/>
<
SelectInput
style
=
{{
fontSize
:
style
.
input
.
fontSize
,
marginTop
:
10
,
marginBottom
:
10
}}
onChangeText
=
{
setcity
}
value
=
{
city
}
list
=
{
cityList
}
/
>
{
isMainCity
()
?
null
:
<
TextInput
style
=
{
style
.
input
}
onChangeText
=
{
setcity
}
value
=
{
city
}
/>
}
<
SelectInput
style
=
{{
fontSize
:
style
.
input
.
fontSize
,
marginTop
:
10
,
marginBottom
:
10
}}
SetIsMain
=
{
setIsMainCity
}
useOther
=
{
true
}
onChangeText
=
{
setcity
}
value
=
{
city
}
list
=
{
cityList
}
/
>
{
isMainCity
?
<
TextInput
style
=
{
style
.
input
}
onChangeText
=
{
setcity
}
value
=
{
city
}
/>
: null
}
<
Text
style
=
{
style
.
titles
}
>
Nom
<
/Text
>
<
TextInput
style
=
{
style
.
input
}
onChangeText
=
{
setname
}
value
=
{
name
}
placeholder
=
"
Nom
"
/>
<
Text
style
=
{
style
.
titles
}
>
Places
restantes
<
/Text
>
...
...
@@ -73,8 +60,8 @@ export default function NewPlace() {
<
Text
style
=
{
style
.
titles
}
>
Prix
<
/Text
>
<
TextInput
style
=
{
style
.
input
}
onChangeText
=
{
setprix
}
value
=
{
prix
}
placeholder
=
"
Prix
"
/>
<
Text
style
=
{
style
.
titles
}
>
Type
de
logement
<
/Text
>
<
SelectInput
style
=
{{
fontSize
:
style
.
input
.
fontSize
,
marginTop
:
10
,
marginBottom
:
10
}}
onChangeText
=
{
settype
}
value
=
{
type
}
list
=
{
typeList
}
/
>
{
isMainType
()
?
null
:
<
TextInput
style
=
{{...
style
.
input
,
marginBottom
:
25
}}
onChangeText
=
{
settype
}
value
=
{
type
}
/>
}
<
SelectInput
style
=
{{
fontSize
:
style
.
input
.
fontSize
,
marginTop
:
10
,
marginBottom
:
10
}}
SetIsMain
=
{
setIsMainType
}
useOther
=
{
true
}
onChangeText
=
{
settype
}
value
=
{
type
}
list
=
{
typeList
}
/
>
{
isMainType
?
<
TextInput
style
=
{{...
style
.
input
,
marginBottom
:
25
}}
onChangeText
=
{
settype
}
value
=
{
type
}
/>
: null
}
<
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
>
...
...
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