Skip to content

Add task support for calendar #3139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
79102b5
chore!: add calendar table tasks
phatgg221 Jun 20, 2025
64536a2
feat: button and add event front end
phatgg221 Jun 20, 2025
ffd4e18
update: event-modal front end
phatgg221 Jun 20, 2025
7dd16d9
refactor: add overflow for dialog
phatgg221 Jun 20, 2025
a33c045
update: update dialog form
phatgg221 Jun 20, 2025
7f2948d
chore: add description for event
phatgg221 Jun 20, 2025
d0e849b
fix: submit grm Error
phatgg221 Jun 20, 2025
16867b6
feat: save tasks to database
phatgg221 Jun 20, 2025
36cae75
fix: delete unwanted imports
phatgg221 Jun 20, 2025
8bad6cb
Update supabase.ts
phatgg221 Jun 20, 2025
e442cde
update: update tasks table policy
phatgg221 Jun 20, 2025
212dd3e
update: change total duration to float number
phatgg221 Jun 20, 2025
5ae2a5f
fix: miss data type of total duration
phatgg221 Jun 20, 2025
051dd1d
Update 20250620103311_changed_policy_of_tasks_table.sql
phatgg221 Jun 20, 2025
f2a9187
fix: hardcoded emails and remove unwanted props
phatgg221 Jun 20, 2025
55c5415
Update add-event-dialog.tsx
phatgg221 Jun 20, 2025
6f9726e
Merge branch 'main' into feat-scheduler-db-and-functionality
vhpx Jun 20, 2025
d24aead
chore(db): consolidate migration files
vhpx Jun 20, 2025
540a5b9
chore(db): fix migration timestampt
vhpx Jun 20, 2025
b921e0b
Merge branch 'main' into feat-scheduler-db-and-functionality
phatgg221 Jun 21, 2025
19bfa98
fix: duplicates errors
phatgg221 Jun 21, 2025
e902936
chore: migrate to tasks table
phatgg221 Jun 21, 2025
0fa7534
refactor: moving to tasks table for schedule tasks
phatgg221 Jun 21, 2025
0160404
chore: rename from minutes to hours
phatgg221 Jun 21, 2025
8981c08
fix: build checks
phatgg221 Jun 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
create type "public"."calendar_task_time" as enum ('working_time', 'personal_time');

create type "public"."priority_status" as enum ('low', 'medium', 'high', 'critical');

create table "public"."workspace_calendar_tasks" (
"id" uuid not null default gen_random_uuid(),
"created_at" timestamp with time zone not null default now(),
"ws_id" uuid,
"creator_id" uuid,
"updated_at" timestamp with time zone,
"is_splittable" boolean,
"name" text,
"min_split_duration_minutes" smallint,
"max_split_duration_minutes" smallint,
"schedule_after" timestamp with time zone,
"due_date" timestamp with time zone,
"time_reference" calendar_task_time default 'working_time'::calendar_task_time,
"user_defined_priority" priority_status default 'medium'::priority_status,
"evaluated_priority" priority_status default 'medium'::priority_status
);


alter table "public"."workspace_calendar_tasks" enable row level security;

CREATE UNIQUE INDEX workspace_calendar_taskss_pkey ON public.workspace_calendar_tasks USING btree (id);

alter table "public"."workspace_calendar_tasks" add constraint "workspace_calendar_taskss_pkey" PRIMARY KEY using index "workspace_calendar_taskss_pkey";

alter table "public"."workspace_calendar_tasks" add constraint "workspace_calendar_taskss_creator_id_fkey" FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE CASCADE not valid;

alter table "public"."workspace_calendar_tasks" validate constraint "workspace_calendar_taskss_creator_id_fkey";

alter table "public"."workspace_calendar_tasks" add constraint "workspace_calendar_taskss_ws_id_fkey" FOREIGN KEY (ws_id) REFERENCES workspaces(id) ON DELETE CASCADE not valid;

alter table "public"."workspace_calendar_tasks" validate constraint "workspace_calendar_taskss_ws_id_fkey";

grant delete on table "public"."workspace_calendar_tasks" to "anon";

grant insert on table "public"."workspace_calendar_tasks" to "anon";

grant references on table "public"."workspace_calendar_tasks" to "anon";

grant select on table "public"."workspace_calendar_tasks" to "anon";

grant trigger on table "public"."workspace_calendar_tasks" to "anon";

grant truncate on table "public"."workspace_calendar_tasks" to "anon";

grant update on table "public"."workspace_calendar_tasks" to "anon";

grant delete on table "public"."workspace_calendar_tasks" to "authenticated";

grant insert on table "public"."workspace_calendar_tasks" to "authenticated";

grant references on table "public"."workspace_calendar_tasks" to "authenticated";

grant select on table "public"."workspace_calendar_tasks" to "authenticated";

