Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-049
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-049
2021-049
Commits
c6aac8e4
Commit
c6aac8e4
authored
Jul 09, 2021
by
Gihan76
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Financial Details view, update, delete routes and models done!
parent
68edea86
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
47 deletions
+48
-47
BackEnd/WebBackEnd/models/finance.model.js
BackEnd/WebBackEnd/models/finance.model.js
+0
-8
BackEnd/WebBackEnd/routes/finance.route.js
BackEnd/WebBackEnd/routes/finance.route.js
+31
-3
WebFrontEnd/smartcoach-frontend/src/Components/Admin/Dashboard.js
...End/smartcoach-frontend/src/Components/Admin/Dashboard.js
+7
-4
WebFrontEnd/smartcoach-frontend/src/Components/Admin/add_financial_details.js
...ch-frontend/src/Components/Admin/add_financial_details.js
+10
-32
No files found.
BackEnd/WebBackEnd/models/finance.model.js
View file @
c6aac8e4
...
...
@@ -2,7 +2,6 @@ const mongoose = require('mongoose');
const
Schema
=
mongoose
.
Schema
;
let
FinanceSchema
=
new
Schema
({
// name : {type:String,required:true},
account_month
:
{
type
:
String
,
required
:
true
},
direct_income
:
{
type
:
String
,
required
:
true
},
indirect_income
:
{
type
:
String
,
required
:
true
},
...
...
@@ -15,13 +14,6 @@ let FinanceSchema = new Schema({
timestamps
:
true
});
// function getPrice(num){
// return (num/100).toFixed(2);
// }
//
// function setPrice(num){
// return num*100;
// }
const
Finance
=
mongoose
.
model
(
'
finance
'
,
FinanceSchema
);
...
...
BackEnd/WebBackEnd/routes/finance.route.js
View file @
c6aac8e4
const
router
=
require
(
'
express
'
).
Router
();
//import models
const
Finance
=
require
(
'
../models/finance.model
'
);
let
Tutor
=
require
(
'
../models/tutor.user.model
'
);
...
...
@@ -17,7 +16,6 @@ router.route('/').get((req ,res) => {
});
router
.
route
(
'
/store
'
).
post
((
req
,
res
)
=>
{
// const tutname = req.body.tutname;
const
account_month
=
req
.
body
.
account_month
;
const
direct_income
=
req
.
body
.
direct_income
;
const
indirect_income
=
req
.
body
.
indirect_income
;
...
...
@@ -28,7 +26,6 @@ router.route('/store').post((req ,res) =>{
const
gross_revenue
=
req
.
body
.
gross_revenue
;
const
newFinancialDetails
=
new
Finance
({
// tutname,
account_month
,
direct_income
,
indirect_income
,
...
...
@@ -44,4 +41,35 @@ router.route('/store').post((req ,res) =>{
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
});
router
.
route
(
'
/:id
'
).
get
((
req
,
res
)
=>
{
Finance
.
findById
(
req
.
params
.
id
)
.
then
(
financedetails
=>
res
.
json
(
financedetails
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
});
router
.
route
(
'
/update/:id
'
).
post
((
req
,
res
)
=>
{
Finance
.
findById
(
req
.
params
.
id
)
.
then
(
financialDetails
=>
{
financialDetails
.
account_month
=
req
.
body
.
account_month
;
financialDetails
.
direct_income
=
req
.
body
.
direct_income
;
financialDetails
.
indirect_income
=
req
.
body
.
indirect_income
;
financialDetails
.
total_income
=
req
.
body
.
total_income
;
financialDetails
.
direct_expenses
=
req
.
body
.
direct_expenses
;
financialDetails
.
indirect_expenses
=
req
.
body
.
indirect_expenses
;
financialDetails
.
total_expenses
=
req
.
body
.
total_expenses
;
financialDetails
.
gross_revenue
=
req
.
body
.
gross_revenue
;
financialDetails
.
save
()
.
then
(()
=>
res
.
json
(
'
Finance Details Updated!
'
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
});
router
.
route
(
'
/:id
'
).
delete
((
req
,
res
)
=>
{
Finance
.
findByIdAndDelete
(
req
.
params
.
id
)
.
then
(()
=>
res
.
json
(
'
Financial Details Deleted!
'
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
});
module
.
exports
=
router
;
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/Admin/Dashboard.js
View file @
c6aac8e4
...
...
@@ -3,6 +3,8 @@ import {NavLink, Route} from 'react-router-dom';
import
{
Link
}
from
"
react-router-dom
"
;
import
AddFinance
from
'
./add_financial_details
'
;
import
ViewFinance
from
'
./view_financial_details
'
;
import
EditFinance
from
'
./edit_financial_details
'
;
export
default
class
Dashboard
extends
Component
{
render
()
{
...
...
@@ -392,16 +394,16 @@ export default class Dashboard extends Component {
<
/a
>
<
ul
>
<
li
>
<
NavLink
activeClassName
=
'
mm-active
'
to
=
{
"
/admin/finance/add
"
}
>
<
NavLink
activeClassName
=
'
mm-active
'
to
=
{
"
/admin/finance/add
/
"
}
>
<
i
className
=
"
metismenu-icon
"
><
/i
>
Add
Details
<
/NavLink
>
<
/li
>
<
li
>
<
a
href
=
"
#
"
>
<
NavLink
to
=
{
"
/admin/finance/
"
}
>
<
i
className
=
"
metismenu-icon
"
><
/i
>
Manage
Details
<
/
a
>
<
/
NavLink
>
<
/li
>
<
/ul
>
<
/li
>
...
...
@@ -438,8 +440,9 @@ export default class Dashboard extends Component {
<
div
className
=
"
app-main__inner
"
>
{
/* ------------------------------Content---------------------------------------- */
}
<
Route
path
=
"
/admin/finance/
"
exact
component
=
{
ViewFinance
}
/
>
<
Route
path
=
"
/admin/finance/add
"
exact
component
=
{
AddFinance
}
/
>
<
Route
path
=
{
"
/admin/finance/edit/:id
"
}
exact
component
=
{
EditFinance
}
/
>
<
/div
>
{
/* Footer */
}
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Admin/add_financial_details.js
View file @
c6aac8e4
import
React
,
{
Component
}
from
"
react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
axios
from
"
axios
"
;
// const TutorsNames = props => (
// <option>{props.tutors}</option>
// );
export
default
class
AddFinancialDetails
extends
Component
{
// nameList(){
// return this.state.tutors.map(currentcateogory => {
// return <TutorsNames name={currentcateogory} key={currentcateogory._id} />;
// })
// }
constructor
(
props
)
{
super
(
props
);
...
...
@@ -49,31 +38,20 @@ export default class AddFinancialDetails extends Component{
gross_revenue
:
this
.
state
.
gross_revenue
}
console
.
log
(
`Form submitted:`
);
console
.
log
(
`account_month:
${
this
.
state
.
account_month
}
`
);
console
.
log
(
`direct_income:
${
this
.
state
.
direct_income
}
`
);
console
.
log
(
`indirect_income:
${
this
.
state
.
indirect_income
}
`
);
console
.
log
(
`total_income:
${
this
.
state
.
total_income
}
`
);
console
.
log
(
`direct_expenses:
${
this
.
state
.
direct_expenses
}
`
);
console
.
log
(
`indirect_expenses:
${
this
.
state
.
indirect_expenses
}
`
);
console
.
log
(
`total_expenses:
${
this
.
state
.
total_expenses
}
`
);
console
.
log
(
`gross_revenue:
${
this
.
state
.
gross_revenue
}
`
);
// console.log(financialDetails);
// axios({
// method: 'post',
// url: 'http://localhost:5000/admin/finance/store',
// headers: {},
// data: financialDetails,
// }).then(res => console.log(res.data));
// console.log(`Form submitted:`);
// console.log(`account_month: ${this.state.account_month}`);
// console.log(`direct_income: ${this.state.direct_income}`);
// console.log(`indirect_income: ${this.state.indirect_income}`);
// console.log(`total_income: ${this.state.total_income}`);
// console.log(`direct_expenses: ${this.state.direct_expenses}`);
// console.log(`indirect_expenses: ${this.state.indirect_expenses}`);
// console.log(`total_expenses: ${this.state.total_expenses}`);
// console.log(`gross_revenue: ${this.state.gross_revenue}`);
axios
.
post
(
'
http://localhost:5000/admin/finance/store
'
,
financialDetails
)
.
then
(
res
=>
console
.
log
(
res
.
data
));
// .catch(//swal("Good job!", "You clicked the button!", "warning"
// );
// window.location = '/admin/mstaff'
;
e
.
target
.
reset
()
;
}
// componentDidMount() {
...
...
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