No description
  • TypeScript 97.5%
  • JavaScript 1.4%
  • CSS 1.1%
Find a file
2025-09-30 15:52:40 +02:00
.vscode 🚀 Initial commit 2023-10-18 10:29:46 +02:00
public 🚚 Added the user interface 2023-10-23 11:25:31 +02:00
src feat: updated groups 2025-09-30 15:52:40 +02:00
.env.example feat: .env.example 2025-09-30 15:52:19 +02:00
.eslintrc.js 🚀 Initial commit 2023-10-18 10:29:46 +02:00
.gitignore 🚚 Updated the .gitignore 2023-11-24 13:34:53 +01:00
.prettierrc 🚀 Initial commit 2023-10-18 10:29:46 +02:00
components.json 🚀 Initial commit 2023-10-18 10:29:46 +02:00
next.config.js 🚀 Initial commit 2023-10-18 10:29:46 +02:00
package-lock.json 🚚 Removed the addHours func on the calendars 2024-04-02 08:32:04 +02:00
package.json 🚚 Removed the addHours func on the calendars 2024-04-02 08:32:04 +02:00
postcss.config.js 🚀 Initial commit 2023-10-18 10:29:46 +02:00
README.md 🚚 Added an env var, updated the README and added a debug log 2023-12-13 16:17:50 +01:00
tailwind.config.js 🚚 Made the user dashboard with the calendar 2023-10-18 23:52:25 +02:00
tsconfig.json 🐛 Fixed a bug where sessions where causing mass reloading 2023-12-15 22:29:46 +01:00

Next.js Project Template

This repository is a Next.js project template using TailwindCSS, ESLint & Prettier.

Installation

  1. Change the project name in the package.json.

  2. Run npm install

Important

If you run this project on Vercel, you might need to set up the NEXT_PUBLIC_RSA_PUBLIC_KEY in the environnement variables. Please wrap the key inside quotes (") to avoid errors. (The error encountered might be : length octect is too long at: (shallow))

Snippets

You have access to 4 default snippets in the .vscode/snippets.code-snippets file.

Documentation

Supabase

Profiles table

create table public.profiles (
  id uuid not null,
  email text not null,
  created_at timestamp with time zone null default now(),
  constraint profiles_pkey primary key (id),
  constraint profiles_id_fkey foreign key (id) references auth.users (id) on delete cascade
) tablespace pg_default;

User handling functions

When creating the functions, you need to set the type of security to SECURITY DEFINER and set the return type to TRIGGER.

-- When creating a user
CREATE OR REPLACE FUNCTION public.handle_new_user()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
  insert into public.profiles (id, email)
  values (new.id, new.email);
  return new;
end;
$function$
-- When updating a user
CREATE OR REPLACE FUNCTION public.handle_udpate_user()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
  update public.profiles set email=new.email where id=new.id;
  return new;
end;
$function$
-- When deleting a user
CREATE OR REPLACE FUNCTION public.handle_old_user()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
  delete from public.profiles where id=old.id;
  return old;
end;
$function$

You then need to create the triggers to run the functions. The condition table is the auth users table, you need to match the event with the function selected, set the trigger to run after the event and run it one time per row.

Get unique professors function

CREATE OR REPLACE FUNCTION get_professors()
RETURNS SETOF text AS $$
DECLARE
    value text;
BEGIN
    -- Use UNNEST and DISTINCT to get distinct unnested values from the array column
    FOR value IN SELECT DISTINCT unnest(professors) FROM courses
    LOOP
        -- Return each distinct unnested value
        RETURN NEXT value;
    END LOOP;

    RETURN;
END;
$$ LANGUAGE plpgsql;

-- Call the function
SELECT * FROM get_professors();