Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
rich-maker
Commits
4e3a96be
Commit
4e3a96be
authored
Jul 26, 2021
by
Choi Ga Young
Browse files
DB연결중
parent
e96aa4df
Changes
5
Show whitespace changes
Inline
Side-by-side
DeptPage.js
View file @
4e3a96be
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
{
StyleSheet
,
Text
,
View
,
FlatList
,
TouchableOpacity
,
Modal
,
Alert
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
{
StyleSheet
,
Text
,
View
,
FlatList
,
TouchableOpacity
,
Modal
,
Alert
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
TodoItem
from
'
./components/
t
odoItem
'
;
import
TodoItem
from
'
./components/
T
odoItem
'
;
import
InfoForm
from
'
./screens/InfoForm
'
;
import
InfoForm
from
'
./screens/InfoForm
'
;
import
Ionicons
from
'
react-native-vector-icons/Ionicons
'
;
import
Ionicons
from
'
react-native-vector-icons/Ionicons
'
;
import
InfoDetails
from
'
./screens/InfoDetails
'
import
ButtonsForm
from
'
./components/ButtonsForm
'
;
import
ButtonsForm
from
'
./components/ButtonsForm
'
;
import
{
TabView
}
from
'
react-native-elements
'
;
import
{
TabView
}
from
'
react-native-elements
'
;
...
...
MemoPage.js
View file @
4e3a96be
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
{
StyleSheet
,
Text
,
View
,
FlatList
,
TouchableOpacity
,
Modal
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
{
StyleSheet
,
Text
,
View
,
FlatList
,
TouchableOpacity
,
Modal
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
TodoItem
from
'
./components/
t
odoItem
'
;
import
TodoItem
from
'
./components/
T
odoItem
'
;
import
Ionicons
from
'
react-native-vector-icons/Ionicons
'
;
import
Ionicons
from
'
react-native-vector-icons/Ionicons
'
;
import
{
NavigationContainer
}
from
'
@react-navigation/native
'
;
import
{
NavigationContainer
}
from
'
@react-navigation/native
'
;
import
MemoDetails
from
'
./screens/MemoDetails
'
;
import
MemoDetails
from
'
./screens/MemoDetails
'
;
...
...
Monthly.js
View file @
4e3a96be
import
React
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
Calendar
from
'
./components/Calendar
'
;
import
Calendar
from
'
./components/Calendar
'
;
import
calApi
from
'
./db/calendarInfo.api
'
;
const
Montly
=
({
navigation
})
=>
{
const
Montly
=
({
navigation
})
=>
{
const
getData
=
async
()
=>
{
try
{
const
totalM
=
await
calApi
.
getFullData
()
console
.
log
(
'
db res
'
,
totalM
)
}
catch
(
error
)
{
console
.
log
(
'
error in getData
'
,
error
)
}
}
useEffect
(()
=>
{
getData
()
},
[])
return
(
return
(
<
Calendar
navigation
=
{
navigation
}
/
>
<
Calendar
navigation
=
{
navigation
}
MData
=
{
totalM
}
/
>
)
)
}
}
...
...
components/Calendar.js
View file @
4e3a96be
...
@@ -38,7 +38,7 @@ const INIT_Data = [
...
@@ -38,7 +38,7 @@ const INIT_Data = [
},
},
];
];
function
Calendar
({
navigation
})
{
function
Calendar
({
navigation
,
MData
})
{
const
date
=
new
Date
();
const
date
=
new
Date
();
const
[
year
,
setYear
]
=
useState
(
date
.
getFullYear
());
const
[
year
,
setYear
]
=
useState
(
date
.
getFullYear
());
const
[
month
,
setMonth
]
=
useState
(
date
.
getMonth
());
const
[
month
,
setMonth
]
=
useState
(
date
.
getMonth
());
...
@@ -71,9 +71,9 @@ function Calendar({ navigation }) {
...
@@ -71,9 +71,9 @@ function Calendar({ navigation }) {
}
}
//DB 데이터와 날짜 비교
//DB 데이터와 날짜 비교
for
(
let
i
=
0
;
i
<
INIT_
Data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
M
Data
.
length
;
i
++
)
{
const
str
=
INIT_
Data
[
i
].
date
const
str
=
M
Data
[
i
].
date
DBDates
.
push
({
date
:
new
Date
(
Number
(
str
.
slice
(
0
,
4
)),
Number
(
str
.
slice
(
5
,
7
))
-
1
,
Number
(
str
.
slice
(
8
,
10
))),
type
:
INIT_
Data
[
i
].
type
})
DBDates
.
push
({
date
:
new
Date
(
Number
(
str
.
slice
(
0
,
4
)),
Number
(
str
.
slice
(
5
,
7
))
-
1
,
Number
(
str
.
slice
(
8
,
10
))),
type
:
M
Data
[
i
].
type
})
}
}
for
(
let
i
=
0
;
i
<
Dates
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
Dates
.
length
;
i
++
)
{
...
@@ -99,7 +99,7 @@ function Calendar({ navigation }) {
...
@@ -99,7 +99,7 @@ function Calendar({ navigation }) {
color
=
'
#a9a9a9
'
color
=
'
#a9a9a9
'
}
}
return
(
return
(
<
DateItem
dateitem
=
{
item
}
textColor
=
{{
color
}}
onPress
=
{()
=>
navigation
.
navigate
(
'
DetailInfo
'
,
item
.
date
)}
flatListHeight
=
{
flatListHeight
/
(
Dates
.
length
/
7
)}
/
>
<
DateItem
dateitem
=
{
item
}
textColor
=
{{
color
}}
onPress
=
{()
=>
navigation
.
navigate
(
'
DetailInfo
'
,
item
.
date
)}
flatListHeight
=
{
flatListHeight
/
(
Dates
.
length
/
7
)}
/
>
)
)
}
}
const
prevBtn
=
()
=>
{
const
prevBtn
=
()
=>
{
...
...
db/calendarInfo.api.js
0 → 100644
View file @
4e3a96be
import
{
DEBUG
,
enablePromise
}
from
'
react-native-sqlite-storage
'
;
import
getDb
from
'
./moneyDB
'
DEBUG
(
true
);
enablePromise
(
true
);
const
getFullData
=
async
()
=>
{
const
db
=
await
getDb
();
return
new
Promise
((
res
,
rej
)
=>
{
db
.
transaction
(
async
(
tx
)
=>
{
console
.
log
(
'
월간 데이터
'
);
const
[
txn
,
results
]
=
await
tx
.
executeSql
(
'
SELECT * FROM money WHERE date BETWEEN "2021-07-01" AND "2021-07-31"
'
);
const
temp
=
[];
for
(
let
i
=
0
;
i
<
results
.
rows
.
length
;
i
++
)
{
console
.
log
(
'
item check
'
,
results
.
rows
.
item
(
i
));
if
(
results
.
rows
.
item
(
i
).
type
==
'
수입
'
)
{
temp
.
push
({
date
:
results
.
rows
.
item
(
i
).
date
,
type
:
{
'
input
'
:
results
.
rows
.
item
(
i
).
price
}
})
}
if
(
results
.
rows
.
item
(
i
).
type
==
'
지출
'
)
{
temp
.
push
({
date
:
results
.
rows
.
item
(
i
).
date
,
type
:
{
'
output
'
:
results
.
rows
.
item
(
i
).
price
}
})
}
}
console
.
log
(
'
temp1
'
,
temp
)
temp
.
sort
(
function
(
a
,
b
)
{
return
a
.
date
<
b
.
date
?
-
1
:
a
.
date
>
b
.
date
?
1
:
0
;
})
const
temp2
=
[
temp
[
0
]]
for
(
let
i
=
1
;
i
<
temp
.
length
;
i
++
)
{
if
(
temp
[
i
].
date
===
temp
[
i
-
1
].
date
)
{
let
lastObj
=
temp2
.
pop
()
let
newObj
=
lastObj
.
type
for
(
const
key
in
temp
[
i
].
type
)
{
let
data
=
0
if
(
newObj
.
hasOwnProperty
(
key
))
{
console
.
log
(
'
둘이 더할거임
'
,
temp
[
i
].
date
,
newObj
[
key
],
'
+
'
,
temp
[
i
].
type
[
key
],
data
)
data
=
newObj
[
key
]
+
temp
[
i
].
type
[
key
]
newObj
[
key
]
=
data
}
else
{
newObj
[
key
]
=
temp
[
i
].
type
[
key
]
}
console
.
log
(
'
TETETET
'
,
temp
[
i
].
date
,
newObj
)
}
temp2
.
push
({
date
:
temp
[
i
].
date
,
type
:
newObj
})
}
else
{
temp2
.
push
(
temp
[
i
])
}
}
console
.
log
(
'
temp2
'
,
temp2
)
res
(
temp2
);
})
})
}
const
calApi
=
{
getFullData
}
export
default
calApi
;
\ No newline at end of file
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