Skip to content

Commit

Permalink
Adds basic connections for academies and fields. Still looks ugly as f.
Browse files Browse the repository at this point in the history
  • Loading branch information
vi0dine committed Jan 26, 2020
1 parent 22dd10c commit 35f3588
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 7 deletions.
29 changes: 22 additions & 7 deletions kompas_maturalny_backend/db/seeds.rb
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
5 changes: 5 additions & 0 deletions kompas_maturalny_web/cypress/integration/fields_spec.js
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')
})
});
12 changes: 12 additions & 0 deletions kompas_maturalny_web/graphql/queries/academies.js
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
}
}
`;
11 changes: 11 additions & 0 deletions kompas_maturalny_web/graphql/queries/fields.js
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
}
}
`;
24 changes: 24 additions & 0 deletions kompas_maturalny_web/pages/academies.js
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;
24 changes: 24 additions & 0 deletions kompas_maturalny_web/pages/fields.js
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;

0 comments on commit 35f3588

Please sign in to comment.