- [] Signup Cookies are not deleted after signup.
- [] The verify email callback is not following best practices.
- [] Implementing Supabase Auth Best Practices for Server and Client (Create Action).
- [] Fix middleware for checking authentication and authorization (permission/role).
- [] Check out feature (multiple order).
- [] Pagination feature.
- [] High Ordered Component implementation (?).
- [] Order feature with realtime rajaongkir API for provinces, cities, and cost.
This is a mini project that creates a dashboard system with Role-Based Access Control (RBAC), data manipulation (CRUD), and authentication using Supabase. It provides a simple way to manage and control access to data, ensuring that users with different roles can interact with the system according to their permissions.
This repository is π battery packed with:
- βοΈ React 18.x
- β¨ TypeScript
- π¨ Material UI β Ready to use Material Design components check here for the usage
- π¨ React Hook Form β Performant, flexible and extensible forms with easy-to-use validation
- β° Day.js β A modern day JavaScript Date Library
- π₯ Utils: getApiResponse - consoleLog
- π Jest β Configured for unit testing
- π Absolute Import and Path Alias β Import components using
@/
prefix - π ESLint β Find and fix problems in your code, also will auto sort your imports
- π Prettier β Format your code consistently
- πΆ Husky & Lint Staged β Run scripts on your staged files before they are committed
- π€ Conventional Commit Lint β Make sure you & your teammates follow conventional commit
- β° Release Please β Generate your changelog by activating the
release-please
workflow - π· Github Actions β Lint your code on PR
- π Automatic Branch and Issue Autolink β Branch will be automatically created on issue assign, and auto linked on PR
- π₯ Snippets β A collection of useful snippets
- π Open Graph Helper Function β Awesome open graph generated using og, fork it and deploy!
- πΊ Site Map β Automatically generate sitemap.xml
- π¦ Expansion Pack β Easily install common libraries, additional components, and configs.
git clone https://github.com/dzaky-pr/mini-project-supabase-dashboard.git
It is encouraged to use yarn so the husky hooks can work properly.
yarn install
You can start the server using this command:
yarn dev
Open http://localhost:3000 with your browser to see the result. You can start editing the page by modifying src/pages/index.tsx
.
There are some things you need to change including title, urls, favicons, etc.
Find all comments with !STARTERCONF, then follow the guide.
Don't forget to change the package name in package.json
This starter is using conventional commits, it is mandatory to use it to commit changes.
Note: The order feature, database schema, and everything related to this feature, both for admins and users, are still under development!
This table stores data about books that users like.
- favorite_id (UUID): Unique ID for each favorite.
- user_id (UUID): ID of the user who likes the book.
- book_id (UUID): ID of the liked book.
- created_at (timestamptz): Time when the favorite was created.
This table stores data about book orders from users.
- order_id (UUID): Unique ID for each order.
- user_id (UUID): ID of the user who placed the order.
- book_id (UUID): ID of the ordered book.
- count (int4): Number of books ordered.
- shipping_address (text): Shipping address.
- city (text): Shipping city.
- province (text): Shipping province.
- status (text): Order status.
- rejected_reason (text): Reason for rejection if the order is rejected.
- created_at (timestamptz): Time when the order was created.
- accepted_rejected_status_at (timestamptz): Time when the order was accepted or rejected.
- courier (text): Courier name.
- service (text): Shipping service type.
- shipping_cost (int4): Shipping cost.
- delivery_estimate (text): Estimated delivery time.
- total_price (int4): Total order price.
This table stores data about available books.
- book_id (UUID): Unique ID for each book.
- title (text): Book title.
- author (text): Book author.
- description (text): Book description.
- created_at (timestamptz): Time when the book was added.
- stocks (int4): Number of books available in stock.
This table stores data about user permissions.
- id (UUID): Unique ID for each permission entry.
- created_at (timestamptz): Time when the permission was created.
- role (text): User role (e.g., admin, user).
This function is triggered when a user signs up. It inserts a new permission entry with the user's ID.
BEGIN
INSERT INTO public.permissions (id)
VALUES (
NEW.id
);
RETURN NEW;
END;
This function checks if a user is an admin. It returns true
if the user's role is 'admin'.
BEGIN
RETURN (SELECT role FROM permissions WHERE permissions.id = (SELECT auth.uid())) = 'admin';
END;
This function checks if a user is a regular user. It returns true
if the user's role is 'user'.
BEGIN
RETURN (SELECT role FROM permissions WHERE permissions.id = (SELECT auth.uid())) = 'user';
END;
This function updates the accepted_rejected_status_at
timestamp when the order status changes.
BEGIN
IF NEW.status IS DISTINCT FROM OLD.status THEN
NEW.accepted_rejected_status_at := CURRENT_TIMESTAMP;
END IF;
RETURN NEW;
END;
This trigger is activated when a user signs up and calls the create_user_on_signup
function.
This trigger is activated after an update on the orders table and calls the
<type>(optional scope): <description>
Example: feat(pre-event): add speakers section
Available types are:
- feat β Changes about addition or removal of a feature. Ex:
feat: add table on landing page
,feat: remove table from landing page
- fix β Bug fixing, followed by the bug. Ex:
fix: illustration overflows in mobile view
- docs β Update documentation (README.md)
- style β Updating style, and not changing any logic in the code (reorder imports, fix whitespace, remove comments)
- chore β Installing new dependencies, or bumping deps
- refactor β Changes in code, same output, but different approach
- ci β Update github workflows, husky
- test β Update testing suite, cypress files
- revert β when reverting commits
- perf β Fixing something regarding performance (deriving state, using memo, callback)
- vercel β Blank commit to trigger vercel deployment. Ex:
vercel: trigger deployment
Labels per page Ex: feat(pre-event): add date label
*If there is no scope needed, you don't need to write it
Description must fully explain what is being done.
Add BREAKING CHANGE in the description if there is a significant change.
If there are multiple changes, then commit one by one
- After colon, there are a single space Ex:
feat: add something
- When using
fix
type, state the issue Ex:fix: file size limiter not working
- Use imperative, and present tense: "change" not "changed" or "changes"
- Don't use capitals in front of the sentence
- Don't add full stop (.) at the end of the sentence
This project is built using the boilerplate starter template from the following repository: