Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just simple solution #6

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "fbjs"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
npm-debug.log
node_modules
ui/jspm_packages
69 changes: 16 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
# Adapt React Coding Challenge
# My solution for `Adapt React Coding Challenge`
All steps was acomplished but not in nice way. There are much to be improvment.
Still this quiz was interesting for me and give me opportunity to remember how to work with react.

Seems like you're trying out for a position at
[Adapt](https://adapt.dk/en) or you've found this and would like to
apply. Fork this repo and go at it ;)
What should be done (what kind of improvement must be done):

Your goal is to set up a React application, where users will be able to
edit book info (and create new books, if you have enough time to
implement it). Once you are done with the challenge, please fire up a
Pull Request and we will get in touch.
* Decouple code by using flux architecture. Such pattern should seperate view from logic
* Implement error handling in case if api server will not respond
* Refactor code
* and much more ... :(

## Brief
# How to run

I am a user of the app and I want to create a book object and edit
previously provided info about it, so that my reading list can stay up
to date. The form should be split into three steps:
I'm usin SystemJS for building jspm for dependency managament and live-server for serving application

1. Choose subject (one of the two).
2. Depending on the selection in the first step, display a list of
reading material. Choose one.
3. When reading material chosen, display all the info that's available
about the book in a form (meaning that the book info can be edited).
First of all install dependencies:

## Requirements
* npm install && npm i --dev
* jspm install && jspm i --dev

* All steps should be visible on the screen and changable at all times
(when they are available -- step 1 when nothing is picked, step 1
and 2 when step 1 is picked and step 1, 2 and 3 when step 2 is
picked).

* You can use whatever libraries, task runners and build processes you
like. React and plain JavaScript are the only requirements (ES6
encouraged, but no TypeScript, CoffeeScript, etc). Redux is strongly
encouraged if you see a need for it.

### Suggested order of completion

This depends on how much time you were given to accomplish the task.
Ideally you would provide a solution for each of the outlined steps
unless they are marked as optional.

1. Data fetching from the api.
2. Form steps logic.
3. (optional) Saving the data.
4. (optional) Styling (minor for a 2-3 h challenge, more if there's more time).

## API Usage

API can be launched using `npm start`. You will need to run `npm
install` once starting working on the project to install dependencies.

| Endpoint | Result |
|------------------------------|-----------------------------------------------------|
| /books?subjects_like=Fiction | Lists all books that contain "Fiction" as a subject |
| /subjects | Lists all available subjects |

---

More info about API usage can be found at the [json-server
repo](https://github.com/typicode/json-server).
Then run application:

* npm run start-api
* npm run start-ui
208 changes: 94 additions & 114 deletions api.json
Original file line number Diff line number Diff line change
@@ -1,120 +1,100 @@
{
"subjects": ["Fiction", "Science"],
"subjects": [
"Fiction",
"Science"
],
"books": [
{
"id":1342,
"authors":[
{
"birth_year":1775,
"death_year":1817,
"name":"Austen, Jane"
}
],
"bookshelves":[
"Best Books Ever Listings",
"Harvard Classics"
],
"download_count":45668,
"formats":{
"text/plain; charset=utf-8":"http://www.gutenberg.org/files/1342/1342-0.txt",
"application/pdf":"http://www.gutenberg.org/files/1342/1342-pdf.pdf",
"application/rdf+xml":"http://www.gutenberg.org/ebooks/1342.rdf",
"application/x-mobipocket-ebook":"http://www.gutenberg.org/ebooks/1342.kindle.noimages",
"application/epub+zip":"http://www.gutenberg.org/ebooks/1342.epub.images",
"text/plain; charset=us-ascii":"http://www.gutenberg.org/files/1342/1342.txt",
"text/html; charset=utf-8":"http://www.gutenberg.org/files/1342/1342-h/1342-h.htm"
},
"languages":[
"en"
],
"media_type":"Text",
"subjects": ["Fiction"],
"title":"Pride and Prejudice"
{
"id": 1342,
"authors": [
{
"birth_year": 1775,
"death_year": 1817,
"name": "Austenas"
}
],
"bookshelves": [
"Best Books Ever Listings",
"Harvard Classics"
],
"download_count": 45668,
"formats": {
"text/plain; charset=utf-8": "http://www.gutenberg.org/files/1342/1342-0.txt",
"application/pdf": "http://www.gutenberg.org/files/1342/1342-pdf.pdf",
"application/rdf+xml": "http://www.gutenberg.org/ebooks/1342.rdf",
"application/x-mobipocket-ebook": "http://www.gutenberg.org/ebooks/1342.kindle.noimages",
"application/epub+zip": "http://www.gutenberg.org/ebooks/1342.epub.images",
"text/plain; charset=us-ascii": "http://www.gutenberg.org/files/1342/1342.txt",
"text/html; charset=utf-8": "http://www.gutenberg.org/files/1342/1342-h/1342-h.htm"
},
{
"id":33283,
"authors":[
{
"birth_year":1851,
"death_year":1916,
"name":"Thompson, Silvanus P. (Silvanus Phillips)"
}
],
"bookshelves":[
"Mathematics"
],
"download_count":24344,
"formats":{
"application/prs.tex":"http://www.gutenberg.org/files/33283/33283-t.zip",
"application/rdf+xml":"http://www.gutenberg.org/ebooks/33283.rdf",
"application/pdf":"http://www.gutenberg.org/files/33283/33283-pdf.pdf"
},
"languages":[
"en"
],
"media_type":"Text",
"subjects": ["Fiction"],
"title":"Calculus Made Easy: Being a very-simplest introduction to those beautiful methods which are generally called by the terrifying names of the Differential Calculus and the Integral Calculus"
"languages": [
"en"
],
"media_type": "Text",
"subjects": [
"Fiction"
],
"title": "Pride and Prejudice"
},
{
"authors": [
{
"birth_year": 1832,
"death_year": 1898,
"name": "Carroll, Lew"
}
],
"bookshelves": [
"Children's Literature"
],
"download_count": 17866,
"formats": {
"text/plain; charset=utf-8": "http://www.gutenberg.org/files/11/11-0.zip",
"application/rdf+xml": "http://www.gutenberg.org/ebooks/11.rdf",
"application/pdf": "http://www.gutenberg.org/files/11/11-pdf.pdf",
"application/x-mobipocket-ebook": "http://www.gutenberg.org/ebooks/11.kindle.noimages",
"application/epub+zip": "http://www.gutenberg.org/ebooks/11.epub.images",
"text/plain; charset=us-ascii": "http://www.gutenberg.org/files/11/11.zip",
"application/zip": "http://www.gutenberg.org/files/11/11-h.zip",
"text/html; charset=utf-8": "http://www.gutenberg.org/files/11/11-h/11-h.htm"
},
{
"id":11,
"authors":[
{
"birth_year":1832,
"death_year":1898,
"name":"Carroll, Lewis"
}
],
"bookshelves":[
"Children's Literature"
],
"download_count":17866,
"formats":{
"text/plain; charset=utf-8":"http://www.gutenberg.org/files/11/11-0.zip",
"application/rdf+xml":"http://www.gutenberg.org/ebooks/11.rdf",
"application/pdf":"http://www.gutenberg.org/files/11/11-pdf.pdf",
"application/x-mobipocket-ebook":"http://www.gutenberg.org/ebooks/11.kindle.noimages",
"application/epub+zip":"http://www.gutenberg.org/ebooks/11.epub.images",
"text/plain; charset=us-ascii":"http://www.gutenberg.org/files/11/11.zip",
"application/zip":"http://www.gutenberg.org/files/11/11-h.zip",
"text/html; charset=utf-8":"http://www.gutenberg.org/files/11/11-h/11-h.htm"
},
"languages":[
"en"
],
"media_type":"Text",
"subjects": ["Fiction", "Science"],
"title":"Alice's Adventures in Wonderland"
"languages": [
"en"
],
"media_type": "Text",
"subjects": [
"Fiction",
"Science"
],
"title": "Alice's Adventures in Wonderland",
"id": 33288
},
{
"authors": [
{
"birth_year": "1850",
"death_year": 1916,
"name": "Thompson, Silvanus P."
}
],
"bookshelves": [
"Mathematics"
],
"download_count": 24344,
"formats": {
"application/prs.tex": "http://www.gutenberg.org/files/33283/33283-t.zip",
"application/rdf+xml": "http://www.gutenberg.org/ebooks/33283.rdf",
"application/pdf": "http://www.gutenberg.org/files/33283/33283-pdf.pdf"
},
{
"id":74,
"authors":[
{
"birth_year":1835,
"death_year":1910,
"name":"Twain, Mark"
}
],
"bookshelves":[
"Banned Books from Anne Haight's list"
],
"download_count":16204,
"formats":{
"image/jpeg":"http://www.gutenberg.org/cache/epub/74/pg74.cover.medium.jpg",
"text/plain; charset=utf-8":"http://www.gutenberg.org/files/74/74-0.zip",
"application/rdf+xml":"http://www.gutenberg.org/ebooks/74.rdf",
"application/x-mobipocket-ebook":"http://www.gutenberg.org/ebooks/74.kindle.images",
"application/epub+zip":"http://www.gutenberg.org/ebooks/74.epub.noimages",
"text/html; charset=utf-8":"http://www.gutenberg.org/files/74/74-h/74-h.htm",
"text/plain; charset=iso-8859-1":"http://www.gutenberg.org/files/74/74.txt",
"application/zip":"http://www.gutenberg.org/files/74/74.zip"
},
"languages":[
"en"
],
"media_type":"Text",
"subjects": ["Science"],
"title":"The Adventures of Tom Sawyer"
}
"languages": [
"en"
],
"media_type": "Text",
"subjects": [
"Fiction"
],
"title": "Calculus Made Easy: Being a very-simplest introduction to those beautiful methods which are generally called by the terrifying names of the Differential Calculus and the Integral Calculus",
"id": 33289
}
]
}
}
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var liveServer = require('live-server');
var proxy = require('http-proxy-middleware');

var params = {
port: 8080,
host: '0.0.0.0',
root: './ui',
ignore: 'jspm_packages',
wait: 1000,
// mount: [[]],
logLevel: 2,
// middleware: [proxy('http://127.0.0.1:3010')],
};

liveServer.start(params);
46 changes: 43 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,52 @@
"version": "1.0.0",
"description": "A package containing a simple dummy book API, which should be used in the challenge",
"scripts": {
"start": "json-server --port 3010 --watch api.json"
"start-api": "json-server --port 3010 --watch api.json",
"start-ui": "node index.js"
},
"keywords": ["react challenge", "tryouts", "react developer", "hiring"],
"keywords": [
"react challenge",
"tryouts",
"react developer",
"hiring"
],
"author": "Adapt A/S",
"license": "ISC",
"jspm": {
"directories": {
"baseURL": "ui"
},
"dependencies": {
"bootstrap": "npm:bootstrap@^3.3.7",
"isomorphic-fetch": "npm:isomorphic-fetch@^2.2.1",
"jsx": "github:floatdrop/plugin-jsx@^1.2.1",
"path-to-regexp": "npm:path-to-regexp@^1.7.0",
"react": "npm:react@^15.6.1",
"react-bootstrap": "npm:react-bootstrap@^0.31.1",
"react-dom": "npm:react-dom@^15.6.1",
"react-router": "npm:react-router@^4.1.2",
"react-router-bootstrap": "npm:react-router-bootstrap@^0.24.2",
"react-router-dom": "npm:react-router-dom@^4.1.2",
"underscore": "npm:underscore@^1.8.3"
},
"devDependencies": {
"babel": "npm:babel-core@^5.8.24",
"babel-runtime": "npm:babel-runtime@^5.8.24",
"core-js": "npm:core-js@^1.1.4"
}
},
"devDependencies": {
"json-server": "0.10.1"
"babel-eslint": "^7.2.3",
"eslint": "^4.3.0",
"eslint-config-fbjs": "^2.0.0",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-relay": "0.0.8",
"http-proxy-middleware": "^0.17.4",
"json-server": "0.10.1",
"jspm": "^0.16.53",
"live-server": "^1.2.0"
}
}
Binary file added ui/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading