forked from ytgov/sfa-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from icefoganalytics/student-financial-aid--is…
…sues-2/view-submitted-applications-and-their-current-status View Submitted Applications and Their Current Status
- Loading branch information
Showing
37 changed files
with
1,971 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Request, Response, NextFunction } from "express" | ||
|
||
export default class BaseController { | ||
protected request: Request | ||
protected response: Response | ||
protected next: NextFunction | ||
|
||
constructor(request: Request, response: Response, next: NextFunction) { | ||
this.request = request | ||
this.response = response | ||
this.next = next | ||
} | ||
|
||
protected get params() { | ||
return this.request.params | ||
} | ||
} |
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 { Request, Response, NextFunction } from "express" | ||
|
||
import BaseController from "@/controllers/base-controller" | ||
|
||
export function routedTo<T extends typeof BaseController>( | ||
controllerClass: T, | ||
method: string & keyof InstanceType<T> | ||
) { | ||
return (req: Request, res: Response, next: NextFunction) => { | ||
const controllerInstance = new controllerClass(req, res, next) as InstanceType<T> | ||
const unboundControllerMethod = controllerInstance[method] | ||
|
||
if (typeof unboundControllerMethod === "function") { | ||
return unboundControllerMethod.call(controllerInstance) | ||
} else { | ||
throw new Error(`Method ${method} is not a function on the provided controller class`) | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/api/controllers/portal/students/student-application-drafts-controller.ts
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,41 @@ | ||
import BaseController from "@/controllers/base-controller" | ||
|
||
import ApplicationDraftsSerializer from "@/serializers/application-drafts-serializer"; | ||
import StudentApplicationDraftsService from "@/services/portal/students/student-application-drafts-service"; | ||
|
||
export default class StudentApplicationDraftsController extends BaseController { | ||
listStudentApplicationDrafts() { | ||
const studentId = parseInt(this.params.studentId) | ||
|
||
const applicationService = new StudentApplicationDraftsService({ studentId }) | ||
return applicationService | ||
.getApplicationDrafts() | ||
.then((applicationDrafts) => { | ||
const applicationDraftsSerializer = new ApplicationDraftsSerializer(applicationDrafts); | ||
const data = applicationDraftsSerializer.asListView() | ||
this.response.json({ data }) | ||
}) | ||
.catch((error: { message: string }) => { | ||
this.response.status(404).json({ error: error.message }) | ||
}) | ||
} | ||
|
||
getStudentApplicationDraft() { | ||
const studentId = parseInt(this.params.studentId) | ||
const applicationDraftId = parseInt(this.params.applicationDraftId) | ||
|
||
const applicationService = new StudentApplicationDraftsService({ studentId, applicationDraftId }) | ||
return applicationService | ||
.getApplicationDraft() | ||
.then((applicationDraft) => { | ||
const applicationDraftsSerializer = new ApplicationDraftsSerializer(applicationDraft); | ||
const data = applicationDraftsSerializer.asDetailedView() | ||
this.response.json({ data }) | ||
}) | ||
.catch((error: { message: string }) => { | ||
this.response.status(404).json({ error: error.message }) | ||
}) | ||
} | ||
|
||
#getStudent(studentId: number) {} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/api/controllers/portal/students/student-applications-controller.ts
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,41 @@ | ||
import BaseController from "@/controllers/base-controller" | ||
|
||
import ApplicationsSerializer from "@/serializers/applications-serializer" | ||
import StudentApplicationsService from "@/services/portal/students/student-applications-service" | ||
|
||
export default class StudentApplicationsController extends BaseController { | ||
listStudentApplications() { | ||
const studentId = parseInt(this.params.studentId) | ||
|
||
const applicationService = new StudentApplicationsService({ studentId }) | ||
return applicationService | ||
.getApplications() | ||
.then((applications) => { | ||
const applicationSerializer = new ApplicationsSerializer(applications) | ||
const data = applicationSerializer.asListView() | ||
this.response.json({ data }) | ||
}) | ||
.catch((error: { message: string }) => { | ||
this.response.status(404).json({ error: error.message }) | ||
}) | ||
} | ||
|
||
getStudentApplication() { | ||
const studentId = parseInt(this.params.studentId) | ||
const applicationId = parseInt(this.params.applicationId) | ||
|
||
const applicationService = new StudentApplicationsService({ studentId, applicationId }) | ||
return applicationService | ||
.getApplication() | ||
.then((application) => { | ||
const applicationSerializer = new ApplicationsSerializer(application) | ||
const data = applicationSerializer.asDetailedView() | ||
this.response.json({ data }) | ||
}) | ||
.catch((error: { message: string }) => { | ||
this.response.status(404).json({ error: error.message }) | ||
}) | ||
} | ||
|
||
#getStudent(studentId: number) {} | ||
} |
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,31 @@ | ||
// TODO: question whether this should be in the database at all. | ||
// And if so, why is it its own table? | ||
enum AddressTypes { | ||
HOME = 1, | ||
MAILING = 2, | ||
SCHOOL = 3, | ||
PARENT = 4, | ||
} | ||
|
||
export default class AddressType { | ||
id: number | ||
description: string | ||
isActive: boolean | ||
|
||
constructor({ | ||
id, | ||
description, | ||
isActive, | ||
}: { | ||
id: number | ||
description: string | ||
isActive: boolean | ||
}) { | ||
this.id = id | ||
this.description = description | ||
this.isActive = isActive | ||
} | ||
|
||
// not in database | ||
static readonly Types = AddressTypes | ||
} |
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,11 @@ | ||
export default interface ApplicationDraft { | ||
id: number | ||
studentId: number | ||
academicYearId: number | ||
createDate: Date | ||
updateDate: Date | ||
isActive?: boolean | ||
applicationJson: string | ||
submitDate?: Date | ||
status?: string | ||
} |
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.