Skip to content

feat: create new schedule atom#24404

Merged
Ryukemeister merged 23 commits intomainfrom
rajiv/cal-5507-feature-create-new-schedule-atom
Oct 14, 2025
Merged

feat: create new schedule atom#24404
Ryukemeister merged 23 commits intomainfrom
rajiv/cal-5507-feature-create-new-schedule-atom

Conversation

@Ryukemeister
Copy link
Contributor

@Ryukemeister Ryukemeister commented Oct 10, 2025

What does this PR do?

  • This PR adds a new atom for creating schedule for a user. Previously there was no way to create a schedule via UI

Visual Demo

loom video:
https://www.loom.com/share/6f019f1ba49a43439032d2d6b434c17c?sid=333d2744-4825-47e8-950d-b99450946925c

https://www.loom.com/share/6f019f1ba49a43439032d2d6b434c17c?sid=4414c519-0c3b-409b-a758-a9ba2fa9804f

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • (N/A) I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

This can be tested inside the platform examples app

@linear
Copy link

linear bot commented Oct 10, 2025

@keithwillcode keithwillcode added core area: core, team members only platform Anything related to our platform plan labels Oct 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • docs/api-reference/v2/openapi.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds schedule-creation across API, platform, libraries, TRPC, and docs. API: new POST /schedules/create on AtomsSchedulesController using CreateScheduleSchema and createScheduleHandler, returning ApiResponse. Platform: new CreateScheduleForm, CreateSchedulePlatformWrapper, useAtomCreateSchedule hook, and re-exports (CreateSchedule, CreateScheduleForm). Libraries: re-exports createScheduleHandler, CreateScheduleHandlerReturn, CreateScheduleSchema. TRPC: narrows ctx.user typing and exports CreateScheduleHandlerReturn. Docs: new create-schedule MDX page and mint.json navigation entry.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly captures the main feature addition—the creation of a new schedule atom—which directly aligns with the primary change described in the pull request and follows a clear conventional commit style.
Description Check ✅ Passed The description clearly outlines the purpose of the PR by summarizing the addition of a UI atom for schedule creation, provides relevant motivation and context through video demos, lists the mandatory checklist items, and includes testing instructions that all align with the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Oct 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Oct 14, 2025 0:13am
cal-eu Ignored Ignored Oct 14, 2025 0:13am

@Ryukemeister Ryukemeister marked this pull request as ready for review October 10, 2025 16:06
@Ryukemeister Ryukemeister requested a review from a team October 10, 2025 16:06
@Ryukemeister Ryukemeister requested review from a team as code owners October 10, 2025 16:06
@dosubot dosubot bot added the ✨ feature New feature or request label Oct 10, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eae2711 and 53945c0.

📒 Files selected for processing (10)
  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts (4 hunks)
  • docs/mint.json (1 hunks)
  • docs/platform/atoms/create-schedule.mdx (1 hunks)
  • packages/platform/atoms/create-schedule/CreateScheduleForm.tsx (1 hunks)
  • packages/platform/atoms/create-schedule/index.tsx (1 hunks)
  • packages/platform/atoms/create-schedule/wrappers/CreateSchedulePlatformWrapper.tsx (1 hunks)
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts (1 hunks)
  • packages/platform/atoms/index.ts (1 hunks)
  • packages/platform/libraries/schedules.ts (1 hunks)
  • packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/platform/atoms/create-schedule/index.tsx
  • packages/platform/atoms/create-schedule/CreateScheduleForm.tsx
  • packages/platform/atoms/create-schedule/wrappers/CreateSchedulePlatformWrapper.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/platform/atoms/create-schedule/index.tsx
  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts
  • packages/platform/libraries/schedules.ts
  • packages/platform/atoms/index.ts
  • packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts
  • packages/platform/atoms/create-schedule/CreateScheduleForm.tsx
  • packages/platform/atoms/create-schedule/wrappers/CreateSchedulePlatformWrapper.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/platform/atoms/create-schedule/index.tsx
  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts
  • packages/platform/libraries/schedules.ts
  • packages/platform/atoms/index.ts
  • packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts
  • packages/platform/atoms/create-schedule/CreateScheduleForm.tsx
  • packages/platform/atoms/create-schedule/wrappers/CreateSchedulePlatformWrapper.tsx
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts
  • packages/platform/libraries/schedules.ts
  • packages/platform/atoms/index.ts
  • packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts
🧬 Code graph analysis (5)
apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts (3)
apps/api/v2/src/modules/users/users.repository.ts (1)
  • UserWithProfile (10-13)
packages/platform/types/api.ts (1)
  • ApiResponse (33-35)
packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts (1)
  • CreateScheduleHandlerReturn (17-17)
packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts (1)
packages/platform/libraries/schedules.ts (2)
  • CreateScheduleHandlerReturn (11-11)
  • createHandler (10-10)
packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts (1)
packages/platform/types/api.ts (3)
  • ApiSuccessResponse (8-8)
  • ApiErrorResponse (19-24)
  • ApiResponse (33-35)
packages/platform/atoms/create-schedule/CreateScheduleForm.tsx (3)
packages/platform/types/api.ts (1)
  • ApiErrorResponse (19-24)
packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts (1)
  • useAtomCreateSchedule (16-46)
packages/ui/components/form/inputs/TextField.tsx (1)
  • InputField (102-232)
packages/platform/atoms/create-schedule/wrappers/CreateSchedulePlatformWrapper.tsx (5)
packages/platform/atoms/index.ts (2)
  • CreateSchedulePlatformWrapper (47-47)
  • CreateScheduleForm (48-48)
packages/platform/types/api.ts (1)
  • ApiErrorResponse (19-24)
packages/platform/atoms/create-schedule/CreateScheduleForm.tsx (2)
  • ActionButtonsClassNames (14-18)
  • CreateScheduleForm (20-108)
packages/ui/components/dialog/Dialog.tsx (3)
  • Dialog (35-38)
  • DialogTrigger (168-172)
  • DialogContent (56-117)
packages/ui/components/button/Button.tsx (1)
  • Button (221-349)
🔇 Additional comments (5)
packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts (1)

12-12: LGTM: Type narrowing and export enhance type safety.

The narrowing of ctx.user to only the required fields (id, timeZone, defaultScheduleId) is correct—the handler code (lines 20-76) uses only these properties. Exporting CreateScheduleHandlerReturn provides a clean public type for API consumers.

Also applies to: 17-17

packages/platform/atoms/create-schedule/index.tsx (1)

1-1: LGTM: Clean re-export pattern.

The named export follows the coding guidelines and established patterns in the codebase.

packages/platform/atoms/index.ts (1)

47-48: LGTM: Public API exports follow established patterns.

The new exports for CreateSchedule and CreateScheduleForm are consistent with existing aliases (e.g., CalendarView) and adhere to the named exports guideline.

apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts (1)

95-109: LGTM: Secure and well-typed endpoint.

The new POST endpoint is properly secured with ApiAuthGuard and SCHEDULE_WRITE permissions. The type usage is correct, and the handler invocation properly passes the user context.

packages/platform/libraries/schedules.ts (1)

9-13: LGTM: Clean public API exports.

The exports provide a well-structured public API surface for schedule creation functionality, using named exports and clear type aliases.

Copy link
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! I left a question below and NIT comment and let me know about my question:

onSuccess: (data) => {
if (data.status === SUCCESS_STATUS) {
onSuccess?.(data);
queryClient.invalidateQueries({ queryKey: [ScheduleQueryKey] });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see here we invalidate ScheduleQueryKey - can you confirm if we have create schedules atom and list schedules atom you recently created that if you have both on the same page and you create a new schedule via create schedule atom that it appears in the list schedules atom and if you do it second time that second schedule appears in the list atom?

Copy link
Contributor Author

@Ryukemeister Ryukemeister Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I can check and confirm this. what I was think was once this PR is merged I can update the examples app in my list schedules atom branch to make the availability page similar to https://app.cal.com/availability. does that sound good?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 53945c0 and bbc1f70.

📒 Files selected for processing (3)
  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts (4 hunks)
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts (1 hunks)
  • packages/platform/libraries/schedules.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/platform/libraries/schedules.ts
  • packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts
🧬 Code graph analysis (1)
apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts (3)
apps/api/v2/src/modules/users/users.repository.ts (1)
  • UserWithProfile (10-13)
packages/platform/types/api.ts (1)
  • ApiResponse (33-35)
packages/trpc/server/routers/viewer/availability/schedule/create.handler.ts (1)
  • CreateScheduleHandlerReturn (17-17)
🔇 Additional comments (3)
apps/api/v2/src/modules/atoms/controllers/atoms.schedules.controller.ts (3)

25-25: LGTM: Zod import added for schema validation.

The Zod import is necessary for the CreateScheduleSchema type inference in the new createSchedule method.


28-29: LGTM: Required imports for schedule creation.

The imports for CreateScheduleHandlerReturn, CreateScheduleSchema, and createScheduleHandler are correctly sourced from @calcom/platform-libraries/schedules and necessary for the new endpoint.


92-106: No explicit error handling required here. Global exception filters (Prisma, Zod, Http, TRPC, CalendarService) are registered in app.ts and will catch and format errors thrown by createScheduleHandler.

@supalarry supalarry self-requested a review October 13, 2025 09:52
ThyMinimalDev
ThyMinimalDev previously approved these changes Oct 13, 2025
@supalarry
Copy link
Contributor

supalarry commented Oct 14, 2025

Fixed CI breaking changes check issue in #24445

You now need to revert openapi.json changes you submitted (it needs to be like in main because nothing in your PR changes it) and then merge main into this branch and should work.

PS i merged main into here to see if CI would pass previously so pull this branch before making changes.

@Ryukemeister Ryukemeister merged commit b5585b3 into main Oct 14, 2025
81 of 87 checks passed
@Ryukemeister Ryukemeister deleted the rajiv/cal-5507-feature-create-new-schedule-atom branch October 14, 2025 14:36
@coderabbitai coderabbitai bot mentioned this pull request Oct 14, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only ✨ feature New feature or request platform Anything related to our platform plan ready-for-e2e size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants