iam4x / blockcal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BlockCal

Fully decentralized blockchain based calendar.

preview

Specs

  • Owner can create companies and assign rooms to them.
  • Owner can create employees and assign them to companies.
  • Employees can book a room for a given day slot.
  • Employees can unbook their own booking.

Description

  • This is my first ever Solidity smart contract, please don't be too picky on the data structure and the code, I still need to learn the best practices and this was a complete discovery.
  • I went with a simple CRUD data structure and the same contract owns the data, there's no proxy to a data store only contract.
  • To develop the contract itself I went with TDD using Hardhat and then deployed on the Ropsten testnet to interract with the UI I built.

How to run

  • Clone the repository
  • Create a .env and fill it according to .env.example
  • Run yarn && yarn deploy copy the contract address and add it to web/.env
  • Run cd web && yarn dev open your browser on http://localhost:3000 and voilĂ !

contracts/BlockCal.sol

Public Methods

  • getCompanies() -> { id: string; name: string }[]
  • getEmployees() -> { addr: string; name: string, companyId: string }[]
  • getRooms() -> { id: string; companyId: string }[]
  • getBookedSlots() -> { slotId: string; roomId: string; bookedBy: string; }[]

Owner methods

  • addComapny(name: string)
  • removeCompany(id: string)
  • addEmployee(name: string, companyId: string)
  • removeEmployee(addr: string)
  • addRoom(name: string, companyId: string)
  • removeRoom(id: string)

Employee methods

  • bookSlot(roomId: string, slotId: string)
  • unbookSlot(roomId: string, slotId: string)

Web UI

  • The UI is built with React, ant.design and tailwindcss.
  • For the deployment I went with fleek which is linked to the repository and auto-deploys new commits to IPFS network.

URLs

Pages

  • / -> connect to Metamask
  • /admin -> administration interface to create companies, employees and rooms
  • /calendar -> calendar interface to book and unbook slots for employees

Known issues

  • When switching profile into Metamask the contract is not updated, you must refresh the page
  • Reloading the page doesn't save the last connected user

Room for improvments

About


Languages

Language:TypeScript 77.4%Language:Solidity 20.3%Language:JavaScript 2.0%Language:Shell 0.1%Language:CSS 0.1%