Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-090 frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-090
2021-090 frontend
Commits
5b0911b2
Commit
5b0911b2
authored
Nov 23, 2021
by
IT18111170-Silva S.H.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: pricepage discount updated
parent
2f5a1693
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
137 additions
and
106 deletions
+137
-106
screen/PriceScreen.js
screen/PriceScreen.js
+137
-106
No files found.
screen/PriceScreen.js
View file @
5b0911b2
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
TouchableOpacity
,
TouchableOpacity
,
ImageBackground
,
ImageBackground
,
Alert
,
Alert
,
Image
Image
,
}
from
"
react-native
"
;
}
from
"
react-native
"
;
import
{
FontAwesome
}
from
"
@expo/vector-icons
"
;
import
{
FontAwesome
}
from
"
@expo/vector-icons
"
;
import
{
FontAwesome5
}
from
"
@expo/vector-icons
"
;
import
{
FontAwesome5
}
from
"
@expo/vector-icons
"
;
...
@@ -24,49 +24,48 @@ export function PriceScreen({ navigation }) {
...
@@ -24,49 +24,48 @@ export function PriceScreen({ navigation }) {
const
[
discount
,
setDiscount
]
=
useState
(
""
);
const
[
discount
,
setDiscount
]
=
useState
(
""
);
// data, route
// data, route
// const {picture} = route.params
// const {picture} = route.params
// useEffect(() => {
// useEffect(() => {
// getImage(picture);
// getImage(picture);
// }, []);
// }, []);
const
fetchData
=
async
()
=>
{
const
fetchData
=
async
()
=>
{
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
axios
({
axios
({
method
:
"
GET
"
,
method
:
"
GET
"
,
url
:
"
http://192.168.8.126:5000/discount/<id>
"
,
url
:
"
http://192.168.8.126:5000/discount/<id>
"
,
})
.
then
(
function
(
response
)
{
console
.
log
(
response
.
data
.
message
);
// data = response.data
setDiscount
(
response
.
data
.
message
);
})
})
.
catch
(
function
(
error
)
{
.
then
(
function
(
response
)
{
console
.
log
(
"
axios error
"
+
error
);
console
.
log
(
response
.
data
.
message
);
});
// data = response.data
};
setDiscount
(
response
.
data
.
message
);
})
useEffect
(()
=>
{
.
catch
(
function
(
error
)
{
fetchData
();
console
.
log
(
"
axios error
"
+
error
);
},[]);
});
};
function
name
()
{
useEffect
(()
=>
{
axios
fetchData
();
}
},
[]);
const
[
image
,
setImage
]
=
useState
(
''
);
function
name
()
{
//get the token and id from headers
axios
;
//from the id get the
}
const
getImage
=
async
(
name
)
=>
{
const
[
image
,
setImage
]
=
useState
(
""
);
console
.
log
(
name
)
//get the token and id from headers
const
q
=
name
.
split
(
'
'
).
join
(
'
+
'
)
//from the id get the
const
img
=
await
fetch
(
`http://192.168.8.126:5000/getimage/
${
name
}
`
)
const
image
=
await
img
.
json
();
console
.
log
(
image
)
setImage
(
image
.
previewURL
)
}
const
getImage
=
async
(
name
)
=>
{
console
.
log
(
name
);
const
q
=
name
.
split
(
"
"
).
join
(
"
+
"
);
const
img
=
await
fetch
(
`http://192.168.8.126:5000/getimage/
${
name
}
`
);
const
image
=
await
img
.
json
();
console
.
log
(
image
);
setImage
(
image
.
previewURL
);
};
const
[
details
,
setDetails
]
=
useState
({
const
[
details
,
setDetails
]
=
useState
({
name
:
""
,
name
:
""
,
...
@@ -110,42 +109,41 @@ const getImage = async (name) => {
...
@@ -110,42 +109,41 @@ const getImage = async (name) => {
}
}
};
};
const
createTwoButtonAlert
=
()
=>
{
const
createTwoButtonAlert
=
()
=>
{
Alert
.
alert
(
Alert
.
alert
(
"
Delete User
"
,
"
Are you sure want to delete User
"
,
[
"
Delete User
"
,
{
"
Are you sure want to delete User
"
,
text
:
"
Cancel
"
,
[
onPress
:
()
=>
console
.
log
(
"
Cancel Pressed
"
),
{
style
:
"
cancel
"
,
text
:
"
Cancel
"
,
},
onPress
:
()
=>
console
.
log
(
"
Cancel Pressed
"
),
{
style
:
"
cancel
"
text
:
"
OK
"
,
},
onPress
:
()
=>
{
text
:
"
OK
"
,
onPress
:
()
=>
axios
.
delete
(
"
http://192.168.8.126:5000/deleteUsers/<id>
"
)
axios
.
then
(
function
(
response
)
{
.
delete
(
"
http://192.168.8.126:5000/deleteUsers/<id>
"
)
const
stngobj
=
JSON
.
stringify
(
response
.
data
)
.
then
(
function
(
response
)
{
console
.
log
(
stngobj
);
const
stngobj
=
JSON
.
stringify
(
response
.
data
);
alert
(
"
Successfully deleted
"
)
console
.
log
(
stngobj
);
navigation
.
navigate
(
"
SignIn
"
)
alert
(
"
Successfully deleted
"
);
// return response;
navigation
.
navigate
(
"
SignIn
"
);
})
// return response;
.
catch
(
function
(
error
)
{
})
console
.
log
(
error
);
.
catch
(
function
(
error
)
{
alert
(
"
Please Insert new Data
"
)
console
.
log
(
error
);
})
}
alert
(
"
Please Insert new Data
"
);
]
}),
);
},
}
]);
};
function
dbDetails
(){
function
dbDetails
()
{}
}
const
form
=
new
FormData
();
const
form
=
new
FormData
();
form
.
append
(
"
name
"
,
details
.
name
)
form
.
append
(
"
name
"
,
details
.
name
)
;
form
.
append
(
"
district
"
,
details
.
district
)
form
.
append
(
"
district
"
,
details
.
district
)
;
console
.
log
(
form
)
console
.
log
(
form
)
;
return
(
return
(
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
container
}
>
...
@@ -180,10 +178,14 @@ const getImage = async (name) => {
...
@@ -180,10 +178,14 @@ const getImage = async (name) => {
<
View
style
=
{
styles
.
con
}
>
<
View
style
=
{
styles
.
con
}
>
<
Text
>
<
Text
>
{
{
<
Image
source
=
{{
uri
:
`http://192.168.8.126:5000/getimage/
${
name
}
`
}}
style
=
{{
width
:
200
,
height
:
200
}}
/
>
<
Image
source
=
{{
uri
:
`http://192.168.8.126:5000/getimage/
${
name
}
`
,
}}
style
=
{{
width
:
200
,
height
:
200
}}
/
>
}
}
<
/Text
>
<
/Text
>
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
textinputicon
}
>
<
View
style
=
{
styles
.
textinputicon
}
>
...
@@ -253,18 +255,21 @@ const getImage = async (name) => {
...
@@ -253,18 +255,21 @@ const getImage = async (name) => {
<
TouchableOpacity
<
TouchableOpacity
style
=
{
styles
.
buttonSub
}
style
=
{
styles
.
buttonSub
}
activeOpacity
=
{
0.5
}
activeOpacity
=
{
0.5
}
onPress
=
{()
=>
axios
.
put
(
"
http://192.168.8.126:5000/updateUsers/<id>
"
,
form
)
onPress
=
{()
=>
.
then
(
function
(
response
)
{
axios
const
stngobj
=
JSON
.
stringify
(
response
.
data
)
.
put
(
"
http://192.168.8.126:5000/updateUsers/<id>
"
,
form
)
console
.
log
(
stngobj
);
.
then
(
function
(
response
)
{
alert
(
"
Successfully Update
"
)
const
stngobj
=
JSON
.
stringify
(
response
.
data
);
// navigation.navigate("HomeScreen")
console
.
log
(
stngobj
);
// return response;
alert
(
"
Successfully Update
"
);
})
// navigation.navigate("HomeScreen")
.
catch
(
function
(
error
)
{
// return response;
console
.
log
(
error
);
})
alert
(
"
update error
"
)
.
catch
(
function
(
error
)
{
})
}
console
.
log
(
error
);
alert
(
"
update error
"
);
})
}
>
>
<
Text
style
=
{
styles
.
buttonTextStyle
}
>
Update
Details
<
/Text
>
<
Text
style
=
{
styles
.
buttonTextStyle
}
>
Update
Details
<
/Text
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
...
@@ -278,13 +283,31 @@ const getImage = async (name) => {
...
@@ -278,13 +283,31 @@ const getImage = async (name) => {
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
View
>
<
View
>
<
Text
style
=
{
styles
.
text1
}
>
You
have
earned
{
discount
}
%
Discount
<
/Text
>
{
discount
==
10
?
(
<
Text
style
=
{
styles
.
text2
}
>
EXCELLENT
!!<
/Text
>
)
:
discount
==
9
?
(
<
Text
style
=
{
styles
.
text2
}
>
SUPERB
!!<
/Text
>
)
:
discount
==
8
?
(
<
Text
style
=
{
styles
.
text2
}
>
BEST
WORK
!!<
/Text
>
)
:
discount
==
7
?
(
<
Text
style
=
{
styles
.
text2
}
>
NICE
JOB
!!<
/Text
>
)
:
discount
==
6
?
(
<
Text
style
=
{
styles
.
text2
}
>
GOOD
!!<
/Text
>
)
:
discount
==
5
?
(
<
Text
style
=
{
styles
.
text2
}
>
GOOD
KEEP
GOING
!!<
/Text
>
)
:
discount
<=
4
?
(
<
Text
style
=
{
styles
.
text2
}
>
GOOD
!
TRY
HARDER
!!<
/Text
>
)
:
(
<
Text
style
=
{
styles
.
text2
}
>
NO
DISCOUNT
<
/Text
>
)}
<
Text
style
=
{
styles
.
text1
}
>
You
have
earned
{
discount
}
%
Discount
<
/Text
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
bottom
}
>
<
View
style
=
{
styles
.
bottom
}
>
<
BottomTab
/>
<
BottomTab
/>
<
/View
>
<
/View
>
<
/ImageBackground
>
<
/ImageBackground
>
<
/View
>
<
/View
>
...
@@ -331,17 +354,25 @@ const styles = StyleSheet.create({
...
@@ -331,17 +354,25 @@ const styles = StyleSheet.create({
text1
:
{
text1
:
{
fontSize
:
20
,
fontSize
:
20
,
alignSelf
:
"
center
"
,
alignSelf
:
"
center
"
,
marginBottom
:
20
,
//
marginBottom: 20,
marginTop
:
1
5
,
marginTop
:
1
0
,
color
:
"
black
"
,
color
:
"
black
"
,
},
},
text2
:
{
fontSize
:
20
,
alignSelf
:
"
center
"
,
// marginBottom: 20,
marginTop
:
15
,
color
:
"
green
"
,
fontWeight
:
"
bold
"
,
},
container
:
{
container
:
{
justifyContent
:
"
flex-start
"
,
justifyContent
:
"
flex-start
"
,
alignContent
:
"
stretch
"
,
alignContent
:
"
stretch
"
,
},
},
secondContainer
:
{
secondContainer
:
{
justifyContent
:
"
flex-start
"
,
justifyContent
:
"
flex-start
"
,
marginTop
:
65
marginTop
:
55
,
},
},
textinputicon
:
{
textinputicon
:
{
// flex: 1,
// flex: 1,
...
@@ -359,7 +390,7 @@ const styles = StyleSheet.create({
...
@@ -359,7 +390,7 @@ const styles = StyleSheet.create({
fontSize
:
15
,
fontSize
:
15
,
borderRadius
:
25
,
borderRadius
:
25
,
marginTop
:
20
,
marginTop
:
20
,
marginBottom
:
10
,
marginBottom
:
5
,
marginLeft
:
10
,
marginLeft
:
10
,
marginRight
:
19
,
marginRight
:
19
,
backgroundColor
:
"
white
"
,
backgroundColor
:
"
white
"
,
...
@@ -400,20 +431,20 @@ const styles = StyleSheet.create({
...
@@ -400,20 +431,20 @@ const styles = StyleSheet.create({
justifyContent
:
"
center
"
,
justifyContent
:
"
center
"
,
borderRadius
:
8
,
borderRadius
:
8
,
},
},
bottom
:{
bottom
:
{
justifyContent
:
"
flex-end
"
,
justifyContent
:
"
flex-end
"
,
marginTop
:
120
marginTop
:
120
,
},
con
:
{
elevation
:
2
,
height
:
100
,
width
:
100
,
backgroundColor
:
"
#efefef
"
,
position
:
"
relative
"
,
borderRadius
:
999
,
overflow
:
"
hidden
"
,
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
alignSelf
:
"
center
"
,
},
},
con
:{
elevation
:
2
,
height
:
100
,
width
:
100
,
backgroundColor
:
'
#efefef
'
,
position
:
'
relative
'
,
borderRadius
:
999
,
overflow
:
'
hidden
'
,
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
alignSelf
:
"
center
"
},
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment