Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ReactNativeBase
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
Nguyen Danh Khanh
ReactNativeBase
Commits
b2377170
Commit
b2377170
authored
Jul 06, 2021
by
Nguyen Danh Khanh
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'khanhTDT/fix-UI' into 'master'
config blacklist whitelist to persist See merge request
!11
parents
f820ef0a
835df838
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
78 additions
and
35 deletions
+78
-35
src/api/listProduct.ts
src/api/listProduct.ts
+3
-2
src/components/ItemCartProduct/index.style.ts
src/components/ItemCartProduct/index.style.ts
+1
-1
src/redux/actions/auth.ts
src/redux/actions/auth.ts
+1
-1
src/redux/reducers/auth.ts
src/redux/reducers/auth.ts
+9
-12
src/redux/reducers/index.ts
src/redux/reducers/index.ts
+2
-0
src/redux/reducers/product.ts
src/redux/reducers/product.ts
+2
-2
src/redux/store/index.ts
src/redux/store/index.ts
+28
-2
src/screens/AuthFlash/index.tsx
src/screens/AuthFlash/index.tsx
+2
-1
src/screens/Home/index.tsx
src/screens/Home/index.tsx
+2
-2
src/screens/HomeCreateBill/index.style.ts
src/screens/HomeCreateBill/index.style.ts
+1
-0
src/screens/HomeCreateBill/index.tsx
src/screens/HomeCreateBill/index.tsx
+6
-6
src/screens/HomeProductCreate/index.style.ts
src/screens/HomeProductCreate/index.style.ts
+1
-2
src/screens/HomeProductCreate/index.tsx
src/screens/HomeProductCreate/index.tsx
+19
-2
src/screens/HomeRepository/index.tsx
src/screens/HomeRepository/index.tsx
+0
-1
src/screens/Profile/index.tsx
src/screens/Profile/index.tsx
+1
-1
No files found.
src/api/listProduct.ts
View file @
b2377170
...
@@ -2,9 +2,10 @@ import axios from 'axios'
...
@@ -2,9 +2,10 @@ import axios from 'axios'
import
config
from
'
../configs
'
import
config
from
'
../configs
'
import
{
store
}
from
'
../redux/store
'
import
{
store
}
from
'
../redux/store
'
const
token
=
store
.
getState
().
auth
.
token
export
function
getListProducts
()
{
export
function
getListProducts
()
{
const
token
=
store
.
getState
().
auth
.
token
console
.
log
(
'
API:
'
,
token
)
const
body
=
{
const
body
=
{
"
drug_barcode
"
:
""
,
"
drug_barcode
"
:
""
,
"
drug_name
"
:
""
,
"
drug_name
"
:
""
,
...
...
src/components/ItemCartProduct/index.style.ts
View file @
b2377170
...
@@ -21,7 +21,7 @@ const styles = StyleSheet.create({
...
@@ -21,7 +21,7 @@ const styles = StyleSheet.create({
fontWeight
:
'
bold
'
fontWeight
:
'
bold
'
},
},
textInfo
:
{
textInfo
:
{
fontSize
:
1
6
,
fontSize
:
1
4
,
}
}
});
});
...
...
src/redux/actions/auth.ts
View file @
b2377170
type
Data
=
{
type
Data
=
{
}
}
export
function
loginSuccess
(
token
:
string
)
{
export
function
loginSuccess
(
token
:
string
|
null
)
{
return
{
return
{
type
:
'
LOGIN_SUCCESS
'
,
type
:
'
LOGIN_SUCCESS
'
,
payload
:
token
payload
:
token
...
...
src/redux/reducers/auth.ts
View file @
b2377170
...
@@ -3,36 +3,33 @@ import Types from "../types";
...
@@ -3,36 +3,33 @@ import Types from "../types";
type
ActionType
=
{
type
ActionType
=
{
type
:
string
type
:
string
payload
:
AnyAction
payload
:
string
|
null
};
};
export
interface
InitStateAuth
{
export
type
InitStateAuth
=
{
username
:
string
//
username: string
password
:
string
//
password: string
token
:
string
|
null
token
:
string
|
null
}
}
const
initialState
:
InitStateAuth
=
{
const
initialState
:
InitStateAuth
=
{
username
:
""
,
//
username: "",
password
:
""
,
//
password: "",
token
:
null
token
:
null
}
}
function
authReducer
(
state
=
initialState
,
action
:
ActionType
)
{
function
productReducer
(
state
=
initialState
,
action
:
ActionType
)
{
const
payload
=
action
.
payload
const
payload
=
action
.
payload
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
case
Types
.
LOGIN_SUCCESS
:
case
Types
.
LOGIN_SUCCESS
:
return
{
return
{
...
state
,
...
state
,
auth
:
payload
,
token
:
payload
,
};
};
default
:
default
:
return
state
return
state
}
}
}
}
// export default authReducer
// export default authReducer
export
default
product
Reducer
export
default
auth
Reducer
src/redux/reducers/index.ts
View file @
b2377170
...
@@ -6,6 +6,7 @@ import invoice, { InitStateInvoice } from './invoice'
...
@@ -6,6 +6,7 @@ import invoice, { InitStateInvoice } from './invoice'
import
cart
from
'
./cart
'
import
cart
from
'
./cart
'
import
{
Cart
}
from
"
../../model/cart
"
;
import
{
Cart
}
from
"
../../model/cart
"
;
import
product
,
{
InitStateProduct
}
from
"
./product
"
;
import
product
,
{
InitStateProduct
}
from
"
./product
"
;
import
{
authPersistedReducer
}
from
"
../store
"
;
export
type
RootState
=
{
export
type
RootState
=
{
auth
:
InitStateAuth
,
auth
:
InitStateAuth
,
...
@@ -14,6 +15,7 @@ export type RootState = {
...
@@ -14,6 +15,7 @@ export type RootState = {
product
:
InitStateProduct
product
:
InitStateProduct
}
}
const
rootReducer
=
combineReducers
({
const
rootReducer
=
combineReducers
({
auth
,
auth
,
invoice
,
invoice
,
...
...
src/redux/reducers/product.ts
View file @
b2377170
...
@@ -68,7 +68,7 @@ const initState: InitStateProduct = {
...
@@ -68,7 +68,7 @@ const initState: InitStateProduct = {
data
:
[]
data
:
[]
}
}
function
invoice
Reducer
(
state
:
InitStateProduct
=
initState
,
action
:
AnyAction
)
{
function
product
Reducer
(
state
:
InitStateProduct
=
initState
,
action
:
AnyAction
)
{
const
payload
=
action
.
payload
const
payload
=
action
.
payload
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
...
@@ -88,4 +88,4 @@ function invoiceReducer(state: InitStateProduct = initState, action: AnyAction)
...
@@ -88,4 +88,4 @@ function invoiceReducer(state: InitStateProduct = initState, action: AnyAction)
// export default authReducer
// export default authReducer
export
default
invoiceReducer
export
default
productReducer
\ No newline at end of file
\ No newline at end of file
src/redux/store/index.ts
View file @
b2377170
...
@@ -5,15 +5,41 @@ import logger from 'redux-logger';
...
@@ -5,15 +5,41 @@ import logger from 'redux-logger';
import
createSagaMiddleware
from
'
redux-saga
'
;
import
createSagaMiddleware
from
'
redux-saga
'
;
import
rootSaga
from
'
../sagas
'
import
rootSaga
from
'
../sagas
'
import
{
persistStore
,
persistReducer
}
from
'
redux-persist
'
import
{
persistStore
,
persistReducer
}
from
'
redux-persist
'
// import storage from 'redux-persist/lib/storage' // defaults to localStorage
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
authReducer
from
'
../reducers/auth
'
;
import
productReducer
from
'
../reducers/product
'
;
import
cartReducer
from
'
../reducers/cart
'
;
import
invoiceReducer
from
'
../reducers/invoice
'
;
const
sagaMiddleware
=
createSagaMiddleware
()
const
sagaMiddleware
=
createSagaMiddleware
()
const
persistConfig
=
{
const
persistConfig
=
{
key
:
'
root
'
,
key
:
'
root
'
,
storage
:
AsyncStorage
storage
:
AsyncStorage
,
whitelist
:
[
'
auth
'
,
'
invoice
'
,
'
cart
'
,
'
product
'
]
}
}
const
authPersistConfig
=
{
key
:
'
auth
'
,
storage
:
AsyncStorage
,
whitelist
:
[
'
token
'
]
}
const
productPersistConfig
=
{
key
:
'
product
'
,
storage
:
AsyncStorage
,
}
const
cartPersistConfig
=
{
key
:
'
cart
'
,
storage
:
AsyncStorage
,
}
const
invoicePersistConfig
=
{
key
:
'
invoice
'
,
storage
:
AsyncStorage
,
}
export
const
authPersistedReducer
=
persistReducer
(
authPersistConfig
,
authReducer
)
export
const
productPersistedReducer
=
persistReducer
(
productPersistConfig
,
productReducer
)
export
const
cartPersistedReducer
=
persistReducer
(
cartPersistConfig
,
cartReducer
)
export
const
invoicePersistedReducer
=
persistReducer
(
invoicePersistConfig
,
invoiceReducer
)
const
persistedReducer
=
persistReducer
(
persistConfig
,
rootReducer
)
const
persistedReducer
=
persistReducer
(
persistConfig
,
rootReducer
)
// const middleware = logger, sagaMiddleware);
// const middleware = logger, sagaMiddleware);
const
store
=
createStore
(
const
store
=
createStore
(
...
...
src/screens/AuthFlash/index.tsx
View file @
b2377170
...
@@ -6,10 +6,11 @@ import {
...
@@ -6,10 +6,11 @@ import {
Image
Image
}
from
'
react-native
'
;
}
from
'
react-native
'
;
import
styles
from
'
./index.style
'
;
import
styles
from
'
./index.style
'
;
import
{
RootState
}
from
'
../../redux/reducers
'
;
const
App
=
()
=>
{
const
App
=
()
=>
{
const
navigation
=
useNavigation
()
const
navigation
=
useNavigation
()
const
token
=
useSelector
(
state
=>
state
.
auth
.
token
)
const
token
=
useSelector
(
(
state
:
RootState
)
=>
state
.
auth
.
token
)
console
.
log
(
'
Flat:
'
,
token
,
'
\n
'
)
console
.
log
(
'
Flat:
'
,
token
,
'
\n
'
)
if
(
token
==
null
)
navigation
.
navigate
(
'
AuthLogin
'
)
if
(
token
==
null
)
navigation
.
navigate
(
'
AuthLogin
'
)
else
navigation
.
navigate
(
'
Main
'
)
else
navigation
.
navigate
(
'
Main
'
)
...
...
src/screens/Home/index.tsx
View file @
b2377170
...
@@ -27,7 +27,7 @@ const App = () => {
...
@@ -27,7 +27,7 @@ const App = () => {
//------------------------------------------------------
//------------------------------------------------------
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
const
token
=
useSelector
((
state
:
RootState
)
=>
state
.
auth
.
token
)
const
token
=
useSelector
((
state
:
RootState
)
=>
state
.
auth
.
token
)
console
.
log
(
'
Home:Ahihi
'
,
token
,
'
\n
'
)
console
.
log
(
'
Home:Ahihi
'
,
token
,
'
\n
'
)
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
...
@@ -131,7 +131,7 @@ const App = () => {
...
@@ -131,7 +131,7 @@ const App = () => {
)
)
}
}
const
_renderButtonBill
=
()
=>
{
const
_renderButtonBill
=
()
=>
{
return
(
return
(
<
View
style=
{
styles
.
billButtonContainer
}
>
<
View
style=
{
styles
.
billButtonContainer
}
>
<
TouchableOpacity
style=
{
styles
.
billButton
}
<
TouchableOpacity
style=
{
styles
.
billButton
}
...
...
src/screens/HomeCreateBill/index.style.ts
View file @
b2377170
...
@@ -8,6 +8,7 @@ const styles = StyleSheet.create({
...
@@ -8,6 +8,7 @@ const styles = StyleSheet.create({
height
:
40
,
height
:
40
,
},
},
container
:
{
container
:
{
height
:
'
80%
'
,
marginBottom
:
60
,
marginBottom
:
60
,
},
},
buttonAdd
:
{
buttonAdd
:
{
...
...
src/screens/HomeCreateBill/index.tsx
View file @
b2377170
...
@@ -112,12 +112,13 @@ const App = () => {
...
@@ -112,12 +112,13 @@ const App = () => {
);
);
};
};
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
const
[
amount
,
setAmount
]
=
useState
(
35264
)
const
[
amount
,
setAmount
]
=
useState
(
28598
)
const
[
amountPaid
,
setAmountPaid
]
=
useState
(
'
0
'
)
const
[
amountPaid
,
setAmountPaid
]
=
useState
(
'
0
'
)
const
[
amountVat
,
setAmountVat
]
=
useState
(
''
)
const
[
amountVat
,
setAmountVat
]
=
useState
(
''
)
const
[
discount
,
setDiscount
]
=
useState
(
0
)
const
[
discount
,
setDiscount
]
=
useState
(
0
)
const
[
note
,
setNote
]
=
useState
(
''
)
const
[
note
,
setNote
]
=
useState
(
''
)
const
[
currentPaid
,
setCurrentPaid
]
=
useState
(
0
)
const
[
currentPaid
,
setCurrentPaid
]
=
useState
(
0
)
const
_renderBillDate
=
()
=>
(
const
_renderBillDate
=
()
=>
(
<
View
style=
{
styles
.
billDateContainer
}
>
<
View
style=
{
styles
.
billDateContainer
}
>
<
View
style=
{
styles
.
lineContainer
}
>
<
View
style=
{
styles
.
lineContainer
}
>
...
@@ -130,7 +131,7 @@ const App = () => {
...
@@ -130,7 +131,7 @@ const App = () => {
</
View
>
</
View
>
<
View
style=
{
styles
.
lineContainer
}
>
<
View
style=
{
styles
.
lineContainer
}
>
<
Text
>
Tổng tiền
</
Text
>
<
Text
>
Tổng tiền
</
Text
>
<
Text
>
{
`
35264
VNĐ`
}
</
Text
>
<
Text
>
{
`
${amount}
VNĐ`
}
</
Text
>
</
View
>
</
View
>
<
View
style=
{
styles
.
lineContainer
}
>
<
View
style=
{
styles
.
lineContainer
}
>
<
Text
>
VAT
</
Text
>
<
Text
>
VAT
</
Text
>
...
@@ -235,7 +236,8 @@ const App = () => {
...
@@ -235,7 +236,8 @@ const App = () => {
return
(
return
(
<
SafeAreaView
>
<
SafeAreaView
>
{
_renderHeader
()
}
{
_renderHeader
()
}
<
ScrollView
style=
{
styles
.
container
}
>
<
ScrollView
style=
{
styles
.
container
}
>
{
_renderButtonAdd
()
}
{
_renderButtonAdd
()
}
<
FlatList
<
FlatList
data=
{
cartProducts
}
data=
{
cartProducts
}
...
@@ -248,9 +250,7 @@ const App = () => {
...
@@ -248,9 +250,7 @@ const App = () => {
{
_renderNote
()
}
{
_renderNote
()
}
<
Button
onPress=
{
()
=>
submit
()
}
title=
'SEND'
></
Button
>
<
Button
onPress=
{
()
=>
submit
()
}
title=
'SEND'
></
Button
>
</
ScrollView
>
</
ScrollView
>
<
TouchableOpacity
style=
{
styles
.
buttonSend
}
onPress=
{
()
=>
submit
()
}
>
<
Text
>
SENDDDDDDDDDDDDDDDDDD
</
Text
>
</
TouchableOpacity
>
</
SafeAreaView
>
</
SafeAreaView
>
);
);
};
};
...
...
src/screens/HomeProductCreate/index.style.ts
View file @
b2377170
...
@@ -9,8 +9,7 @@ const styles = StyleSheet.create({
...
@@ -9,8 +9,7 @@ const styles = StyleSheet.create({
color
:
'
white
'
,
color
:
'
white
'
,
},
},
container
:
{
container
:
{
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
},
},
containerInput
:
{
containerInput
:
{
backgroundColor
:
'
white
'
,
backgroundColor
:
'
white
'
,
...
...
src/screens/HomeProductCreate/index.tsx
View file @
b2377170
...
@@ -21,6 +21,7 @@ import { Cart, Product } from "../../model/cart";
...
@@ -21,6 +21,7 @@ import { Cart, Product } from "../../model/cart";
import
{
Data
}
from
'
../../model/product
'
;
import
{
Data
}
from
'
../../model/product
'
;
import
{
RootState
}
from
'
../../redux/reducers
'
;
import
{
RootState
}
from
'
../../redux/reducers
'
;
import
IconBack
from
'
../../components/IconBack
'
;
import
IconBack
from
'
../../components/IconBack
'
;
import
{
RefreshControl
}
from
'
react-native
'
;
const
App
=
()
=>
{
const
App
=
()
=>
{
...
@@ -123,18 +124,34 @@ const App = () => {
...
@@ -123,18 +124,34 @@ const App = () => {
return
()
=>
{
}
return
()
=>
{
}
},
[])
},
[])
const
wait
=
(
timeout
:
number
)
=>
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
timeout
));
}
const
[
refreshing
,
setRefreshing
]
=
React
.
useState
(
false
);
const
onRefresh
=
React
.
useCallback
(()
=>
{
setRefreshing
(
true
);
wait
(
500
).
then
(()
=>
setRefreshing
(
false
));
},
[]);
//------------------------------------------------------------
//------------------------------------------------------------
return
(
return
(
<
SafeAreaView
>
<
SafeAreaView
>
{
_renderHeader
()
}
{
_renderHeader
()
}
<
View
>
<
ScrollView
style=
{
styles
.
container
}
refreshControl=
{
<
RefreshControl
refreshing=
{
refreshing
}
onRefresh=
{
onRefresh
}
/>
}
>
<
FlatList
<
FlatList
data=
{
products
}
data=
{
products
}
ItemSeparatorComponent=
{
ItemSeparatorView
}
ItemSeparatorComponent=
{
ItemSeparatorView
}
renderItem=
{
({
item
})
=>
_renderListProduct
(
item
)
}
renderItem=
{
({
item
})
=>
_renderListProduct
(
item
)
}
/>
/>
{
/* {_renderButtonSubmit()} */
}
{
/* {_renderButtonSubmit()} */
}
</
View
>
</
Scroll
View
>
</
SafeAreaView
>
</
SafeAreaView
>
);
);
}
}
...
...
src/screens/HomeRepository/index.tsx
View file @
b2377170
...
@@ -7,7 +7,6 @@ import {
...
@@ -7,7 +7,6 @@ import {
import
styles
from
'
./index.style
'
;
import
styles
from
'
./index.style
'
;
import
Header
from
'
../../components/Header
'
;
import
Header
from
'
../../components/Header
'
;
import
IconMedlink
from
'
../../components/IconMedlink
'
;
import
HeaderTitle
from
'
../../components/HeaderTitle
'
;
import
HeaderTitle
from
'
../../components/HeaderTitle
'
;
import
HomeRepositoryItem
from
'
../../components/HomeRepositoryItem
'
import
HomeRepositoryItem
from
'
../../components/HomeRepositoryItem
'
import
{
useNavigation
}
from
'
@react-navigation/core
'
;
import
{
useNavigation
}
from
'
@react-navigation/core
'
;
...
...
src/screens/Profile/index.tsx
View file @
b2377170
...
@@ -35,7 +35,7 @@ const App = () => {
...
@@ -35,7 +35,7 @@ const App = () => {
const
dispatch
=
useDispatch
()
const
dispatch
=
useDispatch
()
const
navigation
=
useNavigation
()
const
navigation
=
useNavigation
()
const
logOut
=
()
=>
{
const
logOut
=
()
=>
{
const
token
=
''
const
token
=
null
dispatch
(
loginSuccess
(
token
))
dispatch
(
loginSuccess
(
token
))
navigation
.
navigate
(
'
AuthLogin
'
)
navigation
.
navigate
(
'
AuthLogin
'
)
}
}
...
...
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