-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#6 attendancebook - Attendance list
- Loading branch information
Showing
19 changed files
with
360 additions
and
120 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { GET_COURSEDATES, GET_ATTENDANCEBOOK, PUT_COURSEDATES, PUT_ATTENDANCEBOOK } from './types' | ||
|
||
import AttendanceService from '../services/AttendanceService' | ||
|
||
export const getCourseDates = courseId => async dispatch => { | ||
try { | ||
const res = await AttendanceService.getCourseDates(courseId) | ||
console.log(res.data.data) | ||
dispatch({ | ||
type: GET_COURSEDATES, | ||
payload: res.data.data, | ||
}) | ||
return Promise.resolve(res.data.data) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} | ||
|
||
export const getAttendanceBook = courseId => async dispatch => { | ||
try { | ||
const res = await AttendanceService.getAttendanceBook(courseId) | ||
console.log(res.data.data) | ||
dispatch({ | ||
type: GET_ATTENDANCEBOOK, | ||
payload: res.data.data, | ||
}) | ||
return Promise.resolve(res.data.data) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} | ||
|
||
export const putCourseDates = courseDateId => async dispatch => { | ||
try { | ||
const res = await AttendanceService.putCourseDates(courseDateId) | ||
console.log(res.data.data) | ||
dispatch({ | ||
type: PUT_COURSEDATES, | ||
payload: res.data.data, | ||
}) | ||
return Promise.resolve(res.data.data) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} | ||
|
||
export const putAttendanceBook = courseDateId => async dispatch => { | ||
try { | ||
const res = await AttendanceService.put(courseDateId) | ||
dispatch({ | ||
type: PUT_ATTENDANCEBOOK, | ||
payload: res.data.data, | ||
}) | ||
return Promise.resolve(res.data.data) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import courseDate from '../../utils/courseDateIdtoString' | ||
|
||
export default function getColumns(courseDates) { | ||
const columnsState = [ | ||
{ | ||
headerAlign: 'center', | ||
field: '학번', | ||
headerName: '학번', | ||
width: 120, | ||
editable: false, | ||
sortable: false, | ||
align: 'center', | ||
headAlign: 'center', | ||
}, | ||
{ | ||
headerAlign: 'center', | ||
field: '이름', | ||
headerName: '이름', | ||
width: 120, | ||
editable: false, | ||
align: 'center', | ||
}, | ||
] | ||
|
||
for (let i = 0; i < courseDates.length; i += 1) { | ||
columnsState.push({ | ||
field: `${courseDate(courseDates, i)}`, | ||
headerName: `${courseDate(courseDates, i)}`, | ||
width: 180, | ||
editable: true, | ||
sortable: false, | ||
type: 'boolean', | ||
align: 'center', | ||
}) | ||
} | ||
console.log(columnsState) | ||
return columnsState | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import courseDate from '../../utils/courseDateIdtoString' | ||
|
||
export default function getRows(courseDates, attendanceBook) { | ||
const rowsState = [] | ||
const studentsState = [] | ||
const courseDateState = {} | ||
|
||
for (let i = 0; i < attendanceBook[0].length; i += 1) { | ||
studentsState.push({ id: i + 1, 이름: `${attendanceBook[0][i].name}`, 학번: `${attendanceBook[0][i].studentId}` }) | ||
} | ||
for (let i = 0; i < studentsState.length; i += 1) { | ||
for (let j = 1; j < attendanceBook.length; j += 1) { | ||
courseDateState[courseDate(courseDates, j - 1)] = attendanceBook[j][i] | ||
} | ||
rowsState.push({ ...studentsState[i], ...courseDateState }) | ||
} | ||
console.log(rowsState) | ||
return rowsState | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.