-
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.
Adds basic connections for academies and fields. Still looks ugly as f.
- Loading branch information
Showing
6 changed files
with
98 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
# This file should contain all the record creation needed to seed the database with its default values. | ||
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). | ||
# | ||
# Examples: | ||
# | ||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) | ||
# Character.create(name: 'Luke', movie: movies.first) | ||
NUMBER_OF_FIELDS = 10 | ||
NUMBER_OF_ACADEMIES = 10 | ||
|
||
User.create(username: 'schoolboy', email: "schoolboy@example.com", role: "schoolboy", password: "test1234") | ||
User.create(username: 'student', email: "student@example.com", role: "student", password: "test1234") | ||
User.create(username: 'partner', email: "partner@example.com", role: "partner", password: "test1234") | ||
User.create(username: 'admin', email: "admin@example.com", role: "admin", password: "test1234") | ||
|
||
NUMBER_OF_FIELDS.times do | ||
FieldOfStudy.create!( | ||
name: "#{Faker::Educator.course_name}", | ||
description: Faker::Lorem.sentences | ||
) | ||
end | ||
|
||
NUMBER_OF_ACADEMIES.times do | ||
Academy.create!( | ||
name: "#{Faker::Educator.university}", | ||
description: Faker::Lorem.sentences, | ||
city: Faker::Address.city | ||
) | ||
end |
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,5 @@ | ||
describe('Displaying all fields of study list', function() { | ||
it('Visits the KIERUNKI tab', function() { | ||
cy.visit('/fields') | ||
}) | ||
}); |
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,12 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
export const ACADEMIES_QUERY = gql` | ||
query academies { | ||
academies { | ||
id | ||
name | ||
description | ||
city | ||
} | ||
} | ||
`; |
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 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
export const FIELDS_QUERY = gql` | ||
query fields { | ||
fields { | ||
id | ||
name | ||
description | ||
} | ||
} | ||
`; |
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,24 @@ | ||
import React from 'react'; | ||
import BasicLayout from "../components/layouts/BasicLayout.layout"; | ||
import {useQuery} from "@apollo/react-hooks"; | ||
import {ACADEMIES_QUERY} from "../graphql/queries/academies"; | ||
|
||
const Academies = () => { | ||
const {data, loading, error} = useQuery(ACADEMIES_QUERY, { | ||
onError: (error) => console.log(error.message) | ||
}); | ||
|
||
return !loading && ( | ||
<BasicLayout> | ||
<div> | ||
{ | ||
!error && data.academies.map(academy => ( | ||
<p>{academy.name}</p> | ||
)) | ||
} | ||
</div> | ||
</BasicLayout> | ||
); | ||
}; | ||
|
||
export default Academies; |
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,24 @@ | ||
import React from 'react'; | ||
import BasicLayout from "../components/layouts/BasicLayout.layout"; | ||
import {useQuery} from "@apollo/react-hooks"; | ||
import {FIELDS_QUERY} from "../graphql/queries/fields"; | ||
|
||
const Fields = () => { | ||
const {data, loading, error} = useQuery(FIELDS_QUERY, { | ||
onError: (error) => console.log(error.message) | ||
}); | ||
|
||
return !loading && ( | ||
<BasicLayout> | ||
<div> | ||
{ | ||
!error && data.fields.map(field => ( | ||
<p>{field.name}</p> | ||
)) | ||
} | ||
</div> | ||
</BasicLayout> | ||
); | ||
}; | ||
|
||
export default Fields; |