38 lines
2.0 KiB
TypeScript
38 lines
2.0 KiB
TypeScript
import { Serializable, SerializationTransformer } from "@/serialization/types";
|
|
import { Edition } from "@/data/edition";
|
|
import { momentSerializationTransformer } from "@/serialization/moment";
|
|
import { Moment } from "moment-timezone";
|
|
|
|
export const editionSerializationTransformer: SerializationTransformer<Edition> = {
|
|
transform(subject: Edition, context?: unknown): Serializable<Edition> {
|
|
return {
|
|
course: subject.course,
|
|
minimumInternshipHours: subject.minimumInternshipHours,
|
|
maximumInternshipHours: subject.maximumInternshipHours,
|
|
proposalDeadline: momentSerializationTransformer.transform(subject.proposalDeadline),
|
|
reportingEnd: momentSerializationTransformer.transform(subject.reportingEnd),
|
|
reportingStart: momentSerializationTransformer.transform(subject.reportingStart),
|
|
startDate: momentSerializationTransformer.transform(subject.startDate),
|
|
endDate: momentSerializationTransformer.transform(subject.endDate),
|
|
schema: subject.schema,
|
|
types: subject.types,
|
|
program: subject.program
|
|
}
|
|
},
|
|
reverseTransform(subject: Serializable<Edition>, context?: unknown): Edition {
|
|
return {
|
|
course: subject.course,
|
|
minimumInternshipHours: subject.minimumInternshipHours,
|
|
maximumInternshipHours: subject.maximumInternshipHours,
|
|
proposalDeadline: momentSerializationTransformer.reverseTransform(subject.proposalDeadline) as Moment,
|
|
reportingEnd: momentSerializationTransformer.reverseTransform(subject.reportingEnd) as Moment,
|
|
reportingStart: momentSerializationTransformer.reverseTransform(subject.reportingStart) as Moment,
|
|
startDate: momentSerializationTransformer.reverseTransform(subject.startDate) as Moment,
|
|
endDate: momentSerializationTransformer.reverseTransform(subject.endDate) as Moment,
|
|
schema: subject.schema as any,
|
|
types: subject.types,
|
|
program: subject.program
|
|
}
|
|
},
|
|
}
|