Skip to content

tdelam/contractors-rater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Datatabase set up

Create a .env file in the server directory and fill it with the following:

PORT=4000
PGUSER=<YOURUSER>
PGPASSWORD=<PASS>
PGHOST=localhost
PGDATABASE=contractors_rater
PGPORT=5432

Connect to your Postgresql database and issue the following commands (this could and should be a script/migration):

  1. CREATE DATABASE contractors_rater;

  2. \connect contractors_rater;

  3. CREATE TABLE contractors (
      id SERIAL NOT NULL PRIMARY KEY,
      name VARCHAR(50) NOT NULL,
      location VARCHAR(50) NOT NULL,
      price_range INT NOT NULL check(price_range >= 1 and price_range <= 5)
    );
    
  4. CREATE TABLE reviews (
      id SERIAL NOT NULL PRIMARY KEY,
      contractor_id INT NOT NULL REFERENCES contractors(id),
      name VARCHAR(50) NOT NULL,
      content TEXT NOT NULL,
      rating INT NOT NULL check(rating >= 1 and rating <= 5)
    );
    
  5. INSERT INTO contractors (name, location, price_range) VALUES ('ACME Inc', 'Toronto', 3);
    INSERT INTO contractors (name, location, price_range) VALUES ('Chicken', 'Ottawa', 1);
    INSERT INTO contractors (name, location, price_range) VALUES ('Hammers Inc', 'Chicago', 3);
    INSERT INTO contractors (name, location, price_range) VALUES ('Builders Inc', 'Minnesota', 2);
    INSERT INTO contractors (name, location, price_range) VALUES ('Installers Inc', 'Sudbury', 5);
    
  6. INSERT INTO reviews (name, contractor_id, content, rating) VALUES ('Jane', 1, 'Contractor was fast and was safe!', 5);
    INSERT INTO reviews (name, contractor_id, content, rating) VALUES ('john', 1, 'Yah, just OK I guess, he could have did a better job!', 3);
    INSERT INTO reviews (name, contractor_id, content, rating) VALUES ('Alex', 2, 'Yah, just OK I guess, he could have did a better job!', 3);
    INSERT INTO reviews (name, contractor_id, content, rating) VALUES ('Matthew', 3, 'Yah, just OK I guess, he could have did a better job!', 3);
    
  7. \q to exit the shell

Code/Server Scripts

Node Server Install and Run

In the project root directory, run:

  • cd server
  • yarn install

Start the node server:

  • yarn start

Nodemon is a dep so any changes to the backend code will refresh without restarting the server.

ReactJS Install and Run

In the project root directory, run:

  • cd client
  • yarn install

To start the web server, run:

  • yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.

Once you're logged in, go ahead and add contractors/sub-contractors. You can also add ratings, update, and delete entries.

About

Little Contractor/Sub-contractor Rater

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published