GithubHelp home page GithubHelp logo

create-inc-assessment's Introduction

Prerequisites

Editor Setup

Instructions

Overview

This is an project to assess engineers for the Create, Inc. freelance marketplace platform. We appreciate you taking the time to participate.

This is a timed exercise. We expect this to take one hour, however you have up to 2 hours after cloning the repo to push code up. The timer begins as soon as you clone this repo. You should make your changes in a separate branch off of main and open a pull request into main with your changes when you are done. We will only consider code pushed up within the alloted time. Speed of completion will be considered when evaluating the exercise, but quality should not be sacrificed.

If you would like to familiarize yourself with the existing code, please read through it on Github. This does not count towards your allotted time.

Task

You are responsible for creating a simple shopping website. For simplicity, this is a frontend-only application, written in Typescript. Because we want to assess basic implementation skills, there is a folder in src/mock-backend that includes a react hook where you should implement the main logic for the shopping cart.

Frontend

In src/pages/index.tsx, you should implement the UI for displaying the items that are for sale, which are provided to you via the useCheckout react hook.

The client has specified the following UI requirements:

  • Each product should be shown on the home page, with their name and price
  • If an item is out of stock (quantity = 0) it should still be listed and show it is out of stock and should be at the bottom of the list.
  • You should be able to buy any of the products via a Buy button that is listed alongside each product. Clicking this button should call the buy function provided from the `useCheckout react hook.
  • The backend will throw errors when the user has insufficient balance to buy an item. In that case, you should show this error to the user. Only one error should be shown on the page at a time.
  • Bonus: While the buy request is running, inform the user.

Styling

This does not need to be a beautifully styled app. The focus is on the other aspects of the implementation. That said, feel free to use css, scss, or tailwind (whatever you're most comfortable with) in this setup to style the frontend.

Mock Backend

The mock backend is implemented inside src/mock-backend/index.ts. You are responsible for ensuring it responds to the buy function calls from the Frontend utiilizing the executePurchase function imported from src/mock-backend/purchase.ts. The executePurchase function should take the following into account:

  • If the user has the required balance to buy the item, then the stock of the item should be reduced by one and the balnce of the user should decrease.
  • If the user does not have the required balance or if the item is out of stock, then the proper error should be thrown.
  • Bonus: Write a jest test in src/mock-backend/__tests__/purchase.ts.

NOTE: the buy function includes a sleep function call. This is included to mimic the behavior of an API. Please do not remove it.

Running the App

This app runs on Next.js, but the necessary scripts from this assignment are all available via yarn:

Command Description
yarn dev starts a development server for the app with hot reloading
yarn test [BONUS] runs the tests

Once you run yarn dev, the app will be running at localhost:3000.

Wrapping up

Once you are finished, open a pull request into the main branch from the branch with your changes and email [email protected] (this routes to [email protected] and [email protected]).

Troubleshooting

If you run into any issues around getting the project setup, email or ping [email protected] or [email protected].

create-inc-assessment's People

Contributors

marcusglowe avatar

Watchers

Gervais I. avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.