forked from scg-unibe-ch/ese2018-team2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into model_relationship
- Loading branch information
Showing
15 changed files
with
405 additions
and
16 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ enum ApplicationState { | |
PENDING | ||
DECLINED | ||
APPROVED | ||
|
||
} | ||
|
||
input CreateJobInput { | ||
|
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
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,47 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class Init1541366395158 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query( | ||
`CREATE TABLE "organizations" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" text NOT NULL, CONSTRAINT "PK_6b031fcd0863e3f6b44230163f9" PRIMARY KEY ("id"))` | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "users" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "firstname" text NOT NULL, "lastname" text NOT NULL, "phone" text NOT NULL, "email" text NOT NULL, "password" text NOT NULL, CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email"), CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY ("id"))` | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "jobs" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" text NOT NULL, "description" text NOT NULL, "salary" float NOT NULL, "start" date NOT NULL, "end" TIMESTAMP, "organizationId" uuid, CONSTRAINT "PK_cf0a6c42b72fcc7f7c237def345" PRIMARY KEY ("id"))` | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "roles" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" text NOT NULL, "description" text NOT NULL, CONSTRAINT "PK_c1433d71a4838793a49dcad46ab" PRIMARY KEY ("id"))` | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "bookmarks" ("usersId" uuid NOT NULL, "jobsId" uuid NOT NULL, CONSTRAINT "PK_59b0563d7b6f7758e9f369bb324" PRIMARY KEY ("usersId", "jobsId"))` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "jobs" ADD CONSTRAINT "FK_08bdc8b939f39e6d55b4c38cfb9" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id")` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "bookmarks" ADD CONSTRAINT "FK_b0075fdec79957795cd75fb7bb9" FOREIGN KEY ("usersId") REFERENCES "users"("id") ON DELETE CASCADE` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "bookmarks" ADD CONSTRAINT "FK_4d0391697f8d396f21846c8784a" FOREIGN KEY ("jobsId") REFERENCES "jobs"("id") ON DELETE CASCADE` | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query( | ||
`ALTER TABLE "bookmarks" DROP CONSTRAINT "FK_4d0391697f8d396f21846c8784a"` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "bookmarks" DROP CONSTRAINT "FK_b0075fdec79957795cd75fb7bb9"` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "jobs" DROP CONSTRAINT "FK_08bdc8b939f39e6d55b4c38cfb9"` | ||
); | ||
await queryRunner.query(`DROP TABLE "bookmarks"`); | ||
await queryRunner.query(`DROP TABLE "roles"`); | ||
await queryRunner.query(`DROP TABLE "jobs"`); | ||
await queryRunner.query(`DROP TABLE "users"`); | ||
await queryRunner.query(`DROP TABLE "organizations"`); | ||
} | ||
} |
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,56 @@ | ||
import {Button, Card, Header, Loader} from "semantic-ui-react"; | ||
import * as React from "react"; | ||
import {SingletonRouter} from "next/router"; | ||
import Link from "next/link"; | ||
import ApolloError from 'apollo-boost'; | ||
|
||
interface StudentJobCardProps { | ||
router?: SingletonRouter, | ||
job: { | ||
id: string, | ||
title: string, | ||
description: string | ||
}, | ||
loading: boolean, | ||
error: ApolloError; | ||
} | ||
|
||
|
||
const StudentJobCard: React.SFC<StudentJobCardProps> = ({router, job, loading, error}) => { | ||
|
||
if (loading) { | ||
return ( | ||
<Card> | ||
<Loader/> | ||
</Card> | ||
); | ||
} | ||
if (error) { | ||
return ( | ||
<Card> | ||
<Header as="h3">Ooops</Header> | ||
</Card> | ||
); | ||
} | ||
|
||
return ( | ||
<Card> | ||
<Card.Content> | ||
<Card.Header>{job.title}</Card.Header> | ||
<Card.Description> | ||
{job.description} | ||
</Card.Description> | ||
</Card.Content> | ||
<Card.Content extra> | ||
<div className='ui two buttons'> | ||
<Button icon="star"/> | ||
<Link href={{pathname: "/jobs/detail", query: {id: job.id}}}> | ||
<Button icon="eye"/> | ||
</Link> | ||
</div> | ||
</Card.Content> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default StudentJobCard; |
63 changes: 63 additions & 0 deletions
63
frontend/components/student/activity/StudentActivities.tsx
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,63 @@ | ||
import {SingletonRouter} from "next/router"; | ||
import * as React from "react"; | ||
import {Card, Header, Loader, Segment} from "semantic-ui-react"; | ||
import {ApolloError} from "apollo-boost"; | ||
import gql from "graphql-tag"; | ||
import {Query} from "react-apollo"; | ||
import StudentActivity from "./StudentActivity"; | ||
import StudentJobCard from "../StudentJobCard"; | ||
|
||
|
||
interface ActivitiesJobs { | ||
jobs: { | ||
id: string; | ||
title: string; | ||
description: string; | ||
organization: { id: string; name }; | ||
}[]; | ||
} | ||
|
||
|
||
interface StudentActivitiesProps { | ||
router?: SingletonRouter; | ||
loading: boolean; | ||
error: ApolloError; | ||
data: ActivitiesJobs; | ||
} | ||
|
||
export const GET_ACTIVITIES_JOBS = gql` | ||
query StudentActivities { | ||
jobs { | ||
id | ||
title | ||
description | ||
organization { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
`; | ||
|
||
|
||
const StudentActivities: React.SFC<StudentActivitiesProps> = ({router, loading, error, data}) => { | ||
return ( | ||
<Segment> | ||
<Header>My Activities</Header> | ||
<Card.Group itemsPerRow={3} centered> | ||
{data.jobs.map(job => ( | ||
<StudentActivity key={job.id} job={job} loading={loading} error={error}/> | ||
))} | ||
</Card.Group> | ||
</Segment> | ||
); | ||
}; | ||
|
||
|
||
export default () => ( | ||
<Query query={GET_ACTIVITIES_JOBS}> | ||
{({loading, error, data}) => ( | ||
<StudentActivities data={data} error={error} loading={loading}/> | ||
)} | ||
</Query> | ||
); |
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,46 @@ | ||
import * as React from "react"; | ||
import {Card, Header, Loader} from "semantic-ui-react"; | ||
import ApolloError from 'apollo-boost' | ||
|
||
interface StudentActivitiesProps { | ||
job: { | ||
id: string, | ||
title: string, | ||
description: string | ||
organisation: { | ||
id: string, | ||
name: string | ||
} | ||
}, | ||
loading: boolean, | ||
error: ApolloError | ||
} | ||
|
||
const StudentActivity: React.SFC<StudentActivitiesProps> = ({job, loading, error}) => { | ||
|
||
if (loading) { | ||
return ( | ||
<Card> | ||
<Loader/> | ||
</Card> | ||
); | ||
} | ||
if (error) { | ||
return ( | ||
<Card> | ||
<Header as="h3">Ooops</Header> | ||
</Card> | ||
); | ||
} | ||
|
||
return ( | ||
<Card> | ||
<Card.Content> | ||
<Card.Header>{job.title}</Card.Header> | ||
<Card.Meta>{job.description}</Card.Meta> | ||
</Card.Content> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default StudentActivity; |
18 changes: 18 additions & 0 deletions
18
frontend/components/student/dashboard/StudentDashboard.tsx
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,18 @@ | ||
import withAuthorization from "../../Auth/withAuthorization"; | ||
import Me from "../../Auth/Me"; | ||
import * as React from "react"; | ||
import {Container} from "semantic-ui-react"; | ||
import RecommendedJobs from "../recomendedjobs/RecommendedJobs"; | ||
import StudentActivities from "../activity/StudentActivities"; | ||
import StudentWatching from "../watching/StudentWatching"; | ||
|
||
const StudentDashboard = () => ( | ||
<Container> | ||
<Me/> | ||
<RecommendedJobs/> | ||
<StudentActivities/> | ||
<StudentWatching/> | ||
</Container> | ||
); | ||
|
||
export default withAuthorization(StudentDashboard); |
75 changes: 75 additions & 0 deletions
75
frontend/components/student/recomendedjobs/RecommendedJobs.tsx
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,75 @@ | ||
import StudentJobCard from "../StudentJobCard"; | ||
import * as React from "react"; | ||
import {Query} from "react-apollo"; | ||
import gql from "graphql-tag"; | ||
import {Card, Header, Loader, Segment} from "semantic-ui-react"; | ||
import {ApolloError} from "apollo-boost"; | ||
|
||
export const GET_RECOMMENDED_JOBS = gql` | ||
query RecommendedJobs { | ||
jobs { | ||
id | ||
title | ||
description | ||
organization { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
`; | ||
|
||
interface RecommendedJobsProps { | ||
loading: boolean; | ||
error: ApolloError; | ||
data: AllJobs; | ||
} | ||
|
||
|
||
const RecommendedJobs: React.SFC<RecommendedJobsProps> = ({loading, error, data}) => { | ||
|
||
if (loading) { | ||
return ( | ||
<Segment> | ||
<Header as="h3">Recommended Jobs</Header> | ||
<Card.Group itemsPerRow={3} centered> | ||
<Card><Loader/></Card> | ||
<Card><Loader/></Card> | ||
<Card><Loader/></Card> | ||
</Card.Group> | ||
</Segment> | ||
) | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<Segment> | ||
<Header as="h3">Recommended Jobs</Header> | ||
<Card.Group itemsPerRow={3} centered> | ||
<Card><Header as="h3">Ooops</Header></Card> | ||
<Card><Header as="h3">Ooops</Header></Card> | ||
<Card><Header as="h3">Ooops</Header></Card> | ||
</Card.Group> | ||
</Segment> | ||
) | ||
} | ||
|
||
return ( | ||
<Segment> | ||
<Header as="h3">Recommended Jobs</Header> | ||
<Card.Group itemsPerRow={3} centered> | ||
{data.jobs.map(job => ( | ||
<StudentJobCard key={job.id} job={job}/> | ||
))} | ||
</Card.Group> | ||
</Segment> | ||
); | ||
}; | ||
|
||
export default () => ( | ||
<Query query={GET_RECOMMENDED_JOBS}> | ||
{({loading, error, data}) => ( | ||
<RecommendedJobs data={data} error={error} loading={loading}/> | ||
)} | ||
</Query> | ||
); |
Oops, something went wrong.