grant trigger on table "public"."workspace_calendar_tasks" to "authenticated";

grant truncate on table "public"."workspace_calendar_tasks" to "authenticated";

grant update on table "public"."workspace_calendar_tasks" to "authenticated";

grant delete on table "public"."workspace_calendar_tasks" to "service_role";

grant insert on table "public"."workspace_calendar_tasks" to "service_role";

grant references on table "public"."workspace_calendar_tasks" to "service_role";

grant select on table "public"."workspace_calendar_tasks" to "service_role";

grant trigger on table "public"."workspace_calendar_tasks" to "service_role";

grant truncate on table "public"."workspace_calendar_tasks" to "service_role";

grant update on table "public"."workspace_calendar_tasks" to "service_role";


5 changes: 5 additions & 0 deletions apps/db/supabase/migrations/20250620095114_new_migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


alter table "public"."workspace_calendar_tasks" disable row level security;


9 changes: 9 additions & 0 deletions apps/db/supabase/migrations/20250620101647_new_migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
alter table "public"."workspace_calendar_tasks" add column "description" text;

alter table "public"."workspace_calendar_tasks" add column "total_duration" text not null;

alter table "public"."workspace_calendar_tasks" alter column "max_split_duration_minutes" set data type real using "max_split_duration_minutes"::real;

alter table "public"."workspace_calendar_tasks" alter column "min_split_duration_minutes" set data type real using "min_split_duration_minutes"::real;


Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
alter table "public"."workspace_calendar_tasks" enable row level security;

create policy "allow only user in the workspace to insert"
on "public"."workspace_calendar_tasks"
as permissive
for insert
to authenticated
with check (true);


alter table "public"."workspace_calendar_tasks" alter column "total_duration" set data type real using "total_duration"::real;


41 changes: 28 additions & 13 deletions apps/web/src/app/[locale]/(dashboard)/[wsId]/calendar/client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import AddEventButton from './components/add-event-button';
import AddEventModal from './components/add-event-dialog';
import AutoScheduleComprehensiveDialog from './components/auto-schedule-comprehensive-dialog';
import TestEventGeneratorButton from './components/test-event-generator-button';
import { DEV_MODE, ROOT_WORKSPACE_ID } from '@/constants/common';
Expand All @@ -9,6 +11,7 @@ import { Button } from '@tuturuuu/ui/button';
import { Sparkles } from '@tuturuuu/ui/icons';
import { SmartCalendar } from '@tuturuuu/ui/legacy/calendar/smart-calendar';
import { useLocale, useTranslations } from 'next-intl';
import { useState } from 'react';

export default function CalendarClientPage({
experimentalGoogleToken,
Expand All @@ -19,11 +22,16 @@ export default function CalendarClientPage({
}) {
const t = useTranslations('calendar');
const locale = useLocale();
const [isAddEventModalOpen, setIsAddEventModalOpen] = useState(false);

const openAddEventDialog = () => setIsAddEventModalOpen(true);
const closeAddEventDialog = () => setIsAddEventModalOpen(false);

const extras =
workspace.id === ROOT_WORKSPACE_ID ? (
<div className="grid w-full items-center gap-2 md:flex md:w-auto">
{DEV_MODE && <TestEventGeneratorButton wsId={workspace.id} />}
<AddEventButton wsId={workspace.id} onOpenDialog={openAddEventDialog} />
<AutoScheduleComprehensiveDialog wsId={workspace.id}>
<Button
variant="default"
Expand All @@ -38,18 +46,25 @@ export default function CalendarClientPage({
) : undefined;

return (
<SmartCalendar
t={t}
locale={locale}
workspace={workspace}
useQuery={useQuery}
useQueryClient={useQueryClient}
experimentalGoogleToken={
experimentalGoogleToken?.ws_id === workspace.id
? experimentalGoogleToken
: null
}
extras={extras}
/>
<>
<SmartCalendar
t={t}
locale={locale}
workspace={workspace}
useQuery={useQuery}
useQueryClient={useQueryClient}
experimentalGoogleToken={
experimentalGoogleToken?.ws_id === workspace.id
? experimentalGoogleToken
: null
}
extras={extras}
/>
<AddEventModal
wsId={workspace.id}
isOpen={isAddEventModalOpen}
onClose={closeAddEventDialog}
/>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Button } from '@tuturuuu/ui/button';
import { PlusIcon } from '@tuturuuu/ui/icons';
import React from 'react';

interface AddEventButtonProps {
wsId: string;
onOpenDialog?: () => void;
}

export default function AddEventButton({ onOpenDialog }: AddEventButtonProps) {
return (
<Button
onClick={onOpenDialog}
variant="default"
size="sm"
className="w-full bg-blue-500 text-white hover:bg-blue-600 md:w-fit"
>
<PlusIcon className="mr-2 h-4 w-4" />
Add Event
</Button>
);
}
Loading
Loading