Rework providers and add models for student related things
This commit is contained in:
		
							parent
							
								
									ee44cbf2f7
								
							
						
					
					
						commit
						516cb73367
					
				
							
								
								
									
										9
									
								
								src/data/course.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/data/course.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					import { InternshipProgramEntry } from "./internship";
 | 
				
			||||||
 | 
					import { Semester } from "./student";
 | 
				
			||||||
 | 
					import { Identifiable } from "./common";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface Course extends Identifiable {
 | 
				
			||||||
 | 
					    name: string,
 | 
				
			||||||
 | 
					    desiredSemesters: Semester[],
 | 
				
			||||||
 | 
					    possibleProgramEntries: InternshipProgramEntry[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/data/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/data/index.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					export * from './common'
 | 
				
			||||||
 | 
					export * from './company'
 | 
				
			||||||
 | 
					export * from './course'
 | 
				
			||||||
 | 
					export * from './internship'
 | 
				
			||||||
 | 
					export * from './student'
 | 
				
			||||||
@ -1,12 +1,26 @@
 | 
				
			|||||||
import { Moment } from "moment";
 | 
					import { Moment } from "moment";
 | 
				
			||||||
import { Nullable } from "../helpers";
 | 
					import { Nullable } from "../helpers";
 | 
				
			||||||
 | 
					import { Identifiable } from "./common";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export enum InternshipType { }
 | 
					export enum InternshipType {
 | 
				
			||||||
export enum InternshipProgram { }
 | 
					    FreeInternship = "FreeInternship",
 | 
				
			||||||
 | 
					    GraduateInternship = "GraduateInternship",
 | 
				
			||||||
 | 
					    FreeApprenticeship = "FreeApprenticeship",
 | 
				
			||||||
 | 
					    PaidApprenticeship = "PaidApprenticeship",
 | 
				
			||||||
 | 
					    ForeignInternship = "ForeignInternship",
 | 
				
			||||||
 | 
					    UOP = "UOP",
 | 
				
			||||||
 | 
					    UD = "UD",
 | 
				
			||||||
 | 
					    UZ = "UZ",
 | 
				
			||||||
 | 
					    Other = "Other",
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface Internship {
 | 
					export interface InternshipProgramEntry extends Identifiable {
 | 
				
			||||||
 | 
					    description: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface Internship extends Identifiable {
 | 
				
			||||||
    type: InternshipType;
 | 
					    type: InternshipType;
 | 
				
			||||||
    program: InternshipProgram;
 | 
					    program: InternshipProgramEntry[];
 | 
				
			||||||
    startDate: Moment;
 | 
					    startDate: Moment;
 | 
				
			||||||
    endDate: Moment;
 | 
					    endDate: Moment;
 | 
				
			||||||
    isAccepted: boolean;
 | 
					    isAccepted: boolean;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								src/data/student.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/data/student.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					import { Course } from "./course";
 | 
				
			||||||
 | 
					import { Identifiable } from "./common";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type Semester = number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface Student extends Identifiable{
 | 
				
			||||||
 | 
					    name: string;
 | 
				
			||||||
 | 
					    surname: string;
 | 
				
			||||||
 | 
					    email: string;
 | 
				
			||||||
 | 
					    albumNumber: string;
 | 
				
			||||||
 | 
					    semester: Semester;
 | 
				
			||||||
 | 
					    course: Course;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,21 +1,12 @@
 | 
				
			|||||||
import React from "react";
 | 
					import React from "react";
 | 
				
			||||||
import { useFormik } from "formik";
 | 
					 | 
				
			||||||
import { emptyInternship, Internship } from "../data/internship";
 | 
					 | 
				
			||||||
import { Nullable } from "../helpers";
 | 
					 | 
				
			||||||
import { TextField } from "@material-ui/core";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type InternshipFormProps = {
 | 
					export type InternshipFormProps = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const InternshipForm: React.FunctionComponent<InternshipFormProps> = props => {
 | 
					export const InternshipForm: React.FunctionComponent<InternshipFormProps> = props => {
 | 
				
			||||||
    const formik = useFormik<Nullable<Internship>>({ onSubmit: values => console.log(values), initialValues: emptyInternship });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const formikProps = (prop: keyof Internship) => ({ onChange: formik.handleChange, value: formik.values[prop], name: prop })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
        <div className="internship-form">
 | 
					        <div className="internship-form">
 | 
				
			||||||
            <TextField {...formikProps("startDate")} />
 | 
					 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import React, { HTMLProps, useEffect, useMemo, useState } from "react";
 | 
					import React, { HTMLProps, useEffect, useMemo, useState } from "react";
 | 
				
			||||||
import { BranchOffice, Company, emptyAddress, emptyBranchOffice, emptyCompany, formatAddress } from "../data/company";
 | 
					import { BranchOffice, Company, emptyAddress, emptyBranchOffice, emptyCompany, formatAddress } from "../data/company";
 | 
				
			||||||
import { sampleCompanies } from "../provider/company";
 | 
					import { sampleCompanies } from "../provider/dummy";
 | 
				
			||||||
import { Autocomplete } from "@material-ui/lab";
 | 
					import { Autocomplete } from "@material-ui/lab";
 | 
				
			||||||
import { Grid, TextField, Typography } from "@material-ui/core";
 | 
					import { Grid, TextField, Typography } from "@material-ui/core";
 | 
				
			||||||
import { formFieldProps } from "./helpers";
 | 
					import { formFieldProps } from "./helpers";
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
import { Company } from "../data/company";
 | 
					import { Company } from "../../data/company";
 | 
				
			||||||
import { makeIdSequence } from "./helpers";
 | 
					import { makeIdSequence } from "./helpers";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const companySequence = makeIdSequence();
 | 
					const companySequence = makeIdSequence();
 | 
				
			||||||
							
								
								
									
										15
									
								
								src/provider/dummy/helpers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/provider/dummy/helpers.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					import { Identifiable } from "../../data";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SequenceGenerator = {
 | 
				
			||||||
 | 
					    (): string;
 | 
				
			||||||
 | 
					    assignIds<T>(objects: T[]): T[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const makeIdSequence = (start: number = 1): SequenceGenerator => {
 | 
				
			||||||
 | 
					    let i = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const sequence = () => (i++).toString();
 | 
				
			||||||
 | 
					    sequence.assignIds = <T extends Identifiable>(objects: T[]): T[] => objects.map(obj => ({ ...obj, id: sequence() }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return sequence as SequenceGenerator;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										1
									
								
								src/provider/dummy/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/provider/dummy/index.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					export * from './company'
 | 
				
			||||||
							
								
								
									
										39
									
								
								src/provider/dummy/student.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/provider/dummy/student.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					import { Course, InternshipProgramEntry, Student } from "../../data"
 | 
				
			||||||
 | 
					import { makeIdSequence } from "./helpers";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const programEntryIdSequence = makeIdSequence();
 | 
				
			||||||
 | 
					const courseIdSequence = makeIdSequence();
 | 
				
			||||||
 | 
					const studentIdSequence = makeIdSequence();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const sampleProgramEntries: InternshipProgramEntry[] = programEntryIdSequence.assignIds([
 | 
				
			||||||
 | 
					    { description: "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych." },
 | 
				
			||||||
 | 
					    { description: "Implementacja polityki bezpieczeństwa informacji w firmie lub instytucji, instalacja ochrony antywirusowej, konfiguracja zapór ogniowych." },
 | 
				
			||||||
 | 
					    { description: "Instalacja, konfiguracja i administracja oprogramowania, w szczególnościsystemów operacyjnychiserwerów aplikacji." },
 | 
				
			||||||
 | 
					    { description: "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań." },
 | 
				
			||||||
 | 
					    { description: "Testowanie oprogramowania, także z wykorzystaniem narzędzi do testowania automatycznego." },
 | 
				
			||||||
 | 
					    { description: "Wykorzystanie otwartych komponentów programowych z uwzględnieniem prawnych zależności pomiędzy nimi a produktem wynikowym." },
 | 
				
			||||||
 | 
					    { description: "Projektowanie i implementacja baz danych oraz badanie ich wydajności." },
 | 
				
			||||||
 | 
					    { description: "Posługiwanie się zaawansowanymi metodami i technologiami przetwarzania, składowania, transformacji i analizy danych(Big Data, Business Intelligence, hurtownie danych)" },
 | 
				
			||||||
 | 
					    { description: "Projektowanie i prototypowaniezaawansowanychinterfejsów użytkownika. " },
 | 
				
			||||||
 | 
					    { description: "Posługiwanie się zaawansowanymi narzędziami informatycznymi do przetwarzania plików dźwiękowych, obrazów i wideo." },
 | 
				
			||||||
 | 
					    { description: "Konfiguracjaurządzeń zewnętrznych komputera, rozbudowa i modyfikacja jego struktury modułówi urządzeń wewnętrznych." },
 | 
				
			||||||
 | 
					    { description: "Przygotowywanie i testowanie oprogramowania prostych mikrokontrolerów i systemów wbudowanych." },
 | 
				
			||||||
 | 
					    { description: "Przygotowywanie i analiza dokumentacjitechnicznej przedsięwzięć informatycznych,wykorzystanie modeli i narzędzi zarządzania dla e-biznesu." },
 | 
				
			||||||
 | 
					]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const sampleCourse: Course = {
 | 
				
			||||||
 | 
					    id: courseIdSequence(),
 | 
				
			||||||
 | 
					    name: "Informatyka",
 | 
				
			||||||
 | 
					    desiredSemesters: [6],
 | 
				
			||||||
 | 
					    possibleProgramEntries: sampleProgramEntries,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const sampleStudent: Student = {
 | 
				
			||||||
 | 
					    id: studentIdSequence(),
 | 
				
			||||||
 | 
					    name: "Jan",
 | 
				
			||||||
 | 
					    surname: "Kowalski",
 | 
				
			||||||
 | 
					    albumNumber: "123456",
 | 
				
			||||||
 | 
					    email: "s123456@student.pg.edu.pl",
 | 
				
			||||||
 | 
					    course: sampleCourse,
 | 
				
			||||||
 | 
					    semester: 4,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,4 +0,0 @@
 | 
				
			|||||||
export const makeIdSequence = (start: number = 1) => {
 | 
					 | 
				
			||||||
    let i = start;
 | 
					 | 
				
			||||||
    return () => i++;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										7
									
								
								src/provider/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/provider/index.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					import * as dummy from './dummy'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export {
 | 
				
			||||||
 | 
					    dummy,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default dummy;
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user