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 {
TouchableOpacity
,
ImageBackground
,
Alert
,
Image
Image
,
}
from
"
react-native
"
;
import
{
FontAwesome
}
from
"
@expo/vector-icons
"
;
import
{
FontAwesome5
}
from
"
@expo/vector-icons
"
;
...
...
@@ -24,49 +24,48 @@ export function PriceScreen({ navigation }) {
const
[
discount
,
setDiscount
]
=
useState
(
""
);
// data, route
// const {picture} = route.params
// useEffect(() => {
// getImage(picture);
// }, []);
// const {picture} = route.params
// useEffect(() => {
// getImage(picture);
// }, []);
const
fetchData
=
async
()
=>
{
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
const
fetchData
=
async
()
=>
{
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
axios
({
method
:
"
GET
"
,
url
:
"
http://192.168.8.126:5000/discount/<id>
"
,
})
.
then
(
function
(
response
)
{
console
.
log
(
response
.
data
.
message
);
// data = response.data
setDiscount
(
response
.
data
.
message
);
axios
({
method
:
"
GET
"
,
url
:
"
http://192.168.8.126:5000/discount/<id>
"
,
})
.
catch
(
function
(
error
)
{
console
.
log
(
"
axios error
"
+
error
);
});
};
useEffect
(()
=>
{
fetchData
();
},[]);
.
then
(
function
(
response
)
{
console
.
log
(
response
.
data
.
message
);
// data = response.data
setDiscount
(
response
.
data
.
message
);
})
.
catch
(
function
(
error
)
{
console
.
log
(
"
axios error
"
+
error
);
});
};
function
name
()
{
axios
}
useEffect
(()
=>
{
fetchData
();
},
[]);
const
[
image
,
setImage
]
=
useState
(
''
);
//get the token and id from headers
//from the id get the
function
name
()
{
axios
;
}
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
[
image
,
setImage
]
=
useState
(
""
);
//get the token and id from headers
//from the id get the
}
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
({
name
:
""
,
...
...
@@ -110,42 +109,41 @@ const getImage = async (name) => {
}
};
const
createTwoButtonAlert
=
()
=>
{
Alert
.
alert
(
"
Delete User
"
,
"
Are you sure want to delete User
"
,
[
{
text
:
"
Cancel
"
,
onPress
:
()
=>
console
.
log
(
"
Cancel Pressed
"
),
style
:
"
cancel
"
},
{
text
:
"
OK
"
,
onPress
:
()
=>
axios
.
delete
(
"
http://192.168.8.126:5000/deleteUsers/<id>
"
)
.
then
(
function
(
response
)
{
const
stngobj
=
JSON
.
stringify
(
response
.
data
)
console
.
log
(
stngobj
);
alert
(
"
Successfully deleted
"
)
navigation
.
navigate
(
"
SignIn
"
)
// return response;
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
alert
(
"
Please Insert new Data
"
)
})
}
]
);
}
const
createTwoButtonAlert
=
()
=>
{
Alert
.
alert
(
"
Delete User
"
,
"
Are you sure want to delete User
"
,
[
{
text
:
"
Cancel
"
,
onPress
:
()
=>
console
.
log
(
"
Cancel Pressed
"
),
style
:
"
cancel
"
,
},
{
text
:
"
OK
"
,
onPress
:
()
=>
axios
.
delete
(
"
http://192.168.8.126:5000/deleteUsers/<id>
"
)
.
then
(
function
(
response
)
{
const
stngobj
=
JSON
.
stringify
(
response
.
data
);
console
.
log
(
stngobj
);
alert
(
"
Successfully deleted
"
);
navigation
.
navigate
(
"
SignIn
"
);
// return response;
})
.
catch
(
function
(
error
)
{
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
(
"
district
"
,
details
.
district
)
form
.
append
(
"
name
"
,
details
.
name
)
;
form
.
append
(
"
district
"
,
details
.
district
)
;
console
.
log
(
form
)
console
.
log
(
form
)
;
return
(
<
View
style
=
{
styles
.
container
}
>
...
...
@@ -180,10 +178,14 @@ const getImage = async (name) => {
<
View
style
=
{
styles
.
con
}
>
<
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
style
=
{
styles
.
textinputicon
}
>
...
...
@@ -253,18 +255,21 @@ const getImage = async (name) => {
<
TouchableOpacity
style
=
{
styles
.
buttonSub
}
activeOpacity
=
{
0.5
}
onPress
=
{()
=>
axios
.
put
(
"
http://192.168.8.126:5000/updateUsers/<id>
"
,
form
)
.
then
(
function
(
response
)
{
const
stngobj
=
JSON
.
stringify
(
response
.
data
)
console
.
log
(
stngobj
);
alert
(
"
Successfully Update
"
)
// navigation.navigate("HomeScreen")
// return response;
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
alert
(
"
update error
"
)
})
}
onPress
=
{()
=>
axios
.
put
(
"
http://192.168.8.126:5000/updateUsers/<id>
"
,
form
)
.
then
(
function
(
response
)
{
const
stngobj
=
JSON
.
stringify
(
response
.
data
);
console
.
log
(
stngobj
);
alert
(
"
Successfully Update
"
);
// navigation.navigate("HomeScreen")
// return response;
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
alert
(
"
update error
"
);
})
}
>
<
Text
style
=
{
styles
.
buttonTextStyle
}
>
Update
Details
<
/Text
>
<
/TouchableOpacity
>
...
...
@@ -278,13 +283,31 @@ const getImage = async (name) => {
<
/TouchableOpacity
>
<
/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
style
=
{
styles
.
bottom
}
>
<
BottomTab
/>
<
BottomTab
/>
<
/View
>
<
/ImageBackground
>
<
/View
>
...
...
@@ -331,17 +354,25 @@ const styles = StyleSheet.create({
text1
:
{
fontSize
:
20
,
alignSelf
:
"
center
"
,
marginBottom
:
20
,
marginTop
:
1
5
,
//
marginBottom: 20,
marginTop
:
1
0
,
color
:
"
black
"
,
},
text2
:
{
fontSize
:
20
,
alignSelf
:
"
center
"
,
// marginBottom: 20,
marginTop
:
15
,
color
:
"
green
"
,
fontWeight
:
"
bold
"
,
},
container
:
{
justifyContent
:
"
flex-start
"
,
alignContent
:
"
stretch
"
,
},
secondContainer
:
{
justifyContent
:
"
flex-start
"
,
marginTop
:
65
marginTop
:
55
,
},
textinputicon
:
{
// flex: 1,
...
...
@@ -359,7 +390,7 @@ const styles = StyleSheet.create({
fontSize
:
15
,
borderRadius
:
25
,
marginTop
:
20
,
marginBottom
:
10
,
marginBottom
:
5
,
marginLeft
:
10
,
marginRight
:
19
,
backgroundColor
:
"
white
"
,
...
...
@@ -400,20 +431,20 @@ const styles = StyleSheet.create({
justifyContent
:
"
center
"
,
borderRadius
:
8
,
},
bottom
:{
justifyContent
:
"
flex-end
"
,
marginTop
:
120
bottom
:
{
justifyContent
:
"
flex-end
"
,
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