Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43a30aa51d | ||
|
|
eb13057157 | ||
|
|
bb4d587359 | ||
|
|
3d7c32c0d8 | ||
|
|
39508b3daa | ||
|
|
e79c818edb | ||
|
|
8a1023087f | ||
|
|
9343aee778 | ||
|
|
89f645c450 | ||
|
|
da5d90eb07 | ||
|
|
9f30f95dd9 | ||
|
|
bc0c1341f6 | ||
|
|
1c0a51cc02 | ||
|
|
7cfe7647f3 | ||
|
|
cc91834ddd | ||
|
|
2cb1a62906 | ||
|
|
6135d449ec | ||
|
|
073b29c214 | ||
|
|
ea99dc5520 | ||
|
|
c3280a62b7 | ||
|
|
a41b42359a | ||
|
|
cc15fb5285 | ||
|
|
e554268592 | ||
|
|
f4c2764cbf | ||
|
|
ac54ccdd70 | ||
|
|
b3216634c9 | ||
|
|
6c437edc0e | ||
|
|
bed153b497 | ||
|
|
2be245eefc | ||
|
|
caf3b40687 | ||
|
|
5650bd6409 | ||
|
|
94a86acdaa | ||
|
|
defd49f986 | ||
|
|
679d3da957 | ||
|
|
e84fd39e11 | ||
|
|
1d74e9c201 | ||
|
|
3356cbc1df | ||
|
|
4584f666e0 | ||
|
|
c9078cfd94 | ||
|
|
4ae1c2aa8c | ||
|
|
cf15f5f2a2 | ||
|
|
d21f42c257 | ||
|
|
92a0dff2c7 | ||
|
|
47add7e7fc | ||
|
|
6dfc19247e | ||
|
|
2db4998eaa | ||
|
|
dad4fd17fb | ||
|
|
c26efcabe4 | ||
|
|
6a8db56dbb | ||
|
|
6c058d041a | ||
|
|
07b43e107e | ||
|
|
ab8ad6434f | ||
|
|
4d7a3ac21a | ||
|
|
2ac709630f | ||
|
|
64147d3618 | ||
|
|
fb0e89ab22 | ||
|
|
7bee930983 | ||
|
|
9678361f5c | ||
|
|
a404ba471d | ||
|
|
9a8aab2e54 | ||
|
|
4c54e9c384 | ||
|
|
8dd2135656 | ||
|
|
4ba72425b9 | ||
|
|
f4b0772746 | ||
|
|
1a605b555a | ||
|
|
17324e406c | ||
|
|
833459cabb | ||
|
|
6076fd7ba0 | ||
|
|
ca8b380815 | ||
|
|
d7953aa53a | ||
|
|
494012484e | ||
|
|
8c6669e204 | ||
|
|
d5f3623377 | ||
|
|
ef483a6520 | ||
|
|
339f00f6aa | ||
|
|
e98bebb9b2 | ||
|
|
dcd7e80e6a | ||
|
|
fcc13da23d | ||
|
|
67a210d439 | ||
|
|
e813f8bb17 | ||
|
|
5ff8d2db6e | ||
|
|
7953551189 | ||
|
|
879bc3f169 | ||
|
|
4aaf5da36d | ||
|
|
fb16d8e900 | ||
|
|
58d6bb840a | ||
|
|
1419c534c8 | ||
|
|
4de1de3418 | ||
|
|
c23a2102f4 | ||
|
|
df686370ab | ||
|
|
0bc7d4ceda | ||
|
|
9444f925e5 | ||
|
|
2918a34e1a | ||
|
|
213caa722e | ||
|
|
6c7d7be9cc | ||
|
|
f1ef50e606 | ||
|
|
22c51ba483 | ||
|
|
b6eaafa39f | ||
|
|
98707e66e1 | ||
|
|
44308cbfa0 | ||
|
|
352a9e2fec | ||
|
|
c1a9f4b656 | ||
|
|
32c6ca0ad5 | ||
|
|
e79b4168f2 | ||
|
|
54833b65ff | ||
|
|
26afc077a7 | ||
|
|
0093b6faa5 | ||
|
|
ef49fc4ce1 | ||
|
|
605f7d35ec | ||
|
|
9b37d65503 | ||
|
|
a1f9012501 | ||
|
|
008016902e | ||
|
|
9f33d85903 | ||
|
|
496b03e92f | ||
|
|
358da42a9b | ||
|
|
8812580f72 | ||
|
|
3009f17cb0 | ||
|
|
3328cb2226 | ||
|
|
7b57b4bcda | ||
|
|
6d413f5721 | ||
|
|
c9fc88ddc7 | ||
|
|
6d284ae15c | ||
|
|
c6791a8d3c | ||
|
|
aa1370b9c7 | ||
|
|
db27c7e4bc | ||
|
|
325c6ddc86 | ||
|
|
9c7428571d | ||
|
|
9391bb5b64 | ||
|
|
d58924ecad | ||
|
|
fdef15712a | ||
|
|
a5b5382306 | ||
|
|
c2fceb2e0f | ||
|
|
a73065ba5d | ||
|
|
7b0f677bdb | ||
|
|
4166a0ab02 | ||
|
|
da80a2bae8 | ||
|
|
c6fd91d181 | ||
|
|
f62e6d9586 | ||
|
|
b03c6d5040 | ||
|
|
172d77dcc3 | ||
|
|
1a905aa330 | ||
|
|
a8da4b87f0 | ||
|
|
eb679a8e7d | ||
|
|
b364a85ed8 | ||
|
|
a2e0d44fb8 | ||
|
|
a9ee5d6f7f | ||
|
|
6d35750784 | ||
|
|
4f423ba692 | ||
|
|
d097c1fada | ||
|
|
fc049e12b3 | ||
|
|
267422a1f4 | ||
|
|
6e15de31aa | ||
|
|
2f6b5ced04 | ||
|
|
cf57be2aef | ||
|
|
c2996cd2f8 | ||
|
|
79944dfed1 | ||
|
|
e83647c652 | ||
|
|
556bf346f0 | ||
|
|
b98f2045d0 | ||
|
|
a13c050e9d | ||
|
|
e088196c8d | ||
|
|
9456ffbb48 | ||
|
|
6d19cc22a5 | ||
|
|
c69c9d6314 | ||
|
|
e0ef30eb52 | ||
|
|
045828d4ab | ||
|
|
354d57f393 | ||
|
|
650d0082a3 | ||
|
|
7c4b7209c2 | ||
|
|
5736821466 | ||
|
|
75f76c130a | ||
|
|
936432a730 | ||
|
|
4fda760e5e | ||
|
|
c467fd41ac | ||
|
|
0969d5960a | ||
|
|
cbe1907118 | ||
|
|
afd41475c9 | ||
|
|
f07c0b09fa | ||
|
|
d0707422b9 | ||
|
|
cc0c686e65 | ||
|
|
7057da7327 | ||
|
|
fbb27ceab0 | ||
|
|
01a5d588f3 | ||
|
|
5003ada671 | ||
|
|
54374cf43e | ||
|
|
55bca88d9b | ||
|
|
f755312ed7 | ||
|
|
207e0aac1f | ||
|
|
c8f7b36307 | ||
|
|
b5f0f0c0de | ||
|
|
816bfdd8f7 | ||
|
|
499b433d4d | ||
|
|
7b1fbd2853 | ||
|
|
9c2e15f016 | ||
|
|
4ac2c52c4e | ||
|
|
4a4cc7c766 | ||
|
|
648886f630 | ||
|
|
8d7b2cfe51 | ||
|
|
bfc2b8df34 | ||
|
|
a36f2aa871 | ||
|
|
6d8a576f60 | ||
|
|
b5e54d6cf9 | ||
|
|
ea20fa9f35 | ||
|
|
c3b2a52815 | ||
|
|
6bd97065e6 | ||
|
|
878a7cbfc5 | ||
|
|
9c84c3db0a | ||
|
|
1cf8ef8155 | ||
|
|
14aa0a2f2d |
No files matched your search
+1
-6
@@ -121,6 +121,7 @@ TWILIO_SID=
|
|||||||
TWILIO_TOKEN=
|
TWILIO_TOKEN=
|
||||||
TWILIO_MESSAGING_SID=
|
TWILIO_MESSAGING_SID=
|
||||||
TWILIO_PHONE_NUMBER=
|
TWILIO_PHONE_NUMBER=
|
||||||
|
TWILIO_WHATSAPP_PHONE_NUMBER=
|
||||||
# For NEXT_PUBLIC_SENDER_ID only letters, numbers and spaces are allowed (max. 11 characters)
|
# For NEXT_PUBLIC_SENDER_ID only letters, numbers and spaces are allowed (max. 11 characters)
|
||||||
NEXT_PUBLIC_SENDER_ID=
|
NEXT_PUBLIC_SENDER_ID=
|
||||||
TWILIO_VERIFY_SID=
|
TWILIO_VERIFY_SID=
|
||||||
@@ -214,9 +215,3 @@ PROJECT_ID_VERCEL=
|
|||||||
TEAM_ID_VERCEL=
|
TEAM_ID_VERCEL=
|
||||||
# Get it from: https://vercel.com/account/tokens
|
# Get it from: https://vercel.com/account/tokens
|
||||||
AUTH_BEARER_TOKEN_VERCEL=
|
AUTH_BEARER_TOKEN_VERCEL=
|
||||||
|
|
||||||
#Enables New booker for Embed only
|
|
||||||
NEW_BOOKER_ENABLED_FOR_EMBED=0
|
|
||||||
|
|
||||||
#Enables New booker for All but Embed requests
|
|
||||||
NEW_BOOKER_ENABLED_FOR_NON_EMBED=0
|
|
||||||
@@ -20,8 +20,20 @@ A summary of the issue. This needs to be a clear detailed-rich summary.
|
|||||||
|
|
||||||
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
|
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
|
||||||
|
|
||||||
|
### Actual Results
|
||||||
|
|
||||||
|
- What's happening right now that is different from what is expected
|
||||||
|
|
||||||
|
### Expected Results
|
||||||
|
|
||||||
|
- This is an ideal result that the system should get after the tests are performed
|
||||||
|
|
||||||
### Technical details
|
### Technical details
|
||||||
|
|
||||||
- Browser version, screen recording, console logs, network requests: You can make a recording with [Bird Eats Bug](https://birdeatsbug.com/).
|
- Browser version, screen recording, console logs, network requests: You can make a recording with [Bird Eats Bug](https://birdeatsbug.com/).
|
||||||
- Node.js version
|
- Node.js version
|
||||||
- Anything else that you think could be an issue.
|
- Anything else that you think could be an issue.
|
||||||
|
|
||||||
|
### Evidence
|
||||||
|
|
||||||
|
- How was this tested? This is quite mandatory in terms of bugs. Providing evidence of your testing with screenshots or/and videos is an amazing way to prove the bug and a troubleshooting chance to find the solution.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Questions
|
- name: Questions
|
||||||
url: https://cal.com/slack
|
url: https://go.cal.com/discord
|
||||||
about: Ask a general question about the project on our Slack workspace
|
about: Ask a general question about the project on our discord community
|
||||||
@@ -39,3 +39,11 @@ assignees: ""
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
(Write your answer here.)
|
(Write your answer here.)
|
||||||
|
|
||||||
|
### Requirement/Document
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Is there any type of document that could support that feature?
|
||||||
|
-->
|
||||||
|
|
||||||
|
(Share it here.)
|
||||||
@@ -8,26 +8,34 @@ Fixes # (issue)
|
|||||||
Loom Video: https://www.loom.com/
|
Loom Video: https://www.loom.com/
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## Requirement/Documentation
|
||||||
|
|
||||||
|
<!-- Please provide all documents that are important to understand the reason of that PR. -->
|
||||||
|
- If there is a requirement document, please, share it here.
|
||||||
|
- If there is ab UI/UX design document, please, share it here.
|
||||||
|
|
||||||
## Type of change
|
## Type of change
|
||||||
|
|
||||||
<!-- Please delete bullets that are not relevant. -->
|
<!-- Please delete bullets that are not relevant. -->
|
||||||
|
|
||||||
- Bug fix (non-breaking change which fixes an issue)
|
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||||
- Chore (refactoring code, technical debt, workflow improvements)
|
- [ ] Chore (refactoring code, technical debt, workflow improvements)
|
||||||
- New feature (non-breaking change which adds functionality)
|
- [ ] New feature (non-breaking change which adds functionality)
|
||||||
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||||
- This change requires a documentation update
|
- [ ] This change requires a documentation update
|
||||||
|
|
||||||
## How should this be tested?
|
## How should this be tested?
|
||||||
|
|
||||||
<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration -->
|
<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. Write details that help to start the tests -->
|
||||||
|
|
||||||
- [ ] Test A
|
- Are there environment variables that should be set?
|
||||||
- [ ] Test B
|
- What are the minimal test data to have?
|
||||||
|
- What is expected (happy path) to have (input and output)?
|
||||||
|
- Any other important info that could help to test that PR
|
||||||
|
|
||||||
## Mandatory Tasks
|
## Mandatory Tasks
|
||||||
|
|
||||||
- [ ] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
|
- [ ] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,16 @@ name: "Set environment variables"
|
|||||||
description: "Configures environment variables for a workflow"
|
description: "Configures environment variables for a workflow"
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Create env file
|
- name: Read env file
|
||||||
uses: buildjet/cache@v3
|
uses: buildjet/cache@v3
|
||||||
id: env-cache
|
id: env-cache
|
||||||
with:
|
with:
|
||||||
path: gh.env
|
path: gh.env-${{ github.sha }}
|
||||||
key: env-cache-${{ hashFiles('gh.env') }}
|
key: env-cache
|
||||||
|
restore-keys: env-cache-
|
||||||
- name: Set Environment Variables
|
- name: Set Environment Variables
|
||||||
uses: tw3lveparsecs/github-actions-setvars@latest
|
uses: tw3lveparsecs/github-actions-setvars@latest
|
||||||
with:
|
with:
|
||||||
envFilePath: gh.env
|
envFilePath: gh.env-${{ github.sha }}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: Cron - scheduleWhatsappReminders
|
||||||
|
|
||||||
|
on:
|
||||||
|
# "Scheduled workflows run on the latest commit on the default or base branch."
|
||||||
|
# — https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#schedule
|
||||||
|
schedule:
|
||||||
|
# Runs “At minute 0, 15, 30, and 45.” (see https://crontab.guru)
|
||||||
|
- cron: "0,15,30,45 * * * *"
|
||||||
|
jobs:
|
||||||
|
cron-scheduleWhatsappReminders:
|
||||||
|
env:
|
||||||
|
APP_URL: ${{ secrets.APP_URL }}
|
||||||
|
CRON_API_KEY: ${{ secrets.CRON_API_KEY }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: cURL request
|
||||||
|
if: ${{ env.APP_URL && env.CRON_API_KEY }}
|
||||||
|
run: |
|
||||||
|
curl ${{ secrets.APP_URL }}/api/cron/workflows/scheduleWhatsappReminders \
|
||||||
|
-X POST \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-H 'authorization: ${{ secrets.CRON_API_KEY }}' \
|
||||||
|
--fail
|
||||||
@@ -22,6 +22,7 @@ jobs:
|
|||||||
uses: crowdin/github-action@1.5.1
|
uses: crowdin/github-action@1.5.1
|
||||||
with:
|
with:
|
||||||
upload_sources: true
|
upload_sources: true
|
||||||
|
upload_translations: true
|
||||||
download_translations: true
|
download_translations: true
|
||||||
push_translations: true
|
push_translations: true
|
||||||
commit_message: "New Crowdin translations by Github Action"
|
commit_message: "New Crowdin translations by Github Action"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ on:
|
|||||||
workflow_call:
|
workflow_call:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
ENV_FILE_NAME: gh.env-${{ github.sha }}
|
||||||
INPUT_ENV_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso
|
INPUT_ENV_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso
|
||||||
INPUT_ENV_NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000
|
INPUT_ENV_NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000
|
||||||
INPUT_ENV_NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000
|
INPUT_ENV_NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000
|
||||||
@@ -44,10 +45,11 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/dangerous-git-checkout
|
- uses: ./.github/actions/dangerous-git-checkout
|
||||||
- uses: ozaytsev86/create-env-file@v1
|
- uses: ozaytsev86/create-env-file@v1
|
||||||
|
|
||||||
with:
|
with:
|
||||||
file-name: ${{ github.workspace }}/gh.env
|
file-name: ${{ github.workspace }}/${{ env.ENV_FILE_NAME }}
|
||||||
- uses: buildjet/cache@v3
|
- uses: buildjet/cache@v3
|
||||||
id: env-cache
|
id: env-cache
|
||||||
with:
|
with:
|
||||||
path: gh.env
|
path: ${{ env.ENV_FILE_NAME }}
|
||||||
key: env-cache-${{ hashFiles('gh.env') }}
|
key: env-cache-${{ hashFiles(env.ENV_FILE_NAME) }}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
name: Assign PR team labels
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
team-labels:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: equitybee/team-label-action@main
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||||
|
organization-name: calcom
|
||||||
|
ignore-labels: "app-store, authentication, automated-testing, billing, bookings, caldav, calendar-apps, ci, console, crm-apps, docs, documentation, emails, embeds, event-types, i18n, impersonation, manual-testing, ui, performance, ops-stack, organizations, public-api, routing-forms, seats, teams, webhooks, workflows, zapier"
|
||||||
@@ -13,16 +13,16 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
welcome-message:
|
welcome-message:
|
||||||
name: Welcoming New Users
|
name: Welcoming New Users
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
needs: semantics
|
needs: semantics
|
||||||
if: github.event.action == 'opened'
|
if: github.event.action == 'opened'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/first-interaction@v1
|
- uses: actions/first-interaction@v1
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
pr-message: |-
|
pr-message: |-
|
||||||
Thank you for making your first Pull Request and taking the time to improve Cal.com ! ❤️🎉
|
Thank you for making your first Pull Request and taking the time to improve Cal.com ! ❤️🎉
|
||||||
Feel free to join the conversation at [slack](https://calendso.slack.com/)
|
Feel free to join the conversation at [discord](https://go.cal.com/discord)
|
||||||
issue-message: |
|
issue-message: |
|
||||||
Thank you for opening your first issue, one of our team members will review it as soon as it possible. ❤️🎉
|
Thank you for opening your first issue, one of our team members will review it as soon as it possible. ❤️🎉
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<a href="https://cal.com"><strong>Learn more »</strong></a>
|
<a href="https://cal.com"><strong>Learn more »</strong></a>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<a href="https://cal.com/slack">Slack</a>
|
<a href="https://go.cal.com/discord">Discord</a>
|
||||||
·
|
·
|
||||||
<a href="https://cal.com">Website</a>
|
<a href="https://cal.com">Website</a>
|
||||||
·
|
·
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://cal.com/slack"><img src="https://img.shields.io/badge/Slack-calendso.slack.com-%234A154B" alt="Join Cal.com Slack"></a>
|
<a href="https://go.cal.com/discord"><img src="https://img.shields.io/badge/Discord-go.cal.com%2Fdiscord-%234A154B" alt="Join Cal.com Discord"></a>
|
||||||
<a href="https://producthunt.com/posts/calendso"><img src="https://img.shields.io/badge/Product%20Hunt-%231%20Product%20of%20the%20Month-%23DA552E" alt="Product Hunt"></a>
|
<a href="https://producthunt.com/posts/calendso"><img src="https://img.shields.io/badge/Product%20Hunt-%231%20Product%20of%20the%20Month-%23DA552E" alt="Product Hunt"></a>
|
||||||
<a href="https://status.cal.com"><img height="20px" src="https://betteruptime.com/status-badges/v1/monitor/a9kf.svg" alt="Uptime"></a>
|
<a href="https://status.cal.com"><img height="20px" src="https://betteruptime.com/status-badges/v1/monitor/a9kf.svg" alt="Uptime"></a>
|
||||||
<a href="https://github.com/calcom/cal.com/stargazers"><img src="https://img.shields.io/github/stars/calcom/cal.com" alt="Github Stars"></a>
|
<a href="https://github.com/calcom/cal.com/stargazers"><img src="https://img.shields.io/github/stars/calcom/cal.com" alt="Github Stars"></a>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<a href="https://twitch.tv/calcomtv"><img src="https://img.shields.io/twitch/status/calcomtv?style=flat"></a>
|
<a href="https://twitch.tv/calcomtv"><img src="https://img.shields.io/twitch/status/calcomtv?style=flat"></a>
|
||||||
<a href="https://github.com/calcom/cal.com/issues?q=is:issue+is:open+label:%22%F0%9F%99%8B%F0%9F%8F%BB%E2%80%8D%E2%99%82%EF%B8%8Fhelp+wanted%22"><img src="https://img.shields.io/badge/Help%20Wanted-Contribute-blue"></a>
|
<a href="https://github.com/calcom/cal.com/issues?q=is:issue+is:open+label:%22%F0%9F%99%8B%F0%9F%8F%BB%E2%80%8D%E2%99%82%EF%B8%8Fhelp+wanted%22"><img src="https://img.shields.io/badge/Help%20Wanted-Contribute-blue"></a>
|
||||||
<a href="https://cal.com/figma"><img src="https://img.shields.io/badge/Figma-Design%20System-blueviolet"></a>
|
<a href="https://cal.com/figma"><img src="https://img.shields.io/badge/Figma-Design%20System-blueviolet"></a>
|
||||||
<a href="https://calendso.slack.com/archives/C02BY67GMMW"><img src="https://img.shields.io/badge/translations-contribute-brightgreen" /></a>
|
<a href="https://discord.com/channels/1125390093386010654/1125398231585661040"><img src="https://img.shields.io/badge/translations-contribute-brightgreen" /></a>
|
||||||
<a href="https://contributor-covenant.org/version/1/4/code-of-conduct/ "><img src="https://img.shields.io/badge/Contributor%20Covenant-1.4-purple" /></a>
|
<a href="https://contributor-covenant.org/version/1/4/code-of-conduct/ "><img src="https://img.shields.io/badge/Contributor%20Covenant-1.4-purple" /></a>
|
||||||
<a href="https://console.algora.io/org/cal/bounties?status=open"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fconsole.algora.io%2Fapi%2Fshields%2Fcal%2Fbounties%3Fstatus%3Dopen" /></a>
|
<a href="https://console.algora.io/org/cal/bounties?status=open"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fconsole.algora.io%2Fapi%2Fshields%2Fcal%2Fbounties%3Fstatus%3Dopen" /></a>
|
||||||
</p>
|
</p>
|
||||||
@@ -388,7 +388,7 @@ We have a list of [help wanted](https://github.com/calcom/cal.com/issues?q=is:is
|
|||||||
|
|
||||||
### Translations
|
### Translations
|
||||||
|
|
||||||
Don't code but still want to contribute? Join our [slack](https://cal.com/slack) and join the [#i18n channel](https://calendso.slack.com/archives/C02BY67GMMW) and let us know what language you want to translate.
|
Don't code but still want to contribute? Join our [discord](https://go.cal.com/discord) and join the [#Translate channel](https://discord.com/channels/1125390093386010654/1125398231585661040) and let us know what language you want to translate.
|
||||||
|
|
||||||
                                             {
|
|||||||
export const verifyApiKey: NextMiddleware = async (req, res, next) => {
|
export const verifyApiKey: NextMiddleware = async (req, res, next) => {
|
||||||
const { prisma, isCustomPrisma, isAdmin } = req;
|
const { prisma, isCustomPrisma, isAdmin } = req;
|
||||||
const hasValidLicense = await checkLicense(prisma);
|
const hasValidLicense = await checkLicense(prisma);
|
||||||
if (!hasValidLicense)
|
if (!hasValidLicense && process.env.NODE_ENV !== "development")
|
||||||
return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" });
|
return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" });
|
||||||
// If the user is an admin and using a license key (from customPrisma), skip the apiKey check.
|
// If the user is an admin and using a license key (from customPrisma), skip the apiKey check.
|
||||||
if (isCustomPrisma && isAdmin) {
|
if (isCustomPrisma && isAdmin) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import slugify from "@calcom/lib/slugify";
|
||||||
import { _EventTypeModel as EventType, _HostModel } from "@calcom/prisma/zod";
|
import { _EventTypeModel as EventType, _HostModel } from "@calcom/prisma/zod";
|
||||||
import { customInputSchema, eventTypeBookingFields } from "@calcom/prisma/zod-utils";
|
import { customInputSchema, eventTypeBookingFields } from "@calcom/prisma/zod-utils";
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ export const schemaEventTypeBaseBodyParams = EventType.pick({
|
|||||||
const schemaEventTypeCreateParams = z
|
const schemaEventTypeCreateParams = z
|
||||||
.object({
|
.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
slug: z.string(),
|
slug: z.string().transform((s) => slugify(s)),
|
||||||
description: z.string().optional().nullable(),
|
description: z.string().optional().nullable(),
|
||||||
length: z.number().int(),
|
length: z.number().int(),
|
||||||
metadata: z.any().optional(),
|
metadata: z.any().optional(),
|
||||||
@@ -76,7 +77,10 @@ export const schemaEventTypeCreateBodyParams = schemaEventTypeBaseBodyParams
|
|||||||
const schemaEventTypeEditParams = z
|
const schemaEventTypeEditParams = z
|
||||||
.object({
|
.object({
|
||||||
title: z.string().optional(),
|
title: z.string().optional(),
|
||||||
slug: z.string().optional(),
|
slug: z
|
||||||
|
.string()
|
||||||
|
.transform((s) => slugify(s))
|
||||||
|
.optional(),
|
||||||
length: z.number().int().optional(),
|
length: z.number().int().optional(),
|
||||||
seatsPerTimeSlot: z.number().optional(),
|
seatsPerTimeSlot: z.number().optional(),
|
||||||
seatsShowAttendees: z.boolean().optional(),
|
seatsShowAttendees: z.boolean().optional(),
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import ensureOnlyMembersAsHosts from "./_utils/ensureOnlyMembersAsHosts";
|
|||||||
* slug:
|
* slug:
|
||||||
* type: string
|
* type: string
|
||||||
* description: Unique slug for the event type
|
* description: Unique slug for the event type
|
||||||
* example: my-event
|
|
||||||
* hosts:
|
* hosts:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
@@ -168,9 +167,9 @@ import ensureOnlyMembersAsHosts from "./_utils/ensureOnlyMembersAsHosts";
|
|||||||
* type: string
|
* type: string
|
||||||
* displayLocationPublicly:
|
* displayLocationPublicly:
|
||||||
* type: boolean
|
* type: boolean
|
||||||
* example:
|
* examples:
|
||||||
* event-type:
|
* event-type:
|
||||||
* summary: An example of event type POST request
|
* summary: An example of an individual event type POST request
|
||||||
* value:
|
* value:
|
||||||
* title: Hello World
|
* title: Hello World
|
||||||
* slug: hello-world
|
* slug: hello-world
|
||||||
@@ -205,6 +204,42 @@ import ensureOnlyMembersAsHosts from "./_utils/ensureOnlyMembersAsHosts";
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* team-event-type:
|
||||||
|
* summary: An example of a team event type POST request
|
||||||
|
* value:
|
||||||
|
* title: "Tennis class"
|
||||||
|
* slug: "tennis-class-{{$guid}}"
|
||||||
|
* length: 60
|
||||||
|
* hidden: false
|
||||||
|
* position: 0
|
||||||
|
* teamId: 3
|
||||||
|
* eventName: null
|
||||||
|
* timeZone: null
|
||||||
|
* periodType: "UNLIMITED"
|
||||||
|
* periodStartDate: null
|
||||||
|
* periodEndDate: null
|
||||||
|
* periodDays: null
|
||||||
|
* periodCountCalendarDays: null
|
||||||
|
* requiresConfirmation: true
|
||||||
|
* recurringEvent:
|
||||||
|
* interval: 2
|
||||||
|
* count: 10
|
||||||
|
* freq: 2
|
||||||
|
* disableGuests: false
|
||||||
|
* hideCalendarNotes: false
|
||||||
|
* minimumBookingNotice: 120
|
||||||
|
* beforeEventBuffer: 0
|
||||||
|
* afterEventBuffer: 0
|
||||||
|
* schedulingType: "COLLECTIVE"
|
||||||
|
* price: 0
|
||||||
|
* currency: "usd"
|
||||||
|
* slotInterval: null
|
||||||
|
* successRedirectUrl: null
|
||||||
|
* description: null
|
||||||
|
* locations:
|
||||||
|
* - address: "London"
|
||||||
|
* type: "inPerson"
|
||||||
|
* metadata: {}
|
||||||
* tags:
|
* tags:
|
||||||
* - event-types
|
* - event-types
|
||||||
* externalDocs:
|
* externalDocs:
|
||||||
|
|||||||
@@ -2,29 +2,36 @@ import type { NextApiRequest, NextApiResponse } from "next";
|
|||||||
|
|
||||||
import { HttpError } from "@calcom/lib/http-error";
|
import { HttpError } from "@calcom/lib/http-error";
|
||||||
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
|
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
|
||||||
import { MembershipRole } from "@calcom/prisma/enums";
|
import { MembershipRole, UserPermissionRole } from "@calcom/prisma/enums";
|
||||||
import { createContext } from "@calcom/trpc/server/createContext";
|
import { createContext } from "@calcom/trpc/server/createContext";
|
||||||
import { publishHandler } from "@calcom/trpc/server/routers/viewer/teams/publish.handler";
|
import { viewerTeamsRouter } from "@calcom/trpc/server/routers/viewer/teams/_router";
|
||||||
|
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { getHTTPStatusCodeFromError } from "@trpc/server/http";
|
import { getHTTPStatusCodeFromError } from "@trpc/server/http";
|
||||||
|
|
||||||
import { withMiddleware } from "~/lib/helpers/withMiddleware";
|
import { withMiddleware } from "~/lib/helpers/withMiddleware";
|
||||||
import { schemaQueryTeamId } from "~/lib/validations/shared/queryTeamId";
|
|
||||||
|
|
||||||
import authMiddleware, { checkPermissions } from "./_auth-middleware";
|
import authMiddleware, { checkPermissions } from "./_auth-middleware";
|
||||||
|
|
||||||
const patchHandler = async (req: NextApiRequest, res: NextApiResponse) => {
|
const patchHandler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
await checkPermissions(req, { in: [MembershipRole.OWNER, MembershipRole.ADMIN] });
|
await checkPermissions(req, { in: [MembershipRole.OWNER, MembershipRole.ADMIN] });
|
||||||
/** @see https://trpc.io/docs/server-side-calls */
|
async function sessionGetter() {
|
||||||
const ctx = await createContext({ req, res });
|
return {
|
||||||
const user = ctx.user;
|
user: {
|
||||||
if (!user) {
|
id: req.userId,
|
||||||
throw new Error("Internal Error.");
|
username: "" /* Not used in this context */,
|
||||||
|
role: req.isAdmin ? UserPermissionRole.ADMIN : UserPermissionRole.USER,
|
||||||
|
},
|
||||||
|
hasValidLicense: true /* To comply with TS signature */,
|
||||||
|
expires: "" /* Not used in this context */,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
/** @see https://trpc.io/docs/server-side-calls */
|
||||||
|
const ctx = await createContext({ req, res }, sessionGetter);
|
||||||
try {
|
try {
|
||||||
const { teamId } = schemaQueryTeamId.parse(req.query);
|
const caller = viewerTeamsRouter.createCaller(ctx);
|
||||||
return await publishHandler({ input: { teamId }, ctx: { ...ctx, user } });
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
return await caller.publish(req.query as any /* Let tRPC handle this */);
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
if (cause instanceof TRPCError) {
|
if (cause instanceof TRPCError) {
|
||||||
const statusCode = getHTTPStatusCodeFromError(cause);
|
const statusCode = getHTTPStatusCodeFromError(cause);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"@calcom/ui": "*",
|
"@calcom/ui": "*",
|
||||||
"@radix-ui/react-avatar": "^1.0.0",
|
"@radix-ui/react-avatar": "^1.0.0",
|
||||||
"@radix-ui/react-collapsible": "^1.0.0",
|
"@radix-ui/react-collapsible": "^1.0.0",
|
||||||
"@radix-ui/react-dialog": "^1.0.0",
|
"@radix-ui/react-dialog": "^1.0.4",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
||||||
"@radix-ui/react-id": "^1.0.0",
|
"@radix-ui/react-id": "^1.0.0",
|
||||||
"@radix-ui/react-popover": "^1.0.2",
|
"@radix-ui/react-popover": "^1.0.2",
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import type { ReactNode } from "react";
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import type { CredentialOwner } from "@calcom/app-store/types";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
||||||
import { Badge, ListItemText } from "@calcom/ui";
|
import { Badge, ListItemText, Avatar } from "@calcom/ui";
|
||||||
import { AlertCircle } from "@calcom/ui/components/icon";
|
import { AlertCircle } from "@calcom/ui/components/icon";
|
||||||
|
|
||||||
type ShouldHighlight = { slug: string; shouldHighlight: true } | { shouldHighlight?: never; slug?: never };
|
type ShouldHighlight = { slug: string; shouldHighlight: true } | { shouldHighlight?: never; slug?: never };
|
||||||
@@ -19,6 +20,7 @@ type AppListCardProps = {
|
|||||||
isTemplate?: boolean;
|
isTemplate?: boolean;
|
||||||
invalidCredential?: boolean;
|
invalidCredential?: boolean;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
|
credentialOwner?: CredentialOwner;
|
||||||
} & ShouldHighlight;
|
} & ShouldHighlight;
|
||||||
|
|
||||||
const schema = z.object({ hl: z.string().optional() });
|
const schema = z.object({ hl: z.string().optional() });
|
||||||
@@ -36,6 +38,7 @@ export default function AppListCard(props: AppListCardProps) {
|
|||||||
isTemplate,
|
isTemplate,
|
||||||
invalidCredential,
|
invalidCredential,
|
||||||
children,
|
children,
|
||||||
|
credentialOwner,
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
data: { hl },
|
data: { hl },
|
||||||
@@ -65,7 +68,7 @@ export default function AppListCard(props: AppListCardProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${highlight ? "dark:bg-muted bg-yellow-100" : ""}`}>
|
<div className={`${highlight ? "dark:bg-muted bg-yellow-100" : ""}`}>
|
||||||
<div className="flex gap-x-3 px-5 py-4">
|
<div className="flex items-center gap-x-3 px-5 py-4">
|
||||||
{logo ? <img className="h-10 w-10" src={logo} alt={`${title} logo`} /> : null}
|
{logo ? <img className="h-10 w-10" src={logo} alt={`${title} logo`} /> : null}
|
||||||
<div className="flex grow flex-col gap-y-1 truncate">
|
<div className="flex grow flex-col gap-y-1 truncate">
|
||||||
<div className="flex items-center gap-x-2">
|
<div className="flex items-center gap-x-2">
|
||||||
@@ -85,6 +88,21 @@ export default function AppListCard(props: AppListCardProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{credentialOwner && (
|
||||||
|
<div>
|
||||||
|
<Badge variant="gray">
|
||||||
|
<div className="flex items-center">
|
||||||
|
<Avatar
|
||||||
|
className="mr-2"
|
||||||
|
alt={credentialOwner.name || "Nameless"}
|
||||||
|
size="xs"
|
||||||
|
imageSrc={credentialOwner.avatar}
|
||||||
|
/>
|
||||||
|
{credentialOwner.name}
|
||||||
|
</div>
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{actions}
|
{actions}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Script from "next/script";
|
|||||||
|
|
||||||
import "@calcom/embed-core/src/embed-iframe";
|
import "@calcom/embed-core/src/embed-iframe";
|
||||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
import { WEBAPP_URL, IS_CALCOM } from "@calcom/lib/constants";
|
||||||
import { buildCanonical } from "@calcom/lib/next-seo.config";
|
import { buildCanonical } from "@calcom/lib/next-seo.config";
|
||||||
|
|
||||||
import type { AppProps } from "@lib/app-providers";
|
import type { AppProps } from "@lib/app-providers";
|
||||||
@@ -53,10 +53,6 @@ function PageWrapper(props: AppProps) {
|
|||||||
// Use the layout defined at the page level, if available
|
// Use the layout defined at the page level, if available
|
||||||
const getLayout = Component.getLayout ?? ((page) => page);
|
const getLayout = Component.getLayout ?? ((page) => page);
|
||||||
|
|
||||||
// Canonical: Check if the URL is from cal.com so that we set the canonical conditionally
|
|
||||||
const isCalcom =
|
|
||||||
WEBAPP_URL &&
|
|
||||||
(new URL(WEBAPP_URL).hostname.endsWith("cal.com") || new URL(WEBAPP_URL).hostname.endsWith("cal.dev"));
|
|
||||||
const path = router.asPath;
|
const path = router.asPath;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -70,7 +66,7 @@ function PageWrapper(props: AppProps) {
|
|||||||
<DefaultSeo
|
<DefaultSeo
|
||||||
// Set canonical to https://cal.com or self-hosted URL
|
// Set canonical to https://cal.com or self-hosted URL
|
||||||
canonical={
|
canonical={
|
||||||
isCalcom
|
IS_CALCOM
|
||||||
? buildCanonical({ path, origin: "https://cal.com" }) // cal.com & .dev
|
? buildCanonical({ path, origin: "https://cal.com" }) // cal.com & .dev
|
||||||
: buildCanonical({ path, origin: WEBAPP_URL }) // self-hosted
|
: buildCanonical({ path, origin: WEBAPP_URL }) // self-hosted
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,36 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { IframeHTMLAttributes } from "react";
|
import type { IframeHTMLAttributes } from "react";
|
||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import { CAL_URL } from "@calcom/lib/constants";
|
||||||
|
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||||
|
|
||||||
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
|
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
|
||||||
import { InstallAppButton, AppDependencyComponent } from "@calcom/app-store/components";
|
import { InstallAppButton, AppDependencyComponent } from "@calcom/app-store/components";
|
||||||
import DisconnectIntegration from "@calcom/features/apps/components/DisconnectIntegration";
|
import DisconnectIntegration from "@calcom/features/apps/components/DisconnectIntegration";
|
||||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||||
|
import type { UserAdminTeams } from "@calcom/features/ee/teams/lib/getUserAdminTeams";
|
||||||
import Shell from "@calcom/features/shell/Shell";
|
import Shell from "@calcom/features/shell/Shell";
|
||||||
import classNames from "@calcom/lib/classNames";
|
import classNames from "@calcom/lib/classNames";
|
||||||
import { APP_NAME, COMPANY_NAME, SUPPORT_MAIL_ADDRESS } from "@calcom/lib/constants";
|
import { APP_NAME, COMPANY_NAME, SUPPORT_MAIL_ADDRESS } from "@calcom/lib/constants";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { trpc } from "@calcom/trpc/react";
|
import { trpc } from "@calcom/trpc/react";
|
||||||
import type { App as AppType } from "@calcom/types/App";
|
import type { App as AppType } from "@calcom/types/App";
|
||||||
|
import type { ButtonProps } from "@calcom/ui";
|
||||||
|
import type { AppFrontendPayload as App } from "@calcom/types/App";
|
||||||
import { Button, showToast, SkeletonButton, SkeletonText, HeadSeo, Badge } from "@calcom/ui";
|
import { Button, showToast, SkeletonButton, SkeletonText, HeadSeo, Badge } from "@calcom/ui";
|
||||||
|
import {
|
||||||
|
Dropdown,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuPortal,
|
||||||
|
DropdownMenuLabel,
|
||||||
|
DropdownItem,
|
||||||
|
Avatar,
|
||||||
|
} from "@calcom/ui";
|
||||||
import { BookOpen, Check, ExternalLink, File, Flag, Mail, Plus, Shield } from "@calcom/ui/components/icon";
|
import { BookOpen, Check, ExternalLink, File, Flag, Mail, Plus, Shield } from "@calcom/ui/components/icon";
|
||||||
|
import { Spinner } from "@calcom/features/calendars/weeklyview/components/spinner/Spinner";
|
||||||
|
|
||||||
|
|
||||||
/* These app slugs all require Google Cal to be installed */
|
/* These app slugs all require Google Cal to be installed */
|
||||||
|
|
||||||
@@ -60,11 +77,14 @@ const Component = ({
|
|||||||
}).format(price);
|
}).format(price);
|
||||||
|
|
||||||
const [existingCredentials, setExistingCredentials] = useState<number[]>([]);
|
const [existingCredentials, setExistingCredentials] = useState<number[]>([]);
|
||||||
const appCredentials = trpc.viewer.appCredentialsByType.useQuery(
|
const [showDisconnectIntegration, setShowDisconnectIntegration] = useState(false);
|
||||||
|
const appDbQuery = trpc.viewer.appCredentialsByType.useQuery(
|
||||||
{ appType: type },
|
{ appType: type },
|
||||||
{
|
{
|
||||||
onSuccess(data) {
|
onSettled(data) {
|
||||||
setExistingCredentials(data);
|
const credentialsCount = data?.credentials.length || 0
|
||||||
|
setShowDisconnectIntegration(data?.userAdminTeams.length ? credentialsCount >= data?.userAdminTeams.length : credentialsCount > 0);
|
||||||
|
setExistingCredentials(data?.credentials.map(credential => credential.id) || []);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -141,7 +161,7 @@ const Component = ({
|
|||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
{!appCredentials.isLoading ? (
|
{!appDbQuery.isLoading ? (
|
||||||
isGlobal ||
|
isGlobal ||
|
||||||
(existingCredentials.length > 0 && allowedMultipleInstalls ? (
|
(existingCredentials.length > 0 && allowedMultipleInstalls ? (
|
||||||
<div className="flex space-x-3">
|
<div className="flex space-x-3">
|
||||||
@@ -166,28 +186,19 @@ const Component = ({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Button
|
<InstallAppButtonChild appCategories={categories} userAdminTeams={appDbQuery.data?.userAdminTeams} addAppMutationInput={{ type, variant, slug }} multiInstall {...props} />
|
||||||
StartIcon={Plus}
|
|
||||||
{...props}
|
|
||||||
// @TODO: Overriding color and size prevent us from
|
|
||||||
// having to duplicate InstallAppButton for now.
|
|
||||||
color="primary"
|
|
||||||
size="base"
|
|
||||||
data-testid="install-app-button">
|
|
||||||
{t("install_another")}
|
|
||||||
</Button>
|
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : existingCredentials.length > 0 ? (
|
) : showDisconnectIntegration ? (
|
||||||
<DisconnectIntegration
|
<DisconnectIntegration
|
||||||
buttonProps={{ color: "secondary" }}
|
buttonProps={{ color: "secondary" }}
|
||||||
label={t("disconnect")}
|
label={t("disconnect")}
|
||||||
credentialId={existingCredentials[0]}
|
credentialId={existingCredentials[0]}
|
||||||
onSuccess={() => {
|
onSuccess={() => {
|
||||||
appCredentials.refetch();
|
appDbQuery.refetch();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -206,15 +217,7 @@ const Component = ({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Button
|
<InstallAppButtonChild appCategories={categories} userAdminTeams={appDbQuery.data?.userAdminTeams} addAppMutationInput={{type, variant, slug}} credentials={appDbQuery.data?.credentials} {...props} />
|
||||||
data-testid="install-app-button"
|
|
||||||
{...props}
|
|
||||||
// @TODO: Overriding color and size prevent us from
|
|
||||||
// having to duplicate InstallAppButton for now.
|
|
||||||
color="primary"
|
|
||||||
size="base">
|
|
||||||
{t("install_app")}
|
|
||||||
</Button>
|
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -385,3 +388,107 @@ export default function App(props: {
|
|||||||
</Shell>
|
</Shell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const InstallAppButtonChild = ({
|
||||||
|
userAdminTeams,
|
||||||
|
addAppMutationInput,
|
||||||
|
appCategories,
|
||||||
|
multiInstall,
|
||||||
|
credentials,
|
||||||
|
...props
|
||||||
|
}: {
|
||||||
|
userAdminTeams?: UserAdminTeams;
|
||||||
|
addAppMutationInput: { type: App["type"]; variant: string; slug: string };
|
||||||
|
appCategories: string[];
|
||||||
|
multiInstall?: boolean;
|
||||||
|
credentials?: RouterOutputs["viewer"]["appCredentialsByType"]["credentials"];
|
||||||
|
} & ButtonProps) => {
|
||||||
|
const { t } = useLocale();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const mutation = useAddAppMutation(null, {
|
||||||
|
onSuccess: (data) => {
|
||||||
|
if (data?.setupPending) return;
|
||||||
|
showToast(t("app_successfully_installed"), "success");
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
if (error instanceof Error) showToast(error.message || t("app_could_not_be_installed"), "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!userAdminTeams?.length || appCategories.some((category) => category === "calendar")) {
|
||||||
|
return <Button
|
||||||
|
data-testid="install-app-button"
|
||||||
|
{...props}
|
||||||
|
// @TODO: Overriding color and size prevent us from
|
||||||
|
// having to duplicate InstallAppButton for now.
|
||||||
|
color="primary"
|
||||||
|
size="base">
|
||||||
|
{multiInstall ? t("install_another") : t("install_app")}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dropdown>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button
|
||||||
|
data-testid="install-app-button"
|
||||||
|
{...props}
|
||||||
|
// @TODO: Overriding color and size prevent us from
|
||||||
|
// having to duplicate InstallAppButton for now.
|
||||||
|
color="primary"
|
||||||
|
size="base">
|
||||||
|
{multiInstall ? t("install_another") : t("install_app")}
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuPortal>
|
||||||
|
<DropdownMenuContent
|
||||||
|
onInteractOutside={(event) => {
|
||||||
|
if (mutation.isLoading) event.preventDefault();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{mutation.isLoading && (
|
||||||
|
<div className="z-1 fixed inset-0 flex items-center justify-center bg-black bg-opacity-50">
|
||||||
|
<Spinner />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<DropdownMenuLabel>{t("install_app_on")}</DropdownMenuLabel>
|
||||||
|
{userAdminTeams.map((team) => {
|
||||||
|
|
||||||
|
const isInstalled = credentials &&
|
||||||
|
credentials.some((credential) =>
|
||||||
|
credential?.teamId ? credential?.teamId === team.id : credential.userId === team.id
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownItem
|
||||||
|
type="button"
|
||||||
|
data-testid={team.isUser ? "install-app-button-personal" : "anything else"}
|
||||||
|
key={team.id}
|
||||||
|
disabled={
|
||||||
|
isInstalled
|
||||||
|
}
|
||||||
|
StartIcon={(props) => (
|
||||||
|
<Avatar
|
||||||
|
alt={team.logo || ""}
|
||||||
|
imageSrc={team.logo || `${CAL_URL}/${team.logo}/avatar.png`} // if no image, use default avatar
|
||||||
|
size="sm"
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
onClick={() => {
|
||||||
|
mutation.mutate(
|
||||||
|
team.isUser ? addAppMutationInput : { ...addAppMutationInput, teamId: team.id }
|
||||||
|
);
|
||||||
|
}}>
|
||||||
|
<p>{team.name}{" "}
|
||||||
|
{isInstalled &&
|
||||||
|
`(${t("installed")})`}</p>
|
||||||
|
</DropdownItem>
|
||||||
|
)})}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenuPortal>
|
||||||
|
</Dropdown>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,51 +1,117 @@
|
|||||||
|
import type {
|
||||||
|
DefaultEventLocationType,
|
||||||
|
EventLocationTypeFromApp,
|
||||||
|
LocationObject,
|
||||||
|
} from "@calcom/app-store/locations";
|
||||||
import { getEventLocationType, getTranslatedLocation } from "@calcom/app-store/locations";
|
import { getEventLocationType, getTranslatedLocation } from "@calcom/app-store/locations";
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { Tooltip } from "@calcom/ui";
|
import { Tooltip } from "@calcom/ui";
|
||||||
import { Link } from "@calcom/ui/components/icon";
|
import { Link } from "@calcom/ui/components/icon";
|
||||||
|
|
||||||
import type { Props } from "./pages/AvailabilityPage";
|
|
||||||
|
|
||||||
const excludeNullValues = (value: unknown) => !!value;
|
const excludeNullValues = (value: unknown) => !!value;
|
||||||
|
|
||||||
export function AvailableEventLocations({ locations }: { locations: Props["eventType"]["locations"] }) {
|
function RenderIcon({
|
||||||
|
eventLocationType,
|
||||||
|
isTooltip,
|
||||||
|
}: {
|
||||||
|
eventLocationType: DefaultEventLocationType | EventLocationTypeFromApp;
|
||||||
|
isTooltip: boolean;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src={eventLocationType.iconUrl}
|
||||||
|
className={classNames(
|
||||||
|
"me-[10px] h-4 w-4 opacity-70 dark:opacity-100",
|
||||||
|
!eventLocationType.iconUrl?.startsWith("/app-store") ? "dark:invert-[.65]" : "",
|
||||||
|
!eventLocationType.iconUrl?.startsWith("/app-store") && isTooltip && "invert"
|
||||||
|
)}
|
||||||
|
alt={`${eventLocationType.label} icon`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderLocationTooltip({ locations }: { locations: LocationObject[] }) {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
|
|
||||||
const renderLocations = locations.map((location, index) => {
|
return (
|
||||||
const eventLocationType = getEventLocationType(location.type);
|
<div className="my-2 me-2 flex w-full flex-col space-y-3 break-words">
|
||||||
if (!eventLocationType) {
|
<p>{t("select_on_next_step")}</p>
|
||||||
// It's possible that the location app got uninstalled
|
{locations.map(
|
||||||
return null;
|
(
|
||||||
}
|
location: Pick<Partial<LocationObject>, "link" | "address"> &
|
||||||
if (eventLocationType.variable === "hostDefault") {
|
Omit<LocationObject, "link" | "address">,
|
||||||
return null;
|
index: number
|
||||||
}
|
) => {
|
||||||
|
const eventLocationType = getEventLocationType(location.type);
|
||||||
|
if (!eventLocationType) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const translatedLocation = getTranslatedLocation(location, eventLocationType, t);
|
||||||
|
return (
|
||||||
|
<div key={`${location.type}-${index}`} className="font-sm flex flex-row items-center">
|
||||||
|
<RenderIcon eventLocationType={eventLocationType} isTooltip />
|
||||||
|
<p className="line-clamp-1">{translatedLocation}</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const translatedLocation = getTranslatedLocation(location, eventLocationType, t);
|
export function AvailableEventLocations({ locations }: { locations: LocationObject[] }) {
|
||||||
|
const { t } = useLocale();
|
||||||
|
|
||||||
return (
|
const renderLocations = locations.map(
|
||||||
<div key={`${location.type}-${index}`} className="flex flex-row items-center text-sm font-medium">
|
(
|
||||||
{eventLocationType.iconUrl === "/link.svg" ? (
|
location: Pick<Partial<LocationObject>, "link" | "address"> & Omit<LocationObject, "link" | "address">,
|
||||||
<Link className="text-default ml-[2px] h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] " />
|
index: number
|
||||||
) : (
|
) => {
|
||||||
<img
|
const eventLocationType = getEventLocationType(location.type);
|
||||||
src={eventLocationType.iconUrl}
|
if (!eventLocationType) {
|
||||||
className={classNames(
|
// It's possible that the location app got uninstalled
|
||||||
"ml-[2px] h-4 w-4 opacity-70 ltr:mr-[10px] rtl:ml-[10px] dark:opacity-100 ",
|
return null;
|
||||||
!eventLocationType.iconUrl?.startsWith("/app-store") ? "dark:invert-[.65]" : ""
|
}
|
||||||
)}
|
if (eventLocationType.variable === "hostDefault") {
|
||||||
alt={`${eventLocationType.label} icon`}
|
return null;
|
||||||
/>
|
}
|
||||||
)}
|
|
||||||
<Tooltip content={translatedLocation}>
|
const translatedLocation = getTranslatedLocation(location, eventLocationType, t);
|
||||||
<p className="line-clamp-1">{translatedLocation}</p>
|
|
||||||
</Tooltip>
|
return (
|
||||||
</div>
|
<div key={`${location.type}-${index}`} className="flex flex-row items-center text-sm font-medium">
|
||||||
);
|
{eventLocationType.iconUrl === "/link.svg" ? (
|
||||||
});
|
<Link className="text-default ml-[2px] h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] " />
|
||||||
|
) : (
|
||||||
|
<RenderIcon eventLocationType={eventLocationType} isTooltip={false} />
|
||||||
|
)}
|
||||||
|
<Tooltip content={translatedLocation}>
|
||||||
|
<p className="line-clamp-1">{translatedLocation}</p>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const filteredLocations = renderLocations.filter(excludeNullValues) as JSX.Element[];
|
const filteredLocations = renderLocations.filter(excludeNullValues) as JSX.Element[];
|
||||||
return filteredLocations.length ? (
|
|
||||||
|
return filteredLocations.length > 1 ? (
|
||||||
|
<div className="flex flex-row items-center text-sm font-medium">
|
||||||
|
<img
|
||||||
|
src="/map-pin.svg"
|
||||||
|
className={classNames("me-[10px] h-4 w-4 opacity-70 dark:invert")}
|
||||||
|
alt="map-pin"
|
||||||
|
/>
|
||||||
|
<Tooltip content={<RenderLocationTooltip locations={locations} />}>
|
||||||
|
<p className="line-clamp-1">
|
||||||
|
{t("location_options", {
|
||||||
|
locationCount: filteredLocations.length,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
) : filteredLocations.length === 1 ? (
|
||||||
<div className="text-default mr-6 flex w-full flex-col space-y-4 break-words text-sm">
|
<div className="text-default mr-6 flex w-full flex-col space-y-4 break-words text-sm">
|
||||||
{filteredLocations}
|
{filteredLocations}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const reserveSlot = (slot: Slot) => {
|
const reserveSlot = (slot: Slot) => {
|
||||||
|
// Prevent double clicking
|
||||||
|
if (reserveSlotMutation.isLoading || reserveSlotMutation.isSuccess) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
reserveSlotMutation.mutate({
|
reserveSlotMutation.mutate({
|
||||||
slotUtcStartDate: slot.time,
|
slotUtcStartDate: slot.time,
|
||||||
eventTypeId,
|
eventTypeId,
|
||||||
@@ -132,8 +136,20 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
|
|||||||
let slotFull, notEnoughSeats;
|
let slotFull, notEnoughSeats;
|
||||||
|
|
||||||
if (slot.attendees && seatsPerTimeSlot) slotFull = slot.attendees >= seatsPerTimeSlot;
|
if (slot.attendees && seatsPerTimeSlot) slotFull = slot.attendees >= seatsPerTimeSlot;
|
||||||
if (slot.attendees && bookingAttendees && seatsPerTimeSlot)
|
if (slot.attendees && bookingAttendees && seatsPerTimeSlot) {
|
||||||
notEnoughSeats = slot.attendees + bookingAttendees > seatsPerTimeSlot;
|
notEnoughSeats = slot.attendees + bookingAttendees > seatsPerTimeSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isHalfFull =
|
||||||
|
slot.attendees && seatsPerTimeSlot && slot.attendees / seatsPerTimeSlot >= 0.5;
|
||||||
|
const isNearlyFull =
|
||||||
|
slot.attendees && seatsPerTimeSlot && slot.attendees / seatsPerTimeSlot >= 0.83;
|
||||||
|
|
||||||
|
const colorClass = isNearlyFull
|
||||||
|
? "text-rose-600"
|
||||||
|
: isHalfFull
|
||||||
|
? "text-yellow-500"
|
||||||
|
: "text-emerald-400";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-slot-owner={(slot.userIds || []).join(",")} key={`${dayjs(slot.time).format()}`}>
|
<div data-slot-owner={(slot.userIds || []).join(",")} key={`${dayjs(slot.time).format()}`}>
|
||||||
@@ -144,7 +160,9 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
"text-default bg-default border-subtle mb-2 block rounded-sm border py-2 font-medium opacity-25",
|
"text-default bg-default border-subtle mb-2 block rounded-sm border py-2 font-medium opacity-25",
|
||||||
brand === "#fff" || brand === "#ffffff" ? "" : ""
|
brand === "#fff" || brand === "#ffffff" ? "" : ""
|
||||||
)}>
|
)}
|
||||||
|
data-testid="time"
|
||||||
|
data-disabled="true">
|
||||||
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
|
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
|
||||||
{notEnoughSeats ? (
|
{notEnoughSeats ? (
|
||||||
<p className="text-sm">{t("not_enough_seats")}</p>
|
<p className="text-sm">{t("not_enough_seats")}</p>
|
||||||
@@ -165,14 +183,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
|
|||||||
data-disabled="false">
|
data-disabled="false">
|
||||||
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
|
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
|
||||||
{!!seatsPerTimeSlot && (
|
{!!seatsPerTimeSlot && (
|
||||||
<p
|
<p className={`${colorClass} text-sm`}>
|
||||||
className={`${
|
|
||||||
slot.attendees && slot.attendees / seatsPerTimeSlot >= 0.8
|
|
||||||
? "text-rose-600"
|
|
||||||
: slot.attendees && slot.attendees / seatsPerTimeSlot >= 0.33
|
|
||||||
? "text-yellow-500"
|
|
||||||
: "text-emerald-400"
|
|
||||||
} text-sm`}>
|
|
||||||
{slot.attendees ? seatsPerTimeSlot - slot.attendees : seatsPerTimeSlot} /{" "}
|
{slot.attendees ? seatsPerTimeSlot - slot.attendees : seatsPerTimeSlot} /{" "}
|
||||||
{seatsPerTimeSlot}{" "}
|
{seatsPerTimeSlot}{" "}
|
||||||
{t("seats_available", {
|
{t("seats_available", {
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
import type { FC, ReactNode } from "react";
|
|
||||||
import { useEffect } from "react";
|
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
|
||||||
import classNames from "@calcom/lib/classNames";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
||||||
import { SchedulingType } from "@calcom/prisma/enums";
|
|
||||||
import { Badge } from "@calcom/ui";
|
|
||||||
import { CheckSquare, Clock } from "@calcom/ui/components/icon";
|
|
||||||
|
|
||||||
import useRouterQuery from "@lib/hooks/useRouterQuery";
|
|
||||||
|
|
||||||
import { UserAvatars } from "@components/booking/UserAvatars";
|
|
||||||
import EventTypeDescriptionSafeHTML from "@components/eventtype/EventTypeDescriptionSafeHTML";
|
|
||||||
|
|
||||||
import type { AvailabilityPageProps } from "../../pages/[user]/[type]";
|
|
||||||
import type { BookPageProps } from "../../pages/[user]/book";
|
|
||||||
import type { DynamicAvailabilityPageProps } from "../../pages/d/[link]/[slug]";
|
|
||||||
import type { HashLinkPageProps } from "../../pages/d/[link]/book";
|
|
||||||
import type { AvailabilityTeamPageProps } from "../../pages/team/[slug]/[type]";
|
|
||||||
import type { TeamBookingPageProps } from "../../pages/team/[slug]/book";
|
|
||||||
import { AvailableEventLocations } from "./AvailableEventLocations";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
profile:
|
|
||||||
| AvailabilityPageProps["profile"]
|
|
||||||
| HashLinkPageProps["profile"]
|
|
||||||
| TeamBookingPageProps["profile"]
|
|
||||||
| BookPageProps["profile"]
|
|
||||||
| AvailabilityTeamPageProps["profile"]
|
|
||||||
| DynamicAvailabilityPageProps["profile"];
|
|
||||||
eventType:
|
|
||||||
| AvailabilityPageProps["eventType"]
|
|
||||||
| HashLinkPageProps["eventType"]
|
|
||||||
| TeamBookingPageProps["eventType"]
|
|
||||||
| BookPageProps["eventType"]
|
|
||||||
| AvailabilityTeamPageProps["eventType"]
|
|
||||||
| DynamicAvailabilityPageProps["eventType"];
|
|
||||||
isBookingPage?: boolean;
|
|
||||||
children: ReactNode;
|
|
||||||
isMobile?: boolean;
|
|
||||||
rescheduleUid?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BookingDescription: FC<Props> = (props) => {
|
|
||||||
const { profile, eventType, isBookingPage = false, children } = props;
|
|
||||||
const { date: bookingDate } = useRouterQuery("date");
|
|
||||||
const { t } = useLocale();
|
|
||||||
const { duration, setQuery: setDuration } = useRouterQuery("duration");
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
!duration ||
|
|
||||||
isNaN(Number(duration)) ||
|
|
||||||
(eventType.metadata?.multipleDuration &&
|
|
||||||
!eventType.metadata?.multipleDuration.includes(Number(duration)))
|
|
||||||
) {
|
|
||||||
setDuration(eventType.length);
|
|
||||||
}
|
|
||||||
}, [duration, setDuration, eventType.length, eventType.metadata?.multipleDuration]);
|
|
||||||
|
|
||||||
let requiresConfirmation = eventType?.requiresConfirmation;
|
|
||||||
let requiresConfirmationText = t("requires_confirmation");
|
|
||||||
const rcThreshold = eventType?.metadata?.requiresConfirmationThreshold;
|
|
||||||
if (rcThreshold) {
|
|
||||||
if (isBookingPage) {
|
|
||||||
if (dayjs(bookingDate).diff(dayjs(), rcThreshold.unit) > rcThreshold.time) {
|
|
||||||
requiresConfirmation = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
requiresConfirmationText = t("requires_confirmation_threshold", {
|
|
||||||
...rcThreshold,
|
|
||||||
unit: rcThreshold.unit.slice(0, -1),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<UserAvatars
|
|
||||||
profile={profile}
|
|
||||||
users={eventType.users}
|
|
||||||
showMembers={eventType.schedulingType !== SchedulingType.ROUND_ROBIN}
|
|
||||||
size="sm"
|
|
||||||
truncateAfter={3}
|
|
||||||
/>
|
|
||||||
<h2 className="text-default mb-2 mt-1 break-words text-sm font-medium ">
|
|
||||||
{eventType.team?.parent?.name} {profile.name}
|
|
||||||
</h2>
|
|
||||||
<h1 className="font-cal text-emphasis mb-6 break-words text-2xl font-semibold leading-none">
|
|
||||||
{eventType.title}
|
|
||||||
</h1>
|
|
||||||
<div className=" text-default flex flex-col space-y-4 text-sm font-medium">
|
|
||||||
{eventType?.description && (
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
"scroll-bar scrollbar-track-w-20 -mx-5 flex max-h-[180px] overflow-y-scroll px-5 ",
|
|
||||||
isBookingPage && "text-default text-sm font-medium"
|
|
||||||
)}>
|
|
||||||
{/* TODO: Fix colors when token is introdcued to DS */}
|
|
||||||
<div className="max-w-full flex-shrink break-words [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600">
|
|
||||||
<EventTypeDescriptionSafeHTML eventType={eventType} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{requiresConfirmation && (
|
|
||||||
<div className={classNames("items-top flex", isBookingPage && "text-default text-sm font-medium")}>
|
|
||||||
<div>
|
|
||||||
<CheckSquare className="ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] " />
|
|
||||||
</div>
|
|
||||||
{requiresConfirmationText}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<AvailableEventLocations
|
|
||||||
locations={eventType.locations as AvailabilityPageProps["eventType"]["locations"]}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
"flex flex-nowrap text-sm font-medium",
|
|
||||||
isBookingPage && "text-default",
|
|
||||||
!eventType.metadata?.multipleDuration && "items-center"
|
|
||||||
)}>
|
|
||||||
<Clock
|
|
||||||
className={classNames(
|
|
||||||
"ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]",
|
|
||||||
isBookingPage && "mt-[2px]"
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{eventType.metadata?.multipleDuration !== undefined ? (
|
|
||||||
!isBookingPage ? (
|
|
||||||
<ul className="-mt-1 flex flex-wrap gap-1">
|
|
||||||
{eventType.metadata.multipleDuration.map((dur, idx) => (
|
|
||||||
<li key={idx}>
|
|
||||||
<Badge
|
|
||||||
variant="gray"
|
|
||||||
className={classNames(
|
|
||||||
duration === dur.toString()
|
|
||||||
? "bg-emphasis border-emphasis text-emphasis "
|
|
||||||
: "bg-subtle text-default border-transparent ",
|
|
||||||
"cursor-pointer border"
|
|
||||||
)}
|
|
||||||
onClick={() => {
|
|
||||||
setDuration(dur);
|
|
||||||
}}>
|
|
||||||
{dur} {t("minute_timeUnit")}
|
|
||||||
</Badge>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
) : (
|
|
||||||
`${duration} ${t("minutes")}`
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
`${eventType.length} ${t("minutes")}`
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default BookingDescription;
|
|
||||||
@@ -10,6 +10,7 @@ import ViewRecordingsDialog from "@calcom/features/ee/video/ViewRecordingsDialog
|
|||||||
import classNames from "@calcom/lib/classNames";
|
import classNames from "@calcom/lib/classNames";
|
||||||
import { formatTime } from "@calcom/lib/date-fns";
|
import { formatTime } from "@calcom/lib/date-fns";
|
||||||
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
||||||
|
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { getEveryFreqFor } from "@calcom/lib/recurringStrings";
|
import { getEveryFreqFor } from "@calcom/lib/recurringStrings";
|
||||||
import { BookingStatus } from "@calcom/prisma/enums";
|
import { BookingStatus } from "@calcom/prisma/enums";
|
||||||
@@ -49,6 +50,8 @@ type BookingItemProps = BookingItem & {
|
|||||||
function BookingListItem(booking: BookingItemProps) {
|
function BookingListItem(booking: BookingItemProps) {
|
||||||
// Get user so we can determine 12/24 hour format preferences
|
// Get user so we can determine 12/24 hour format preferences
|
||||||
const query = useMeQuery();
|
const query = useMeQuery();
|
||||||
|
const bookerUrl = useBookerUrl();
|
||||||
|
|
||||||
const user = query.data;
|
const user = query.data;
|
||||||
const {
|
const {
|
||||||
t,
|
t,
|
||||||
@@ -170,7 +173,7 @@ function BookingListItem(booking: BookingItemProps) {
|
|||||||
id: "reschedule",
|
id: "reschedule",
|
||||||
icon: Clock,
|
icon: Clock,
|
||||||
label: t("reschedule_booking"),
|
label: t("reschedule_booking"),
|
||||||
href: `/reschedule/${booking.uid}${
|
href: `${bookerUrl}/reschedule/${booking.uid}${
|
||||||
booking.seatsReferences.length ? `?seatReferenceUid=${getSeatReferenceUid()}` : ""
|
booking.seatsReferences.length ? `?seatReferenceUid=${getSeatReferenceUid()}` : ""
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,292 +0,0 @@
|
|||||||
import dynamic from "next/dynamic";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager";
|
|
||||||
import dayjs from "@calcom/dayjs";
|
|
||||||
import {
|
|
||||||
useEmbedNonStylesConfig,
|
|
||||||
useEmbedStyles,
|
|
||||||
useEmbedUiConfig,
|
|
||||||
useIsBackgroundTransparent,
|
|
||||||
useIsEmbed,
|
|
||||||
} from "@calcom/embed-core/embed-iframe";
|
|
||||||
import classNames from "@calcom/lib/classNames";
|
|
||||||
import useGetBrandingColours from "@calcom/lib/getBrandColours";
|
|
||||||
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
||||||
import useTheme from "@calcom/lib/hooks/useTheme";
|
|
||||||
import notEmpty from "@calcom/lib/notEmpty";
|
|
||||||
import { getRecurringFreq } from "@calcom/lib/recurringStrings";
|
|
||||||
import { detectBrowserTimeFormat, setIs24hClockInLocalStorage, TimeFormat } from "@calcom/lib/timeFormat";
|
|
||||||
import { trpc } from "@calcom/trpc";
|
|
||||||
import { HeadSeo, NumberInput, useCalcomTheme } from "@calcom/ui";
|
|
||||||
import { CreditCard, User, RefreshCcw } from "@calcom/ui/components/icon";
|
|
||||||
|
|
||||||
import { timeZone as localStorageTimeZone } from "@lib/clock";
|
|
||||||
|
|
||||||
import BookingDescription from "@components/booking/BookingDescription";
|
|
||||||
import { SlotPicker } from "@components/booking/SlotPicker";
|
|
||||||
|
|
||||||
import type { AvailabilityPageProps } from "../../../pages/[user]/[type]";
|
|
||||||
import type { DynamicAvailabilityPageProps } from "../../../pages/d/[link]/[slug]";
|
|
||||||
import type { AvailabilityTeamPageProps } from "../../../pages/team/[slug]/[type]";
|
|
||||||
|
|
||||||
const PoweredBy = dynamic(() => import("@calcom/ee/components/PoweredBy"));
|
|
||||||
|
|
||||||
const Toaster = dynamic(() => import("react-hot-toast").then((mod) => mod.Toaster), { ssr: false });
|
|
||||||
/*const SlotPicker = dynamic(() => import("../SlotPicker").then((mod) => mod.SlotPicker), {
|
|
||||||
ssr: false,
|
|
||||||
loading: () => <div className="mt-8 px-4 pb-4 sm:mt-0 sm:p-4 md:min-w-[300px] md:px-5 lg:min-w-[455px]" />,
|
|
||||||
});*/
|
|
||||||
const TimezoneDropdown = dynamic(() => import("../TimezoneDropdown").then((mod) => mod.TimezoneDropdown), {
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const dateQuerySchema = z.object({
|
|
||||||
rescheduleUid: z.string().optional().default(""),
|
|
||||||
date: z.string().optional().default(""),
|
|
||||||
timeZone: z.string().optional().default(""),
|
|
||||||
seatReferenceUid: z.string().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type Props = AvailabilityTeamPageProps | AvailabilityPageProps | DynamicAvailabilityPageProps;
|
|
||||||
|
|
||||||
const useBrandColors = ({ brandColor, darkBrandColor }: { brandColor: string; darkBrandColor: string }) => {
|
|
||||||
const brandTheme = useGetBrandingColours({
|
|
||||||
lightVal: brandColor,
|
|
||||||
darkVal: darkBrandColor,
|
|
||||||
});
|
|
||||||
useCalcomTheme(brandTheme);
|
|
||||||
};
|
|
||||||
|
|
||||||
const AvailabilityPage = ({ profile, eventType, ...restProps }: Props) => {
|
|
||||||
const router = useRouter();
|
|
||||||
const isEmbed = useIsEmbed(restProps.isEmbed);
|
|
||||||
const query = dateQuerySchema.parse(router.query);
|
|
||||||
const { rescheduleUid } = query;
|
|
||||||
useTheme(profile.theme);
|
|
||||||
useBrandColors({
|
|
||||||
brandColor: profile.brandColor,
|
|
||||||
darkBrandColor: profile.darkBrandColor,
|
|
||||||
});
|
|
||||||
const { t, i18n } = useLocale();
|
|
||||||
const availabilityDatePickerEmbedStyles = useEmbedStyles("availabilityDatePicker");
|
|
||||||
//TODO: Plan to remove shouldAlignCentrallyInEmbed config
|
|
||||||
const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig("align") !== "left";
|
|
||||||
const shouldAlignCentrally = !isEmbed || shouldAlignCentrallyInEmbed;
|
|
||||||
const isBackgroundTransparent = useIsBackgroundTransparent();
|
|
||||||
|
|
||||||
const [timeZone, setTimeZone] = useState<string>();
|
|
||||||
const [timeFormat, setTimeFormat] = useState<TimeFormat>(detectBrowserTimeFormat);
|
|
||||||
|
|
||||||
const onTimeFormatChange = (is24Hours: boolean) => {
|
|
||||||
setTimeFormat(is24Hours ? TimeFormat.TWENTY_FOUR_HOUR : TimeFormat.TWELVE_HOUR);
|
|
||||||
setIs24hClockInLocalStorage(is24Hours);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTimeZone(localStorageTimeZone() || dayjs.tz.guess());
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const [recurringEventCount, setRecurringEventCount] = useState(eventType.recurringEvent?.count);
|
|
||||||
|
|
||||||
/*
|
|
||||||
const telemetry = useTelemetry();
|
|
||||||
useEffect(() => {
|
|
||||||
if (top !== window) {
|
|
||||||
//page_view will be collected automatically by _middleware.ts
|
|
||||||
telemetry.event(
|
|
||||||
telemetryEventTypes.embedView,
|
|
||||||
collectPageParameters("/availability", { isTeamBooking: document.URL.includes("team/") })
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [telemetry]); */
|
|
||||||
const embedUiConfig = useEmbedUiConfig();
|
|
||||||
// get dynamic user list here
|
|
||||||
const userList = eventType.users ? eventType.users.map((user) => user.username).filter(notEmpty) : [];
|
|
||||||
|
|
||||||
const timezoneDropdown = useMemo(
|
|
||||||
() => <TimezoneDropdown timeZone={timeZone} onChangeTimeZone={setTimeZone} />,
|
|
||||||
[timeZone]
|
|
||||||
);
|
|
||||||
const paymentAppData = getPaymentAppData(eventType);
|
|
||||||
|
|
||||||
const rawSlug = profile.slug ? profile.slug.split("/") : [];
|
|
||||||
if (rawSlug.length > 1) rawSlug.pop(); //team events have team name as slug, but user events have [user]/[type] as slug.
|
|
||||||
|
|
||||||
const showEventTypeDetails = (isEmbed && !embedUiConfig.hideEventTypeDetails) || !isEmbed;
|
|
||||||
|
|
||||||
const { data: bookingAttendees } = trpc.viewer.bookings.getBookingAttendees.useQuery(
|
|
||||||
{
|
|
||||||
seatReferenceUid: rescheduleUid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
enabled: !!(rescheduleUid && eventType.seatsPerTimeSlot),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<HeadSeo
|
|
||||||
title={`${rescheduleUid ? t("reschedule") : ""} ${eventType.title} | ${profile.name}`}
|
|
||||||
description={`${rescheduleUid ? t("reschedule") : ""} ${eventType.title}`}
|
|
||||||
meeting={{
|
|
||||||
title: eventType.title,
|
|
||||||
profile: { name: `${profile.name}`, image: profile.image },
|
|
||||||
users: [
|
|
||||||
...(eventType.users || []).map((user) => ({
|
|
||||||
name: `${user.name}`,
|
|
||||||
username: `${user.username}`,
|
|
||||||
})),
|
|
||||||
],
|
|
||||||
}}
|
|
||||||
nextSeoProps={{
|
|
||||||
nofollow: eventType.hidden,
|
|
||||||
noindex: eventType.hidden,
|
|
||||||
}}
|
|
||||||
isBrandingHidden={restProps.isBrandingHidden}
|
|
||||||
/>
|
|
||||||
<BookingPageTagManager eventType={eventType} />
|
|
||||||
<div>
|
|
||||||
<main
|
|
||||||
className={classNames(
|
|
||||||
"flex flex-col md:mx-4",
|
|
||||||
shouldAlignCentrally ? "items-center" : "items-start",
|
|
||||||
!isEmbed && classNames("bg-subtle dark:bg-default mx-auto my-0 ease-in-out md:my-24")
|
|
||||||
)}>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
style={availabilityDatePickerEmbedStyles}
|
|
||||||
className={classNames(
|
|
||||||
isBackgroundTransparent ? "" : "bg-default dark:bg-muted pb-4 md:pb-0",
|
|
||||||
"border-booker md:border-booker-width md:rounded-md",
|
|
||||||
isEmbed && "mx-auto"
|
|
||||||
)}>
|
|
||||||
<div className="md:flex">
|
|
||||||
{showEventTypeDetails && (
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
" border-subtle flex flex-col p-5 sm:border-r",
|
|
||||||
"min-w-full md:w-[230px] md:min-w-[230px]",
|
|
||||||
recurringEventCount && "xl:w-[380px] xl:min-w-[380px]"
|
|
||||||
)}>
|
|
||||||
<BookingDescription profile={profile} eventType={eventType} rescheduleUid={rescheduleUid}>
|
|
||||||
{rescheduleUid && eventType.seatsPerTimeSlot && bookingAttendees && (
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
"flex flex-nowrap items-center text-sm font-medium",
|
|
||||||
" text-default",
|
|
||||||
"ltr:mr-[10px] rtl:ml-[10px]"
|
|
||||||
)}>
|
|
||||||
<User
|
|
||||||
className={classNames(
|
|
||||||
"min-h-4 min-w-4 ml-[2px] inline-block ltr:mr-[10px] rtl:ml-[10px]",
|
|
||||||
"mt-[2px]"
|
|
||||||
)}
|
|
||||||
/>{" "}
|
|
||||||
{t("event_type_seats", { numberOfSeats: bookingAttendees })}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!rescheduleUid && eventType.recurringEvent && (
|
|
||||||
<div className="flex items-start text-sm font-medium">
|
|
||||||
<RefreshCcw className="float-left ml-[2px] mt-[7px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] " />
|
|
||||||
<div>
|
|
||||||
<p className="-ml-2 mb-1 inline px-2 py-1">
|
|
||||||
{getRecurringFreq({ t, recurringEvent: eventType.recurringEvent })}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<NumberInput
|
|
||||||
defaultValue={eventType.recurringEvent.count}
|
|
||||||
min="1"
|
|
||||||
max={eventType.recurringEvent.count}
|
|
||||||
isFullWidth={false}
|
|
||||||
className="me-2 inline w-16"
|
|
||||||
onChange={(event) => {
|
|
||||||
setRecurringEventCount(parseInt(event?.target.value));
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<p className="inline">
|
|
||||||
{t("occurrence", {
|
|
||||||
count: recurringEventCount,
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{paymentAppData.price > 0 && (
|
|
||||||
<p className="-ml-2 px-2 text-sm font-medium">
|
|
||||||
<CreditCard className="-mt-1 ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]" />
|
|
||||||
{paymentAppData.paymentOption === "HOLD" ? (
|
|
||||||
<>
|
|
||||||
{t("no_show_fee_amount", {
|
|
||||||
amount: paymentAppData.price / 100.0,
|
|
||||||
formatParams: { amount: { currency: paymentAppData.currency } },
|
|
||||||
})}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{new Intl.NumberFormat(i18n.language, {
|
|
||||||
style: "currency",
|
|
||||||
currency: paymentAppData.currency,
|
|
||||||
}).format(paymentAppData.price / 100)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{timezoneDropdown}
|
|
||||||
</BookingDescription>
|
|
||||||
|
|
||||||
{/* Temporarily disabled - booking?.startTime && rescheduleUid && (
|
|
||||||
<div>
|
|
||||||
<p
|
|
||||||
className="mt-4 mb-3 text-default"
|
|
||||||
data-testid="former_time_p_desktop">
|
|
||||||
{t("former_time")}
|
|
||||||
</p>
|
|
||||||
<p className="text-subtle line-through ">
|
|
||||||
<CalendarIcon className="ltr:mr-[10px] rtl:ml-[10px] -mt-1 inline-block h-4 w-4 text-subtle" />
|
|
||||||
{typeof booking.startTime === "string" && parseDate(dayjs(booking.startTime), i18n)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)*/}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<SlotPicker
|
|
||||||
weekStart={
|
|
||||||
typeof profile.weekStart === "string"
|
|
||||||
? ([
|
|
||||||
"Sunday",
|
|
||||||
"Monday",
|
|
||||||
"Tuesday",
|
|
||||||
"Wednesday",
|
|
||||||
"Thursday",
|
|
||||||
"Friday",
|
|
||||||
"Saturday",
|
|
||||||
].indexOf(profile.weekStart) as 0 | 1 | 2 | 3 | 4 | 5 | 6)
|
|
||||||
: profile.weekStart /* Allows providing weekStart as number */
|
|
||||||
}
|
|
||||||
eventType={eventType}
|
|
||||||
timeFormat={timeFormat}
|
|
||||||
onTimeFormatChange={onTimeFormatChange}
|
|
||||||
timeZone={timeZone}
|
|
||||||
users={userList}
|
|
||||||
seatsPerTimeSlot={eventType.seatsPerTimeSlot || undefined}
|
|
||||||
bookingAttendees={bookingAttendees || undefined}
|
|
||||||
recurringEventCount={recurringEventCount}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* FIXME: We don't show branding in Embed yet because we need to place branding on top of the main content. Keeping it outside the main content would have visibility issues because outside main content background is transparent */}
|
|
||||||
{!restProps.isBrandingHidden && !isEmbed && <PoweredBy />}
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
<Toaster position="bottom-right" />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AvailabilityPage;
|
|
||||||
@@ -1,704 +0,0 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
|
||||||
import { useSession } from "next-auth/react";
|
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
import Head from "next/head";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
|
||||||
import { useForm, useFormContext } from "react-hook-form";
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager";
|
|
||||||
import type { EventLocationType } from "@calcom/app-store/locations";
|
|
||||||
import { createPaymentLink } from "@calcom/app-store/stripepayment/lib/client";
|
|
||||||
import type { LocationObject } from "@calcom/core/location";
|
|
||||||
import dayjs from "@calcom/dayjs";
|
|
||||||
import {
|
|
||||||
useEmbedNonStylesConfig,
|
|
||||||
useEmbedUiConfig,
|
|
||||||
useIsBackgroundTransparent,
|
|
||||||
useIsEmbed,
|
|
||||||
} from "@calcom/embed-core/embed-iframe";
|
|
||||||
import { createBooking, createRecurringBooking } from "@calcom/features/bookings/lib";
|
|
||||||
import { useTimePreferences } from "@calcom/features/bookings/lib";
|
|
||||||
import {
|
|
||||||
getBookingFieldsWithSystemFields,
|
|
||||||
SystemField,
|
|
||||||
} from "@calcom/features/bookings/lib/getBookingFields";
|
|
||||||
import getBookingResponsesSchema, {
|
|
||||||
getBookingResponsesPartialSchema,
|
|
||||||
} from "@calcom/features/bookings/lib/getBookingResponsesSchema";
|
|
||||||
import getLocationOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect";
|
|
||||||
import { FormBuilderField } from "@calcom/features/form-builder/FormBuilder";
|
|
||||||
import { bookingSuccessRedirect } from "@calcom/lib/bookingSuccessRedirect";
|
|
||||||
import classNames from "@calcom/lib/classNames";
|
|
||||||
import { APP_NAME, MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
|
||||||
import useGetBrandingColours from "@calcom/lib/getBrandColours";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
||||||
import useTheme from "@calcom/lib/hooks/useTheme";
|
|
||||||
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
|
||||||
import { HttpError } from "@calcom/lib/http-error";
|
|
||||||
import { parseDate, parseDateTimeWithTimeZone, parseRecurringDates } from "@calcom/lib/parse-dates";
|
|
||||||
import { getEveryFreqFor } from "@calcom/lib/recurringStrings";
|
|
||||||
import { telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
|
|
||||||
import { TimeFormat } from "@calcom/lib/timeFormat";
|
|
||||||
import { trpc } from "@calcom/trpc";
|
|
||||||
import { Button, Form, Tooltip, useCalcomTheme } from "@calcom/ui";
|
|
||||||
import { AlertTriangle, Calendar, RefreshCw, User } from "@calcom/ui/components/icon";
|
|
||||||
|
|
||||||
import { timeZone } from "@lib/clock";
|
|
||||||
import useRouterQuery from "@lib/hooks/useRouterQuery";
|
|
||||||
|
|
||||||
import BookingDescription from "@components/booking/BookingDescription";
|
|
||||||
|
|
||||||
import type { BookPageProps } from "../../../pages/[user]/book";
|
|
||||||
import type { HashLinkPageProps } from "../../../pages/d/[link]/book";
|
|
||||||
import type { TeamBookingPageProps } from "../../../pages/team/[slug]/book";
|
|
||||||
|
|
||||||
const Toaster = dynamic(() => import("react-hot-toast").then((mod) => mod.Toaster), { ssr: false });
|
|
||||||
|
|
||||||
/** These are like 40kb that not every user needs */
|
|
||||||
const BookingDescriptionPayment = dynamic(
|
|
||||||
() => import("@components/booking/BookingDescriptionPayment")
|
|
||||||
) as unknown as typeof import("@components/booking/BookingDescriptionPayment").default;
|
|
||||||
|
|
||||||
const useBrandColors = ({ brandColor, darkBrandColor }: { brandColor?: string; darkBrandColor?: string }) => {
|
|
||||||
const brandTheme = useGetBrandingColours({
|
|
||||||
lightVal: brandColor,
|
|
||||||
darkVal: darkBrandColor,
|
|
||||||
});
|
|
||||||
useCalcomTheme(brandTheme);
|
|
||||||
};
|
|
||||||
|
|
||||||
type BookingPageProps = BookPageProps | TeamBookingPageProps | HashLinkPageProps;
|
|
||||||
const BookingFields = ({
|
|
||||||
fields,
|
|
||||||
locations,
|
|
||||||
rescheduleUid,
|
|
||||||
isDynamicGroupBooking,
|
|
||||||
}: {
|
|
||||||
fields: BookingPageProps["eventType"]["bookingFields"];
|
|
||||||
locations: LocationObject[];
|
|
||||||
rescheduleUid?: string;
|
|
||||||
isDynamicGroupBooking: boolean;
|
|
||||||
}) => {
|
|
||||||
const { t } = useLocale();
|
|
||||||
const { watch, setValue } = useFormContext();
|
|
||||||
const locationResponse = watch("responses.location");
|
|
||||||
const currentView = rescheduleUid ? "reschedule" : "";
|
|
||||||
|
|
||||||
return (
|
|
||||||
// TODO: It might make sense to extract this logic into BookingFields config, that would allow to quickly configure system fields and their editability in fresh booking and reschedule booking view
|
|
||||||
<div>
|
|
||||||
{fields.map((field, index) => {
|
|
||||||
// During reschedule by default all system fields are readOnly. Make them editable on case by case basis.
|
|
||||||
// Allowing a system field to be edited might require sending emails to attendees, so we need to be careful
|
|
||||||
let readOnly =
|
|
||||||
(field.editable === "system" || field.editable === "system-but-optional") && !!rescheduleUid;
|
|
||||||
|
|
||||||
let noLabel = false;
|
|
||||||
let hidden = !!field.hidden;
|
|
||||||
const fieldViews = field.views;
|
|
||||||
|
|
||||||
if (fieldViews && !fieldViews.find((view) => view.id === currentView)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (field.name === SystemField.Enum.rescheduleReason) {
|
|
||||||
// rescheduleReason is a reschedule specific field and thus should be editable during reschedule
|
|
||||||
readOnly = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (field.name === SystemField.Enum.smsReminderNumber) {
|
|
||||||
// `smsReminderNumber` and location.optionValue when location.value===phone are the same data point. We should solve it in a better way in the Form Builder itself.
|
|
||||||
// I think we should have a way to connect 2 fields together and have them share the same value in Form Builder
|
|
||||||
if (locationResponse?.value === "phone") {
|
|
||||||
setValue(`responses.${SystemField.Enum.smsReminderNumber}`, locationResponse?.optionValue);
|
|
||||||
// Just don't render the field now, as the value is already connected to attendee phone location
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// `smsReminderNumber` can be edited during reschedule even though it's a system field
|
|
||||||
readOnly = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (field.name === SystemField.Enum.guests) {
|
|
||||||
// No matter what user configured for Guests field, we don't show it for dynamic group booking as that doesn't support guests
|
|
||||||
hidden = isDynamicGroupBooking ? true : !!field.hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't show `notes` field during reschedule
|
|
||||||
if (
|
|
||||||
(field.name === SystemField.Enum.notes || field.name === SystemField.Enum.guests) &&
|
|
||||||
!!rescheduleUid
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dynamically populate location field options
|
|
||||||
if (field.name === SystemField.Enum.location && field.type === "radioInput") {
|
|
||||||
if (!field.optionsInputs) {
|
|
||||||
throw new Error("radioInput must have optionsInputs");
|
|
||||||
}
|
|
||||||
const optionsInputs = field.optionsInputs;
|
|
||||||
|
|
||||||
// TODO: Instead of `getLocationOptionsForSelect` options should be retrieved from dataStore[field.getOptionsAt]. It would make it agnostic of the `name` of the field.
|
|
||||||
const options = getLocationOptionsForSelect(locations, t);
|
|
||||||
options.forEach((option) => {
|
|
||||||
const optionInput = optionsInputs[option.value as keyof typeof optionsInputs];
|
|
||||||
if (optionInput) {
|
|
||||||
optionInput.placeholder = option.inputPlaceholder;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
field.options = options.filter(
|
|
||||||
(location): location is NonNullable<(typeof options)[number]> => !!location
|
|
||||||
);
|
|
||||||
// If we have only one option and it has an input, we don't show the field label because Option name acts as label.
|
|
||||||
// e.g. If it's just Attendee Phone Number option then we don't show `Location` label
|
|
||||||
if (field.options.length === 1) {
|
|
||||||
if (field.optionsInputs[field.options[0].value]) {
|
|
||||||
noLabel = true;
|
|
||||||
} else {
|
|
||||||
// If there's only one option and it doesn't have an input, we don't show the field at all because it's visible in the left side bar
|
|
||||||
hidden = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const label = noLabel ? "" : field.label || t(field.defaultLabel || "");
|
|
||||||
const placeholder = field.placeholder || t(field.defaultPlaceholder || "");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormBuilderField
|
|
||||||
className="mb-4"
|
|
||||||
field={{ ...field, label, placeholder, hidden }}
|
|
||||||
readOnly={readOnly}
|
|
||||||
key={index}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const routerQuerySchema = z
|
|
||||||
.object({
|
|
||||||
timeFormat: z.nativeEnum(TimeFormat),
|
|
||||||
rescheduleUid: z.string().optional(),
|
|
||||||
date: z
|
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.transform((date) => {
|
|
||||||
if (date === undefined) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return date;
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
.passthrough();
|
|
||||||
|
|
||||||
const BookingPage = ({
|
|
||||||
eventType,
|
|
||||||
booking,
|
|
||||||
currentSlotBooking,
|
|
||||||
profile,
|
|
||||||
isDynamicGroupBooking,
|
|
||||||
recurringEventCount,
|
|
||||||
hasHashedBookingLink,
|
|
||||||
hashedLink,
|
|
||||||
...restProps
|
|
||||||
}: BookingPageProps) => {
|
|
||||||
const removeSelectedSlotMarkMutation = trpc.viewer.public.slots.removeSelectedSlotMark.useMutation();
|
|
||||||
const reserveSlotMutation = trpc.viewer.public.slots.reserveSlot.useMutation();
|
|
||||||
const { t, i18n } = useLocale();
|
|
||||||
const { duration: queryDuration } = useRouterQuery("duration");
|
|
||||||
const { date: queryDate } = useRouterQuery("date");
|
|
||||||
const isEmbed = useIsEmbed(restProps.isEmbed);
|
|
||||||
const embedUiConfig = useEmbedUiConfig();
|
|
||||||
const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig("align") !== "left";
|
|
||||||
const shouldAlignCentrally = !isEmbed || shouldAlignCentrallyInEmbed;
|
|
||||||
const router = useRouter();
|
|
||||||
const { data: session } = useSession();
|
|
||||||
const isBackgroundTransparent = useIsBackgroundTransparent();
|
|
||||||
const telemetry = useTelemetry();
|
|
||||||
|
|
||||||
const { timezone } = useTimePreferences();
|
|
||||||
|
|
||||||
const reserveSlot = () => {
|
|
||||||
if (queryDuration) {
|
|
||||||
reserveSlotMutation.mutate({
|
|
||||||
eventTypeId: eventType.id,
|
|
||||||
slotUtcStartDate: dayjs(queryDate).utc().format(),
|
|
||||||
slotUtcEndDate: dayjs(queryDate).utc().add(parseInt(queryDuration), "minutes").format(),
|
|
||||||
bookingUid: currentSlotBooking?.uid,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Define duration now that we support multiple duration eventTypes
|
|
||||||
let duration = eventType.length;
|
|
||||||
if (
|
|
||||||
queryDuration &&
|
|
||||||
!isNaN(Number(queryDuration)) &&
|
|
||||||
eventType.metadata?.multipleDuration &&
|
|
||||||
eventType.metadata?.multipleDuration.includes(Number(queryDuration))
|
|
||||||
) {
|
|
||||||
duration = Number(queryDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
/* if (top !== window) {
|
|
||||||
//page_view will be collected automatically by _middleware.ts
|
|
||||||
telemetry.event(
|
|
||||||
telemetryEventTypes.embedView,
|
|
||||||
collectPageParameters("/book", { isTeamBooking: document.URL.includes("team/") })
|
|
||||||
);
|
|
||||||
} */
|
|
||||||
reserveSlot();
|
|
||||||
const interval = setInterval(reserveSlot, parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000);
|
|
||||||
return () => {
|
|
||||||
clearInterval(interval);
|
|
||||||
removeSelectedSlotMarkMutation.mutate();
|
|
||||||
};
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const mutation = useMutation(createBooking, {
|
|
||||||
onSuccess: async (responseData) => {
|
|
||||||
const { uid } = responseData;
|
|
||||||
|
|
||||||
if ("paymentUid" in responseData && !!responseData.paymentUid) {
|
|
||||||
return await router.push(
|
|
||||||
createPaymentLink({
|
|
||||||
paymentUid: responseData.paymentUid,
|
|
||||||
date,
|
|
||||||
name: bookingForm.getValues("responses.name"),
|
|
||||||
email: bookingForm.getValues("responses.email"),
|
|
||||||
absolute: false,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = {
|
|
||||||
isSuccessBookingPage: true,
|
|
||||||
email: bookingForm.getValues("responses.email"),
|
|
||||||
eventTypeSlug: eventType.slug,
|
|
||||||
seatReferenceUid: "seatReferenceUid" in responseData ? responseData.seatReferenceUid : null,
|
|
||||||
...(rescheduleUid && booking?.startTime && { formerTime: booking.startTime.toString() }),
|
|
||||||
};
|
|
||||||
|
|
||||||
return bookingSuccessRedirect({
|
|
||||||
router,
|
|
||||||
successRedirectUrl: eventType.successRedirectUrl,
|
|
||||||
query,
|
|
||||||
bookingUid: uid,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const recurringMutation = useMutation(createRecurringBooking, {
|
|
||||||
onSuccess: async (responseData = []) => {
|
|
||||||
const { uid } = responseData[0] || {};
|
|
||||||
const query = {
|
|
||||||
isSuccessBookingPage: true,
|
|
||||||
allRemainingBookings: true,
|
|
||||||
email: bookingForm.getValues("responses.email"),
|
|
||||||
eventTypeSlug: eventType.slug,
|
|
||||||
formerTime: booking?.startTime.toString(),
|
|
||||||
};
|
|
||||||
return bookingSuccessRedirect({
|
|
||||||
router,
|
|
||||||
successRedirectUrl: eventType.successRedirectUrl,
|
|
||||||
query,
|
|
||||||
bookingUid: uid,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { timeFormat, rescheduleUid, date },
|
|
||||||
} = useTypedQuery(routerQuerySchema);
|
|
||||||
|
|
||||||
useTheme(profile.theme);
|
|
||||||
useBrandColors({
|
|
||||||
brandColor: profile.brandColor,
|
|
||||||
darkBrandColor: profile.darkBrandColor,
|
|
||||||
});
|
|
||||||
|
|
||||||
const querySchema = getBookingResponsesPartialSchema({
|
|
||||||
eventType: {
|
|
||||||
bookingFields: getBookingFieldsWithSystemFields(eventType),
|
|
||||||
},
|
|
||||||
view: rescheduleUid ? "reschedule" : "booking",
|
|
||||||
});
|
|
||||||
|
|
||||||
const parsedQuery = querySchema.parse({
|
|
||||||
...router.query,
|
|
||||||
// `guest` because we need to support legacy URL with `guest` query param support
|
|
||||||
// `guests` because the `name` of the corresponding bookingField is `guests`
|
|
||||||
guests: router.query.guests || router.query.guest,
|
|
||||||
});
|
|
||||||
|
|
||||||
// it would be nice if Prisma at some point in the future allowed for Json<Location>; as of now this is not the case.
|
|
||||||
const locations: LocationObject[] = useMemo(
|
|
||||||
() => (eventType.locations as LocationObject[]) || [],
|
|
||||||
[eventType.locations]
|
|
||||||
);
|
|
||||||
|
|
||||||
const [isClientTimezoneAvailable, setIsClientTimezoneAvailable] = useState(false);
|
|
||||||
useEffect(() => {
|
|
||||||
// THis is to fix hydration error that comes because of different timezone on server and client
|
|
||||||
setIsClientTimezoneAvailable(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const loggedInIsOwner = eventType?.users[0]?.id === session?.user?.id;
|
|
||||||
|
|
||||||
// There should only exists one default userData variable for primaryAttendee.
|
|
||||||
const defaultUserValues = {
|
|
||||||
email: rescheduleUid ? booking?.attendees[0].email : parsedQuery["email"],
|
|
||||||
name: rescheduleUid ? booking?.attendees[0].name : parsedQuery["name"],
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultValues = () => {
|
|
||||||
if (!rescheduleUid) {
|
|
||||||
const defaults = {
|
|
||||||
responses: {} as Partial<z.infer<typeof bookingFormSchema>["responses"]>,
|
|
||||||
};
|
|
||||||
|
|
||||||
const responses = eventType.bookingFields.reduce((responses, field) => {
|
|
||||||
return {
|
|
||||||
...responses,
|
|
||||||
[field.name]: parsedQuery[field.name],
|
|
||||||
};
|
|
||||||
}, {});
|
|
||||||
defaults.responses = {
|
|
||||||
...responses,
|
|
||||||
name: defaultUserValues.name || (!loggedInIsOwner && session?.user?.name) || "",
|
|
||||||
email: defaultUserValues.email || (!loggedInIsOwner && session?.user?.email) || "",
|
|
||||||
};
|
|
||||||
|
|
||||||
return defaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!booking || !booking.attendees.length) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
const primaryAttendee = booking.attendees[0];
|
|
||||||
if (!primaryAttendee) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaults = {
|
|
||||||
responses: {} as Partial<z.infer<typeof bookingFormSchema>["responses"]>,
|
|
||||||
};
|
|
||||||
|
|
||||||
const responses = eventType.bookingFields.reduce((responses, field) => {
|
|
||||||
return {
|
|
||||||
...responses,
|
|
||||||
[field.name]: booking.responses[field.name],
|
|
||||||
};
|
|
||||||
}, {});
|
|
||||||
defaults.responses = {
|
|
||||||
...responses,
|
|
||||||
name: defaultUserValues.name || (!loggedInIsOwner && session?.user?.name) || "",
|
|
||||||
email: defaultUserValues.email || (!loggedInIsOwner && session?.user?.email) || "",
|
|
||||||
};
|
|
||||||
return defaults;
|
|
||||||
};
|
|
||||||
|
|
||||||
const bookingFormSchema = z
|
|
||||||
.object({
|
|
||||||
responses: getBookingResponsesSchema({
|
|
||||||
eventType: { bookingFields: getBookingFieldsWithSystemFields(eventType) },
|
|
||||||
view: rescheduleUid ? "reschedule" : "booking",
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
.passthrough();
|
|
||||||
|
|
||||||
type BookingFormValues = {
|
|
||||||
locationType?: EventLocationType["type"];
|
|
||||||
responses: z.infer<typeof bookingFormSchema>["responses"];
|
|
||||||
};
|
|
||||||
|
|
||||||
const bookingForm = useForm<BookingFormValues>({
|
|
||||||
defaultValues: defaultValues(),
|
|
||||||
resolver: zodResolver(bookingFormSchema), // Since this isn't set to strict we only validate the fields in the schema
|
|
||||||
});
|
|
||||||
|
|
||||||
// Calculate the booking date(s)
|
|
||||||
let recurringStrings: string[] = [],
|
|
||||||
recurringDates: Date[] = [];
|
|
||||||
if (eventType.recurringEvent?.freq && recurringEventCount !== null) {
|
|
||||||
[recurringStrings, recurringDates] = parseRecurringDates(
|
|
||||||
{
|
|
||||||
startDate: date,
|
|
||||||
timeZone: timeZone(),
|
|
||||||
recurringEvent: eventType.recurringEvent,
|
|
||||||
recurringCount: parseInt(recurringEventCount.toString()),
|
|
||||||
selectedTimeFormat: timeFormat,
|
|
||||||
},
|
|
||||||
i18n.language
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bookEvent = (bookingValues: BookingFormValues) => {
|
|
||||||
telemetry.event(
|
|
||||||
top !== window ? telemetryEventTypes.embedBookingConfirmed : telemetryEventTypes.bookingConfirmed,
|
|
||||||
{ isTeamBooking: document.URL.includes("team/") }
|
|
||||||
);
|
|
||||||
// "metadata" is a reserved key to allow for connecting external users without relying on the email address.
|
|
||||||
// <...url>&metadata[user_id]=123 will be send as a custom input field as the hidden type.
|
|
||||||
|
|
||||||
// @TODO: move to metadata
|
|
||||||
const metadata = Object.keys(router.query)
|
|
||||||
.filter((key) => key.startsWith("metadata"))
|
|
||||||
.reduce(
|
|
||||||
(metadata, key) => ({
|
|
||||||
...metadata,
|
|
||||||
[key.substring("metadata[".length, key.length - 1)]: router.query[key],
|
|
||||||
}),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (recurringDates.length) {
|
|
||||||
// Identify set of bookings to one intance of recurring event to support batch changes
|
|
||||||
const recurringEventId = uuidv4();
|
|
||||||
const recurringBookings = recurringDates.map((recurringDate) => ({
|
|
||||||
...bookingValues,
|
|
||||||
start: dayjs(recurringDate).utc().format(),
|
|
||||||
end: dayjs(recurringDate).utc().add(duration, "minute").format(),
|
|
||||||
eventTypeId: eventType.id,
|
|
||||||
eventTypeSlug: eventType.slug,
|
|
||||||
recurringEventId,
|
|
||||||
// Added to track down the number of actual occurrences selected by the user
|
|
||||||
recurringCount: recurringDates.length,
|
|
||||||
timeZone: timeZone(),
|
|
||||||
language: i18n.language,
|
|
||||||
rescheduleUid,
|
|
||||||
user: router.query.user,
|
|
||||||
metadata,
|
|
||||||
hasHashedBookingLink,
|
|
||||||
hashedLink,
|
|
||||||
}));
|
|
||||||
recurringMutation.mutate(recurringBookings);
|
|
||||||
} else {
|
|
||||||
mutation.mutate({
|
|
||||||
...bookingValues,
|
|
||||||
start: dayjs(date).utc().format(),
|
|
||||||
end: dayjs(date).utc().add(duration, "minute").format(),
|
|
||||||
eventTypeId: eventType.id,
|
|
||||||
eventTypeSlug: eventType.slug,
|
|
||||||
timeZone: timeZone(),
|
|
||||||
language: i18n.language,
|
|
||||||
rescheduleUid,
|
|
||||||
bookingUid: (router.query.bookingUid as string) || booking?.uid,
|
|
||||||
user: router.query.user,
|
|
||||||
metadata,
|
|
||||||
hasHashedBookingLink,
|
|
||||||
hashedLink,
|
|
||||||
seatReferenceUid: router.query.seatReferenceUid as string,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const showEventTypeDetails = (isEmbed && !embedUiConfig.hideEventTypeDetails) || !isEmbed;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Head>
|
|
||||||
<title>
|
|
||||||
{rescheduleUid
|
|
||||||
? t("booking_reschedule_confirmation", {
|
|
||||||
eventTypeTitle: eventType.title,
|
|
||||||
profileName: profile.name,
|
|
||||||
})
|
|
||||||
: t("booking_confirmation", {
|
|
||||||
eventTypeTitle: eventType.title,
|
|
||||||
profileName: profile.name,
|
|
||||||
})}{" "}
|
|
||||||
| {APP_NAME}
|
|
||||||
</title>
|
|
||||||
<link rel="icon" href="/favico.ico" />
|
|
||||||
</Head>
|
|
||||||
<BookingPageTagManager eventType={eventType} />
|
|
||||||
<main
|
|
||||||
className={classNames(
|
|
||||||
shouldAlignCentrally ? "mx-auto" : "",
|
|
||||||
isEmbed ? "" : "sm:my-24",
|
|
||||||
"my-0 max-w-3xl"
|
|
||||||
)}>
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
"main",
|
|
||||||
isBackgroundTransparent ? "" : "bg-default dark:bg-muted",
|
|
||||||
"border-booker sm:border-booker-width rounded-md"
|
|
||||||
)}>
|
|
||||||
<div className="sm:flex">
|
|
||||||
{showEventTypeDetails && (
|
|
||||||
<div className="sm:border-subtle text-default flex flex-col px-6 pb-0 pt-6 sm:w-1/2 sm:border-r sm:pb-6">
|
|
||||||
<BookingDescription isBookingPage profile={profile} eventType={eventType}>
|
|
||||||
<BookingDescriptionPayment eventType={eventType} t={t} i18n={i18n} />
|
|
||||||
{!rescheduleUid && eventType.recurringEvent?.freq && recurringEventCount && (
|
|
||||||
<div className="text-default items-start text-sm font-medium">
|
|
||||||
<RefreshCw className="ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]" />
|
|
||||||
<p className="-ml-2 inline-block items-center px-2">
|
|
||||||
{getEveryFreqFor({
|
|
||||||
t,
|
|
||||||
recurringEvent: eventType.recurringEvent,
|
|
||||||
recurringCount: recurringEventCount,
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="text-bookinghighlight flex items-start text-sm">
|
|
||||||
<Calendar className="ml-[2px] mt-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]" />
|
|
||||||
<div className="text-sm font-medium">
|
|
||||||
{isClientTimezoneAvailable &&
|
|
||||||
(rescheduleUid || !eventType.recurringEvent?.freq) &&
|
|
||||||
`${parseDate(date, i18n.language, { selectedTimeFormat: timeFormat })}`}
|
|
||||||
{isClientTimezoneAvailable &&
|
|
||||||
!rescheduleUid &&
|
|
||||||
eventType.recurringEvent?.freq &&
|
|
||||||
recurringStrings.slice(0, 5).map((timeFormatted, key) => {
|
|
||||||
return <p key={key}>{timeFormatted}</p>;
|
|
||||||
})}
|
|
||||||
{!rescheduleUid && eventType?.recurringEvent?.freq && recurringStrings.length > 5 && (
|
|
||||||
<div className="flex">
|
|
||||||
<Tooltip
|
|
||||||
content={recurringStrings.slice(5).map((timeFormatted, key) => (
|
|
||||||
<p key={key}>{timeFormatted}</p>
|
|
||||||
))}>
|
|
||||||
<p className=" text-sm">
|
|
||||||
+ {t("plus_more", { count: recurringStrings.length - 5 })}
|
|
||||||
</p>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{booking?.startTime && rescheduleUid && (
|
|
||||||
<div>
|
|
||||||
<p className="mb-2 mt-8 text-sm " data-testid="former_time_p">
|
|
||||||
{t("former_time")}
|
|
||||||
</p>
|
|
||||||
<p className="line-through ">
|
|
||||||
<Calendar className="-mt-1 ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]" />
|
|
||||||
{isClientTimezoneAvailable &&
|
|
||||||
typeof booking.startTime === "string" &&
|
|
||||||
parseDateTimeWithTimeZone(booking.startTime, i18n.language, timezone, {
|
|
||||||
selectedTimeFormat: timeFormat,
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!!eventType.seatsPerTimeSlot && (
|
|
||||||
<div className="text-bookinghighlight flex items-start text-sm">
|
|
||||||
<User
|
|
||||||
className={`ml-[2px] mt-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] ${
|
|
||||||
currentSlotBooking &&
|
|
||||||
currentSlotBooking.attendees.length / eventType.seatsPerTimeSlot >= 0.5
|
|
||||||
? "text-rose-600"
|
|
||||||
: currentSlotBooking &&
|
|
||||||
currentSlotBooking.attendees.length / eventType.seatsPerTimeSlot >= 0.33
|
|
||||||
? "text-yellow-500"
|
|
||||||
: "text-bookinghighlight"
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
<p
|
|
||||||
className={`${
|
|
||||||
currentSlotBooking &&
|
|
||||||
currentSlotBooking.attendees.length / eventType.seatsPerTimeSlot >= 0.5
|
|
||||||
? "text-rose-600"
|
|
||||||
: currentSlotBooking &&
|
|
||||||
currentSlotBooking.attendees.length / eventType.seatsPerTimeSlot >= 0.33
|
|
||||||
? "text-yellow-500"
|
|
||||||
: "text-bookinghighlight"
|
|
||||||
} mb-2 font-medium`}>
|
|
||||||
{currentSlotBooking
|
|
||||||
? eventType.seatsPerTimeSlot - currentSlotBooking.attendees.length
|
|
||||||
: eventType.seatsPerTimeSlot}{" "}
|
|
||||||
/ {eventType.seatsPerTimeSlot}{" "}
|
|
||||||
{t("seats_available", {
|
|
||||||
count: currentSlotBooking
|
|
||||||
? eventType.seatsPerTimeSlot - currentSlotBooking.attendees.length
|
|
||||||
: eventType.seatsPerTimeSlot,
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</BookingDescription>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className={classNames("p-6", showEventTypeDetails ? "sm:w-1/2" : "w-full")}>
|
|
||||||
<Form form={bookingForm} noValidate handleSubmit={bookEvent}>
|
|
||||||
<BookingFields
|
|
||||||
isDynamicGroupBooking={isDynamicGroupBooking}
|
|
||||||
fields={eventType.bookingFields}
|
|
||||||
locations={locations}
|
|
||||||
rescheduleUid={rescheduleUid}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
"flex justify-end space-x-2 rtl:space-x-reverse",
|
|
||||||
// HACK: If the last field is guests, we need to move Cancel, Submit buttons up because "Add Guests" being present on the left and the buttons on the right, spacing is not required
|
|
||||||
eventType.bookingFields[eventType.bookingFields.length - 1].name ===
|
|
||||||
SystemField.Enum.guests
|
|
||||||
? "-mt-4"
|
|
||||||
: ""
|
|
||||||
)}>
|
|
||||||
<Button color="minimal" type="button" onClick={() => router.back()}>
|
|
||||||
{t("cancel")}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
data-testid={rescheduleUid ? "confirm-reschedule-button" : "confirm-book-button"}
|
|
||||||
loading={mutation.isLoading || recurringMutation.isLoading}>
|
|
||||||
{rescheduleUid ? t("reschedule") : t("confirm")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</Form>
|
|
||||||
{mutation.isError || recurringMutation.isError ? (
|
|
||||||
<ErrorMessage error={mutation.error || recurringMutation.error} />
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
<Toaster position="bottom-right" />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default BookingPage;
|
|
||||||
|
|
||||||
function ErrorMessage({ error }: { error: unknown }) {
|
|
||||||
const { t } = useLocale();
|
|
||||||
const { query: { rescheduleUid } = {} } = useRouter();
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div data-testid="booking-fail" className="mt-2 border-l-4 border-blue-400 bg-blue-50 p-4">
|
|
||||||
<div className="flex">
|
|
||||||
<div className="flex-shrink-0">
|
|
||||||
<AlertTriangle className="h-5 w-5 text-blue-400" aria-hidden="true" />
|
|
||||||
</div>
|
|
||||||
<div className="ms-3">
|
|
||||||
<p className="text-sm text-blue-700">
|
|
||||||
{rescheduleUid ? t("reschedule_fail") : t("booking_fail")}{" "}
|
|
||||||
{error instanceof HttpError || error instanceof Error ? (
|
|
||||||
<>
|
|
||||||
{t("can_you_try_again")}{" "}
|
|
||||||
<span className="cursor-pointer underline" onClick={() => router.back()}>
|
|
||||||
{t("go_back")}
|
|
||||||
</span>
|
|
||||||
.
|
|
||||||
</> /* t(error.message) */
|
|
||||||
) : (
|
|
||||||
"Unknown error"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -34,12 +34,12 @@ interface ISetLocationDialog {
|
|||||||
saveLocation: (newLocationType: EventLocationType["type"], details: { [key: string]: string }) => void;
|
saveLocation: (newLocationType: EventLocationType["type"], details: { [key: string]: string }) => void;
|
||||||
selection?: LocationOption;
|
selection?: LocationOption;
|
||||||
booking?: BookingItem;
|
booking?: BookingItem;
|
||||||
isTeamEvent?: boolean;
|
|
||||||
defaultValues?: LocationObject[];
|
defaultValues?: LocationObject[];
|
||||||
setShowLocationModal: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowLocationModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
isOpenDialog: boolean;
|
isOpenDialog: boolean;
|
||||||
setSelectedLocation?: (param: LocationOption | undefined) => void;
|
setSelectedLocation?: (param: LocationOption | undefined) => void;
|
||||||
setEditingLocationType?: (param: string) => void;
|
setEditingLocationType?: (param: string) => void;
|
||||||
|
teamId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LocationInput = (props: {
|
const LocationInput = (props: {
|
||||||
@@ -79,15 +79,15 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
saveLocation,
|
saveLocation,
|
||||||
selection,
|
selection,
|
||||||
booking,
|
booking,
|
||||||
isTeamEvent,
|
|
||||||
setShowLocationModal,
|
setShowLocationModal,
|
||||||
isOpenDialog,
|
isOpenDialog,
|
||||||
defaultValues,
|
defaultValues,
|
||||||
setSelectedLocation,
|
setSelectedLocation,
|
||||||
setEditingLocationType,
|
setEditingLocationType,
|
||||||
|
teamId,
|
||||||
} = props;
|
} = props;
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const locationsQuery = trpc.viewer.locationOptions.useQuery();
|
const locationsQuery = trpc.viewer.locationOptions.useQuery({ teamId });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selection) {
|
if (selection) {
|
||||||
@@ -103,6 +103,7 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
locationType: z.string(),
|
locationType: z.string(),
|
||||||
phone: z.string().optional().nullable(),
|
phone: z.string().optional().nullable(),
|
||||||
locationAddress: z.string().optional(),
|
locationAddress: z.string().optional(),
|
||||||
|
credentialId: z.number().optional(),
|
||||||
locationLink: z
|
locationLink: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
@@ -173,8 +174,6 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(defaultLocation);
|
|
||||||
|
|
||||||
const LocationOptions = (() => {
|
const LocationOptions = (() => {
|
||||||
if (eventLocationType && eventLocationType.organizerInputType && LocationInput) {
|
if (eventLocationType && eventLocationType.organizerInputType && LocationInput) {
|
||||||
if (!eventLocationType.variable) {
|
if (!eventLocationType.variable) {
|
||||||
@@ -298,6 +297,9 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (values.credentialId) {
|
||||||
|
details = { ...details, credentialId: values.credentialId };
|
||||||
|
}
|
||||||
saveLocation(newLocation, details);
|
saveLocation(newLocation, details);
|
||||||
setShowLocationModal(false);
|
setShowLocationModal(false);
|
||||||
setSelectedLocation?.(undefined);
|
setSelectedLocation?.(undefined);
|
||||||
@@ -313,7 +315,7 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
success={({ data }) => {
|
success={({ data }) => {
|
||||||
if (!data.length) return null;
|
if (!data.length) return null;
|
||||||
const locationOptions = [...data].map((option) => {
|
const locationOptions = [...data].map((option) => {
|
||||||
if (isTeamEvent) {
|
if (teamId) {
|
||||||
// Let host's Default conferencing App option show for Team Event
|
// Let host's Default conferencing App option show for Team Event
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { Controller, useFormContext } from "react-hook-form";
|
import { Controller, useFormContext } from "react-hook-form";
|
||||||
import short from "short-uuid";
|
import short from "short-uuid";
|
||||||
import { v5 as uuidv5 } from "uuid";
|
import { v5 as uuidv5 } from "uuid";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { EventNameObjectType } from "@calcom/core/event";
|
import type { EventNameObjectType } from "@calcom/core/event";
|
||||||
import { getEventName } from "@calcom/core/event";
|
import { getEventName } from "@calcom/core/event";
|
||||||
@@ -16,6 +17,7 @@ import {
|
|||||||
allowDisablingHostConfirmationEmails,
|
allowDisablingHostConfirmationEmails,
|
||||||
} from "@calcom/features/ee/workflows/lib/allowDisablingStandardEmails";
|
} from "@calcom/features/ee/workflows/lib/allowDisablingStandardEmails";
|
||||||
import { FormBuilder } from "@calcom/features/form-builder/FormBuilder";
|
import { FormBuilder } from "@calcom/features/form-builder/FormBuilder";
|
||||||
|
import { EditableSchema } from "@calcom/features/form-builder/FormBuilderFieldsSchema"
|
||||||
import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
|
import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { APP_NAME, CAL_URL } from "@calcom/lib/constants";
|
import { APP_NAME, CAL_URL } from "@calcom/lib/constants";
|
||||||
@@ -85,6 +87,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
|
|||||||
return {
|
return {
|
||||||
...field,
|
...field,
|
||||||
hidden: !enabled,
|
hidden: !enabled,
|
||||||
|
editable: (!enabled ? "system-but-hidden" : "system-but-optional") as z.infer<typeof EditableSchema>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return field;
|
return field;
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ export type EventType = Pick<EventTypeSetupProps, "eventType">["eventType"] &
|
|||||||
|
|
||||||
export const EventAppsTab = ({ eventType }: { eventType: EventType }) => {
|
export const EventAppsTab = ({ eventType }: { eventType: EventType }) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const { data: eventTypeApps, isLoading } = trpc.viewer.apps.useQuery({
|
const { data: eventTypeApps, isLoading } = trpc.viewer.integrations.useQuery({
|
||||||
extendsFeature: "EventType",
|
extendsFeature: "EventType",
|
||||||
|
teamId: eventType.team?.id || eventType.parent?.teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const methods = useFormContext<FormValues>();
|
const methods = useFormContext<FormValues>();
|
||||||
const installedApps = eventTypeApps?.filter((app) => app.credentials.length);
|
const installedApps =
|
||||||
const notInstalledApps = eventTypeApps?.filter((app) => !app.credentials.length);
|
eventTypeApps?.items.filter((app) => app.userCredentialIds.length || app.teams.length) || [];
|
||||||
|
const notInstalledApps =
|
||||||
|
eventTypeApps?.items.filter((app) => !app.userCredentialIds.length && !app.teams.length) || [];
|
||||||
const allAppsData = methods.watch("metadata")?.apps || {};
|
const allAppsData = methods.watch("metadata")?.apps || {};
|
||||||
|
|
||||||
const setAllAppsData = (_allAppsData: typeof allAppsData) => {
|
const setAllAppsData = (_allAppsData: typeof allAppsData) => {
|
||||||
@@ -62,11 +66,54 @@ export const EventAppsTab = ({ eventType }: { eventType: EventType }) => {
|
|||||||
t("locked_fields_member_description")
|
t("locked_fields_member_description")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const appsWithTeamCredentials = eventTypeApps?.items.filter((app) => app.teams.length) || [];
|
||||||
|
const cardsForAppsWithTeams = appsWithTeamCredentials.map((app) => {
|
||||||
|
const appCards = [];
|
||||||
|
|
||||||
|
if (app.userCredentialIds.length) {
|
||||||
|
appCards.push(
|
||||||
|
<EventTypeAppCard
|
||||||
|
getAppData={getAppDataGetter(app.slug as EventTypeAppsList)}
|
||||||
|
setAppData={getAppDataSetter(app.slug as EventTypeAppsList)}
|
||||||
|
key={app.slug}
|
||||||
|
app={app}
|
||||||
|
eventType={eventType}
|
||||||
|
{...shouldLockDisableProps("apps")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const team of app.teams) {
|
||||||
|
if (team) {
|
||||||
|
appCards.push(
|
||||||
|
<EventTypeAppCard
|
||||||
|
getAppData={getAppDataGetter(app.slug as EventTypeAppsList)}
|
||||||
|
setAppData={getAppDataSetter(app.slug as EventTypeAppsList)}
|
||||||
|
key={app.slug + team?.credentialId}
|
||||||
|
app={{
|
||||||
|
...app,
|
||||||
|
// credentialIds: team?.credentialId ? [team.credentialId] : [],
|
||||||
|
credentialOwner: {
|
||||||
|
name: team.name,
|
||||||
|
avatar: team.logo,
|
||||||
|
teamId: team.teamId,
|
||||||
|
credentialId: team.credentialId,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
eventType={eventType}
|
||||||
|
{...shouldLockDisableProps("apps")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return appCards;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<div className="before:border-0">
|
<div className="before:border-0">
|
||||||
{!installedApps?.length && isManagedEventType && (
|
{isManagedEventType && (
|
||||||
<Alert
|
<Alert
|
||||||
severity="neutral"
|
severity="neutral"
|
||||||
className="mb-2"
|
className="mb-2"
|
||||||
@@ -92,15 +139,20 @@ export const EventAppsTab = ({ eventType }: { eventType: EventType }) => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{installedApps?.map((app) => (
|
{cardsForAppsWithTeams.map((apps) => apps.map((cards) => cards))}
|
||||||
<EventTypeAppCard
|
{installedApps.map((app) => {
|
||||||
getAppData={getAppDataGetter(app.slug as EventTypeAppsList)}
|
if (!app.teams.length)
|
||||||
setAppData={getAppDataSetter(app.slug as EventTypeAppsList)}
|
return (
|
||||||
key={app.slug}
|
<EventTypeAppCard
|
||||||
app={app}
|
getAppData={getAppDataGetter(app.slug as EventTypeAppsList)}
|
||||||
eventType={eventType}
|
setAppData={getAppDataSetter(app.slug as EventTypeAppsList)}
|
||||||
/>
|
key={app.slug}
|
||||||
))}
|
app={app}
|
||||||
|
eventType={eventType}
|
||||||
|
{...shouldLockDisableProps("apps")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{!shouldLockDisableProps("apps").disabled && (
|
{!shouldLockDisableProps("apps").disabled && (
|
||||||
|
|||||||
@@ -530,7 +530,6 @@ export const EventSetupTab = (
|
|||||||
|
|
||||||
{/* We portal this modal so we can submit the form inside. Otherwise we get issues submitting two forms at once */}
|
{/* We portal this modal so we can submit the form inside. Otherwise we get issues submitting two forms at once */}
|
||||||
<EditLocationDialog
|
<EditLocationDialog
|
||||||
isTeamEvent={!!team}
|
|
||||||
isOpenDialog={showLocationModal}
|
isOpenDialog={showLocationModal}
|
||||||
setShowLocationModal={setShowLocationModal}
|
setShowLocationModal={setShowLocationModal}
|
||||||
saveLocation={saveLocation}
|
saveLocation={saveLocation}
|
||||||
@@ -553,6 +552,7 @@ export const EventSetupTab = (
|
|||||||
}
|
}
|
||||||
setSelectedLocation={setSelectedLocation}
|
setSelectedLocation={setSelectedLocation}
|
||||||
setEditingLocationType={setEditingLocationType}
|
setEditingLocationType={setEditingLocationType}
|
||||||
|
teamId={eventType.team?.id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { useMemo, useState, Suspense } from "react";
|
|||||||
import type { UseFormReturn } from "react-hook-form";
|
import type { UseFormReturn } from "react-hook-form";
|
||||||
|
|
||||||
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
|
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
|
||||||
|
import { useOrgBrandingValues } from "@calcom/features/ee/organizations/hooks";
|
||||||
import Shell from "@calcom/features/shell/Shell";
|
import Shell from "@calcom/features/shell/Shell";
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { CAL_URL } from "@calcom/lib/constants";
|
import { CAL_URL } from "@calcom/lib/constants";
|
||||||
@@ -210,7 +211,7 @@ function EventTypeSingleLayout({
|
|||||||
}
|
}
|
||||||
if (isManagedEventType || isChildrenManagedEventType) {
|
if (isManagedEventType || isChildrenManagedEventType) {
|
||||||
// Removing apps and workflows for manageg event types by admins v1
|
// Removing apps and workflows for manageg event types by admins v1
|
||||||
navigation.splice(-2, 1);
|
navigation.splice(0, 1);
|
||||||
} else {
|
} else {
|
||||||
navigation.push({
|
navigation.push({
|
||||||
name: "webhooks",
|
name: "webhooks",
|
||||||
@@ -233,9 +234,11 @@ function EventTypeSingleLayout({
|
|||||||
formMethods,
|
formMethods,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const permalink = `${CAL_URL}/${team ? `team/${team.slug}` : eventType.users[0].username}/${
|
const orgBranding = useOrgBrandingValues();
|
||||||
eventType.slug
|
const isOrgEvent = orgBranding?.fullDomain;
|
||||||
}`;
|
const permalink = `${orgBranding?.fullDomain ?? CAL_URL}/${
|
||||||
|
team ? `${!isOrgEvent ? "team/" : ""}${team.slug}` : eventType.users[0].username
|
||||||
|
}/${eventType.slug}`;
|
||||||
|
|
||||||
const embedLink = `${team ? `team/${team.slug}` : eventType.users[0].username}/${eventType.slug}`;
|
const embedLink = `${team ? `team/${team.slug}` : eventType.users[0].username}/${eventType.slug}`;
|
||||||
const isManagedEvent = eventType.schedulingType === SchedulingType.MANAGED ? "_managed" : "";
|
const isManagedEvent = eventType.schedulingType === SchedulingType.MANAGED ? "_managed" : "";
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const AppConnectionItem = (props: IAppConnectionItem) => {
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
disabled={installed}
|
disabled={installed}
|
||||||
type="button"
|
type="button"
|
||||||
|
loading={buttonProps?.isLoading}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
// Save cookie key to return url step
|
// Save cookie key to return url step
|
||||||
document.cookie = `return-to=${window.location.href};path=/;max-age=3600;SameSite=Lax`;
|
document.cookie = `return-to=${window.location.href};path=/;max-age=3600;SameSite=Lax`;
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ const ConnectedCalendars = (props: IConnectCalendarsProps) => {
|
|||||||
const { nextStep } = props;
|
const { nextStep } = props;
|
||||||
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery({ onboarding: true });
|
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery({ onboarding: true });
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const queryIntegrations = trpc.viewer.integrations.useQuery({ variant: "calendar", onlyInstalled: false });
|
const queryIntegrations = trpc.viewer.integrations.useQuery({
|
||||||
|
variant: "calendar",
|
||||||
|
onlyInstalled: false,
|
||||||
|
sortByMostPopular: true,
|
||||||
|
});
|
||||||
|
|
||||||
const firstCalendar = queryConnectedCalendars.data?.connectedCalendars.find(
|
const firstCalendar = queryConnectedCalendars.data?.connectedCalendars.find(
|
||||||
(item) => item.calendars && item.calendars?.length > 0
|
(item) => item.calendars && item.calendars?.length > 0
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
|
|||||||
const { data: queryConnectedVideoApps, isLoading } = trpc.viewer.integrations.useQuery({
|
const { data: queryConnectedVideoApps, isLoading } = trpc.viewer.integrations.useQuery({
|
||||||
variant: "conferencing",
|
variant: "conferencing",
|
||||||
onlyInstalled: false,
|
onlyInstalled: false,
|
||||||
|
sortByMostPopular: true,
|
||||||
});
|
});
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
|
|
||||||
const hasAnyInstalledVideoApps = queryConnectedVideoApps?.items.some(
|
const hasAnyInstalledVideoApps = queryConnectedVideoApps?.items.some(
|
||||||
(item) => item.credentialIds.length > 0
|
(item) => item.userCredentialIds.length > 0
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -38,7 +39,7 @@ const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
|
|||||||
title={item.name}
|
title={item.name}
|
||||||
description={item.description}
|
description={item.description}
|
||||||
logo={item.logo}
|
logo={item.logo}
|
||||||
installed={item.credentialIds.length > 0}
|
installed={item.userCredentialIds.length > 0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -22,15 +22,13 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
|
|||||||
const { nextStep } = props;
|
const { nextStep } = props;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
let queryAvailability;
|
|
||||||
if (defaultScheduleId) {
|
const queryAvailability = trpc.viewer.availability.schedule.get.useQuery(
|
||||||
queryAvailability = trpc.viewer.availability.schedule.get.useQuery(
|
{ scheduleId: defaultScheduleId! },
|
||||||
{ scheduleId: defaultScheduleId },
|
{
|
||||||
{
|
enabled: router.isReady && !!defaultScheduleId,
|
||||||
enabled: router.isReady,
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const availabilityForm = useForm({
|
const availabilityForm = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import type { BaseSyntheticEvent } from "react";
|
import type { BaseSyntheticEvent } from "react";
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
||||||
|
import { useCallbackRef } from "@calcom/lib/hooks/useCallbackRef";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { Button, Dialog, DialogContent, Form } from "@calcom/ui";
|
import { Button, Dialog, DialogContent, Form } from "@calcom/ui";
|
||||||
|
|
||||||
@@ -127,6 +128,17 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleEnableRef = useCallbackRef(handleEnable);
|
||||||
|
|
||||||
|
const totpCode = form.watch("totpCode");
|
||||||
|
|
||||||
|
// auto submit 2FA if all inputs have a value
|
||||||
|
useEffect(() => {
|
||||||
|
if (totpCode?.trim().length === 6) {
|
||||||
|
form.handleSubmit(handleEnableRef.current)();
|
||||||
|
}
|
||||||
|
}, [form, handleEnableRef, totpCode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={true}>
|
<Dialog open={true}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import type { BaseSyntheticEvent } from "react";
|
import type { BaseSyntheticEvent } from "react";
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
||||||
|
import { useCallbackRef } from "@calcom/lib/hooks/useCallbackRef";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { Button, Dialog, DialogContent, DialogFooter, Form, TextField } from "@calcom/ui";
|
import { Button, Dialog, DialogContent, DialogFooter, Form, TextField } from "@calcom/ui";
|
||||||
|
|
||||||
@@ -129,6 +130,17 @@ const EnableTwoFactorModal = ({ onEnable, onCancel, open, onOpenChange }: Enable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleEnableRef = useCallbackRef(handleEnable);
|
||||||
|
|
||||||
|
const totpCode = form.watch("totpCode");
|
||||||
|
|
||||||
|
// auto submit 2FA if all inputs have a value
|
||||||
|
useEffect(() => {
|
||||||
|
if (totpCode?.trim().length === 6) {
|
||||||
|
form.handleSubmit(handleEnableRef.current)();
|
||||||
|
}
|
||||||
|
}, [form, handleEnableRef, totpCode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent title={t("enable_2fa")} description={setupDescriptions[step]} type="creation">
|
<DialogContent title={t("enable_2fa")} description={setupDescriptions[step]} type="creation">
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import * as RadioGroup from "@radix-ui/react-radio-group";
|
import * as RadioGroup from "@radix-ui/react-radio-group";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
|
|
||||||
const ENTERPRISE_BOOKING_FEE = "$99"; // TODO: get this from a new API endpoint
|
|
||||||
|
|
||||||
const ChooseLicense = (
|
const ChooseLicense = (
|
||||||
props: {
|
props: {
|
||||||
value: string;
|
value: string;
|
||||||
@@ -50,23 +49,19 @@ const ChooseLicense = (
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup.Item>
|
</RadioGroup.Item>
|
||||||
<RadioGroup.Item value="EE">
|
<RadioGroup.Item value="EE" disabled>
|
||||||
<div
|
<Link href="https://cal.com/sales" target="_blank">
|
||||||
className={classNames(
|
<div className={classNames("bg-default h-full cursor-pointer space-y-2 rounded-md border p-4")}>
|
||||||
"bg-default cursor-pointer space-y-2 rounded-md border p-4 hover:border-black",
|
<h2 className="font-cal text-emphasis text-xl">{t("custom_plan")}</h2>
|
||||||
value === "EE" && "ring-2 ring-black"
|
<p className="font-medium text-green-800">{t("contact_sales")}</p>
|
||||||
)}>
|
<p className="text-subtle">Build on top of Cal.com</p>
|
||||||
<h2 className="font-cal text-emphasis text-xl">{t("ee_enterprise_license")}</h2>
|
<ul className="text-subtle ml-4 list-disc text-left text-xs">
|
||||||
<p className="font-medium text-green-800">
|
<li>{t("no_need_to_keep_your_code_open_source")}</li>
|
||||||
{t("enterprise_booking_fee", { enterprise_booking_fee: ENTERPRISE_BOOKING_FEE })}
|
<li>{t("repackage_rebrand_resell")}</li>
|
||||||
</p>
|
<li>{t("a_vast_suite_of_enterprise_features")}</li>
|
||||||
<p className="text-subtle">{t("enterprise_license_includes")}</p>
|
</ul>
|
||||||
<ul className="text-subtle ml-4 list-disc text-left text-xs">
|
</div>
|
||||||
<li>{t("no_need_to_keep_your_code_open_source")}</li>
|
</Link>
|
||||||
<li>{t("repackage_rebrand_resell")}</li>
|
|
||||||
<li>{t("a_vast_suite_of_enterprise_features")}</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</RadioGroup.Item>
|
</RadioGroup.Item>
|
||||||
</RadioGroup.Root>
|
</RadioGroup.Root>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { md } from "@calcom/lib/markdownIt";
|
import { md } from "@calcom/lib/markdownIt";
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
||||||
@@ -12,24 +11,20 @@ type TeamType = NonNullable<TeamWithMembers>;
|
|||||||
type MembersType = TeamType["members"];
|
type MembersType = TeamType["members"];
|
||||||
type MemberType = MembersType[number] & { safeBio: string | null };
|
type MemberType = MembersType[number] & { safeBio: string | null };
|
||||||
|
|
||||||
type TeamTypeWithSafeHtml = Omit<TeamType, "members"> & { members: MemberType[] };
|
type TeamTypeWithSafeHtml = Omit<TeamType, "members" | "inviteToken"> & { members: MemberType[] };
|
||||||
|
|
||||||
const Member = ({ member, teamName }: { member: MemberType; teamName: string | null }) => {
|
const Member = ({ member, teamName }: { member: MemberType; teamName: string | null }) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const isBioEmpty = !member.bio || !member.bio.replace("<p><br></p>", "").length;
|
const isBioEmpty = !member.bio || !member.bio.replace("<p><br></p>", "").length;
|
||||||
|
|
||||||
// slug is a route parameter, we don't want to forward it to the next route
|
// We don't want to forward orgSlug and user which are route params to the next route
|
||||||
const { slug: _slug, ...queryParamsToForward } = router.query;
|
const { slug: _slug, orgSlug: _orgSlug, user: _user, ...queryParamsToForward } = router.query;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link key={member.id} href={{ pathname: `/${member.username}`, query: queryParamsToForward }}>
|
<Link key={member.id} href={{ pathname: `/${member.username}`, query: queryParamsToForward }}>
|
||||||
<div className="sm:min-w-80 sm:max-w-80 bg-default hover:bg-muted border-subtle group flex min-h-full flex-col space-y-2 rounded-md border p-4 hover:cursor-pointer">
|
<div className="sm:min-w-80 sm:max-w-80 bg-default hover:bg-muted border-subtle group flex min-h-full flex-col space-y-2 rounded-md border p-4 hover:cursor-pointer">
|
||||||
<Avatar
|
<Avatar size="md" alt={member.name || ""} imageSrc={"/" + member.username + "/avatar.png"} />
|
||||||
size="md"
|
|
||||||
alt={member.name || ""}
|
|
||||||
imageSrc={WEBAPP_URL + "/" + member.username + "/avatar.png"}
|
|
||||||
/>
|
|
||||||
<section className="mt-2 line-clamp-4 w-full space-y-1">
|
<section className="mt-2 line-clamp-4 w-full space-y-1">
|
||||||
<p className="text-default font-medium">{member.name}</p>
|
<p className="text-default font-medium">{member.name}</p>
|
||||||
<div className="text-subtle line-clamp-3 overflow-ellipsis text-sm font-normal">
|
<div className="text-subtle line-clamp-3 overflow-ellipsis text-sm font-normal">
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { debounce, noop } from "lodash";
|
import { debounce, noop } from "lodash";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import type { RefCallback } from "react";
|
import type { RefCallback } from "react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
import { getPremiumPlanPriceValue } from "@calcom/app-store/stripepayment/lib/utils";
|
import { getPremiumPlanPriceValue } from "@calcom/app-store/stripepayment/lib/utils";
|
||||||
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||||
import { fetchUsername } from "@calcom/lib/fetchUsername";
|
import { fetchUsername } from "@calcom/lib/fetchUsername";
|
||||||
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
|
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
@@ -45,6 +47,7 @@ const obtainNewUsernameChangeCondition = ({
|
|||||||
|
|
||||||
const PremiumTextfield = (props: ICustomUsernameProps) => {
|
const PremiumTextfield = (props: ICustomUsernameProps) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
|
const { data: session, update } = useSession();
|
||||||
const {
|
const {
|
||||||
currentUsername,
|
currentUsername,
|
||||||
setCurrentUsername = noop,
|
setCurrentUsername = noop,
|
||||||
@@ -93,6 +96,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
|
|||||||
const updateUsername = trpc.viewer.updateProfile.useMutation({
|
const updateUsername = trpc.viewer.updateProfile.useMutation({
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
onSuccessMutation && (await onSuccessMutation());
|
onSuccessMutation && (await onSuccessMutation());
|
||||||
|
await update();
|
||||||
setOpenDialogSaveUsername(false);
|
setOpenDialogSaveUsername(false);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -116,7 +120,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
|
|||||||
|
|
||||||
const paymentLink = `/api/integrations/stripepayment/subscription?intentUsername=${
|
const paymentLink = `/api/integrations/stripepayment/subscription?intentUsername=${
|
||||||
inputUsernameValue || usernameFromStripe
|
inputUsernameValue || usernameFromStripe
|
||||||
}&action=${usernameChangeCondition}&callbackUrl=${router.asPath}`;
|
}&action=${usernameChangeCondition}&callbackUrl=${WEBAPP_URL}${router.asPath}`;
|
||||||
|
|
||||||
const ActionButtons = () => {
|
const ActionButtons = () => {
|
||||||
if (paymentRequired) {
|
if (paymentRequired) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { debounce, noop } from "lodash";
|
import { debounce, noop } from "lodash";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
import type { RefCallback } from "react";
|
import type { RefCallback } from "react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ interface ICustomUsernameProps {
|
|||||||
|
|
||||||
const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.ComponentProps<typeof TextField>>) => {
|
const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.ComponentProps<typeof TextField>>) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
|
const { data: session, update } = useSession();
|
||||||
const {
|
const {
|
||||||
currentUsername,
|
currentUsername,
|
||||||
setCurrentUsername = noop,
|
setCurrentUsername = noop,
|
||||||
@@ -69,6 +71,7 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.Component
|
|||||||
onSuccessMutation && (await onSuccessMutation());
|
onSuccessMutation && (await onSuccessMutation());
|
||||||
setOpenDialogSaveUsername(false);
|
setOpenDialogSaveUsername(false);
|
||||||
setCurrentUsername(inputUsernameValue);
|
setCurrentUsername(inputUsernameValue);
|
||||||
|
await update();
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
onErrorMutation && onErrorMutation(error);
|
onErrorMutation && onErrorMutation(error);
|
||||||
@@ -135,7 +138,7 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.Component
|
|||||||
/>
|
/>
|
||||||
{currentUsername !== inputUsernameValue && (
|
{currentUsername !== inputUsernameValue && (
|
||||||
<div className="absolute right-[2px] top-6 flex flex-row">
|
<div className="absolute right-[2px] top-6 flex flex-row">
|
||||||
<span className={classNames("mx-2 py-2.5")}>
|
<span className={classNames("mx-2 py-3.5")}>
|
||||||
{usernameIsAvailable ? <Check className="h-4 w-4" /> : <></>}
|
{usernameIsAvailable ? <Check className="h-4 w-4" /> : <></>}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -156,23 +159,23 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.Component
|
|||||||
<DialogContent type="confirmation" Icon={Edit2} title={t("confirm_username_change_dialog_title")}>
|
<DialogContent type="confirmation" Icon={Edit2} title={t("confirm_username_change_dialog_title")}>
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
<div className="mb-4 w-full pt-1">
|
<div className="mb-4 w-full pt-1">
|
||||||
<div className="bg-subtle flex w-full flex-wrap rounded-sm py-3 text-sm">
|
<div className="bg-subtle flex w-full flex-wrap gap-6 rounded-sm px-2 py-3 text-sm">
|
||||||
<div className="flex-1 px-2">
|
<div>
|
||||||
<p className="text-subtle">{t("current_username")}</p>
|
<p className="text-subtle">{t("current_username")}</p>
|
||||||
<p className="text-emphasis mt-1" data-testid="current-username">
|
<p className="text-emphasis mt-1" data-testid="current-username">
|
||||||
{currentUsername}
|
{currentUsername}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="ml-6 flex-1">
|
<div>
|
||||||
<p className="text-subtle" data-testid="new-username">
|
<p className="text-subtle" data-testid="new-username">
|
||||||
{t("new_username")}
|
{t("new_username")}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-emphasis">{inputUsernameValue}</p>
|
<p className="text-emphasis mt-1">{inputUsernameValue}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 flex flex-row-reverse gap-x-2">
|
<div className="ml-4 mt-4 flex flex-row-reverse gap-x-2">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
loading={updateUsernameMutation.isLoading}
|
loading={updateUsernameMutation.isLoading}
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ export default function LocationSelect(props: Props<LocationOption, false, Group
|
|||||||
name="location"
|
name="location"
|
||||||
id="location-select"
|
id="location-select"
|
||||||
components={{
|
components={{
|
||||||
Option: (props) => (
|
Option: (props) => {
|
||||||
<components.Option {...props}>
|
return (
|
||||||
<OptionWithIcon icon={props.data.icon} label={props.data.label} />
|
<components.Option {...props}>
|
||||||
</components.Option>
|
<OptionWithIcon icon={props.data.icon} label={props.data.label} />
|
||||||
),
|
</components.Option>
|
||||||
|
);
|
||||||
|
},
|
||||||
SingleValue: (props) => (
|
SingleValue: (props) => (
|
||||||
<components.SingleValue {...props}>
|
<components.SingleValue {...props}>
|
||||||
<OptionWithIcon icon={props.data.icon} label={props.data.label} />
|
<OptionWithIcon icon={props.data.icon} label={props.data.label} />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { GroupBase, Props, InputProps, SingleValue, MultiValue } from "reac
|
|||||||
import ReactSelect, { components } from "react-select";
|
import ReactSelect, { components } from "react-select";
|
||||||
|
|
||||||
import classNames from "@calcom/lib/classNames";
|
import classNames from "@calcom/lib/classNames";
|
||||||
import useTheme from "@calcom/lib/hooks/useTheme";
|
import { useGetTheme } from "@calcom/lib/hooks/useTheme";
|
||||||
|
|
||||||
export type SelectProps<
|
export type SelectProps<
|
||||||
Option,
|
Option,
|
||||||
@@ -30,7 +30,7 @@ function Select<
|
|||||||
Group extends GroupBase<Option> = GroupBase<Option>
|
Group extends GroupBase<Option> = GroupBase<Option>
|
||||||
>({ className, ...props }: SelectProps<Option, IsMulti, Group>) {
|
>({ className, ...props }: SelectProps<Option, IsMulti, Group>) {
|
||||||
const [mounted, setMounted] = useState<boolean>(false);
|
const [mounted, setMounted] = useState<boolean>(false);
|
||||||
const { resolvedTheme, forcedTheme } = useTheme();
|
const { resolvedTheme, forcedTheme } = useGetTheme();
|
||||||
const hasDarkTheme = !forcedTheme && resolvedTheme === "dark";
|
const hasDarkTheme = !forcedTheme && resolvedTheme === "dark";
|
||||||
const darkThemeColors = {
|
const darkThemeColors = {
|
||||||
/** Dark Theme starts */
|
/** Dark Theme starts */
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ type AppPropsWithChildren = AppProps & {
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getEmbedNamespace = (query: ReturnType<typeof useRouter>["query"]) => {
|
||||||
|
// Mostly embed query param should be available on server. Use that there.
|
||||||
|
// Use the most reliable detection on client
|
||||||
|
return typeof window !== "undefined" ? window.getEmbedNamespace() : (query.embed as string) || null;
|
||||||
|
};
|
||||||
|
|
||||||
const CustomI18nextProvider = (props: AppPropsWithChildren) => {
|
const CustomI18nextProvider = (props: AppPropsWithChildren) => {
|
||||||
/**
|
/**
|
||||||
* i18n should never be clubbed with other queries, so that it's caching can be managed independently.
|
* i18n should never be clubbed with other queries, so that it's caching can be managed independently.
|
||||||
@@ -87,7 +93,7 @@ const CalcomThemeProvider = (props: CalcomThemeProps) => {
|
|||||||
// Use namespace of embed to ensure same namespaced embed are displayed with same theme. This allows different embeds on the same website to be themed differently
|
// Use namespace of embed to ensure same namespaced embed are displayed with same theme. This allows different embeds on the same website to be themed differently
|
||||||
// One such example is our Embeds Demo and Testing page at http://localhost:3100
|
// One such example is our Embeds Demo and Testing page at http://localhost:3100
|
||||||
// Having `getEmbedNamespace` defined on window before react initializes the app, ensures that embedNamespace is available on the first mount and can be used as part of storageKey
|
// Having `getEmbedNamespace` defined on window before react initializes the app, ensures that embedNamespace is available on the first mount and can be used as part of storageKey
|
||||||
const embedNamespace = typeof window !== "undefined" ? window.getEmbedNamespace() : null;
|
const embedNamespace = getEmbedNamespace(router.query);
|
||||||
const isEmbedMode = typeof embedNamespace === "string";
|
const isEmbedMode = typeof embedNamespace === "string";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -158,10 +164,10 @@ function getThemeProviderProps({
|
|||||||
? ThemeSupport.None
|
? ThemeSupport.None
|
||||||
: ThemeSupport.App;
|
: ThemeSupport.App;
|
||||||
|
|
||||||
const isBookingPageThemSupportRequired = themeSupport === ThemeSupport.Booking;
|
const isBookingPageThemeSupportRequired = themeSupport === ThemeSupport.Booking;
|
||||||
const themeBasis = props.themeBasis;
|
const themeBasis = props.themeBasis;
|
||||||
|
|
||||||
if ((isBookingPageThemSupportRequired || isEmbedMode) && !themeBasis) {
|
if ((isBookingPageThemeSupportRequired || isEmbedMode) && !themeBasis) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"`themeBasis` is required for booking page theme support. Not providing it will cause theme flicker."
|
"`themeBasis` is required for booking page theme support. Not providing it will cause theme flicker."
|
||||||
);
|
);
|
||||||
@@ -184,7 +190,7 @@ function getThemeProviderProps({
|
|||||||
`embed-theme-${embedNamespace}${appearanceIdSuffix}${embedExplicitlySetThemeSuffix}`
|
`embed-theme-${embedNamespace}${appearanceIdSuffix}${embedExplicitlySetThemeSuffix}`
|
||||||
: themeSupport === ThemeSupport.App
|
: themeSupport === ThemeSupport.App
|
||||||
? "app-theme"
|
? "app-theme"
|
||||||
: isBookingPageThemSupportRequired
|
: isBookingPageThemeSupportRequired
|
||||||
? `booking-theme${appearanceIdSuffix}`
|
? `booking-theme${appearanceIdSuffix}`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ import { extendEventData, nextCollectBasicSettings } from "@calcom/lib/telemetry
|
|||||||
const middleware: NextMiddleware = async (req) => {
|
const middleware: NextMiddleware = async (req) => {
|
||||||
const url = req.nextUrl;
|
const url = req.nextUrl;
|
||||||
const requestHeaders = new Headers(req.headers);
|
const requestHeaders = new Headers(req.headers);
|
||||||
/**
|
|
||||||
* We are using env variable to toggle new-booker because using flags would be an unnecessary delay for booking pages
|
|
||||||
* Also, we can't easily identify the booker page requests here(to just fetch the flags for those requests)
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (isIpInBanlist(req) && url.pathname !== "/api/nope") {
|
if (isIpInBanlist(req) && url.pathname !== "/api/nope") {
|
||||||
// DDOS Prevention: Immediately end request with no response - Avoids a redirect as well initiated by NextAuth on invalid callback
|
// DDOS Prevention: Immediately end request with no response - Avoids a redirect as well initiated by NextAuth on invalid callback
|
||||||
|
|||||||
+63
-120
@@ -4,8 +4,12 @@ const os = require("os");
|
|||||||
const englishTranslation = require("./public/static/locales/en/common.json");
|
const englishTranslation = require("./public/static/locales/en/common.json");
|
||||||
const { withAxiom } = require("next-axiom");
|
const { withAxiom } = require("next-axiom");
|
||||||
const { i18n } = require("./next-i18next.config");
|
const { i18n } = require("./next-i18next.config");
|
||||||
const { pages } = require("./pages");
|
const {
|
||||||
const { getSubdomainRegExp } = require("./getSubdomainRegExp");
|
orgHostPath,
|
||||||
|
orgUserRoutePath,
|
||||||
|
orgUserTypeRoutePath,
|
||||||
|
orgUserTypeEmbedRoutePath,
|
||||||
|
} = require("./pagesAndRewritePaths");
|
||||||
|
|
||||||
if (!process.env.NEXTAUTH_SECRET) throw new Error("Please set NEXTAUTH_SECRET");
|
if (!process.env.NEXTAUTH_SECRET) throw new Error("Please set NEXTAUTH_SECRET");
|
||||||
if (!process.env.CALENDSO_ENCRYPTION_KEY) throw new Error("Please set CALENDSO_ENCRYPTION_KEY");
|
if (!process.env.CALENDSO_ENCRYPTION_KEY) throw new Error("Please set CALENDSO_ENCRYPTION_KEY");
|
||||||
@@ -81,52 +85,44 @@ if (process.env.ANALYZE === "true") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins.push(withAxiom);
|
plugins.push(withAxiom);
|
||||||
|
|
||||||
// .* matches / as well(Note: *(i.e wildcard) doesn't match / but .*(i.e. RegExp) does)
|
|
||||||
// It would match /free/30min but not /bookings/upcoming because 'bookings' is an item in pages
|
|
||||||
// It would also not match /free/30min/embed because we are ensuring just two slashes
|
|
||||||
// ?!book ensures it doesn't match /free/book page which doesn't have a corresponding new-booker page.
|
|
||||||
// [^/]+ makes the RegExp match the full path, it seems like a partial match doesn't work.
|
|
||||||
// book$ ensures that only /book is excluded from rewrite(which is at the end always) and not /booked
|
|
||||||
|
|
||||||
// Important Note: When modifying these RegExps update apps/web/test/lib/next-config.test.ts as well
|
|
||||||
const userTypeRouteRegExp = `/:user((?!${pages.join("/|")})[^/]*)/:type((?!book$)[^/]+)`;
|
|
||||||
const teamTypeRouteRegExp = "/team/:slug/:type((?!book$)[^/]+)";
|
|
||||||
const privateLinkRouteRegExp = "/d/:link/:slug((?!book$)[^/]+)";
|
|
||||||
const embedUserTypeRouteRegExp = `/:user((?!${pages.join("/|")})[^/]*)/:type/embed`;
|
|
||||||
const embedTeamTypeRouteRegExp = "/team/:slug/:type/embed";
|
|
||||||
const subdomainRegExp = getSubdomainRegExp(process.env.NEXT_PUBLIC_WEBAPP_URL);
|
|
||||||
// Important Note: Do update the RegExp in apps/web/test/lib/next-config.test.ts when changing it.
|
|
||||||
const orgHostRegExp = `^(?<orgSlug>${subdomainRegExp})\\..*`;
|
|
||||||
|
|
||||||
const matcherConfigRootPath = {
|
const matcherConfigRootPath = {
|
||||||
has: [
|
has: [
|
||||||
{
|
{
|
||||||
type: "host",
|
type: "host",
|
||||||
value: orgHostRegExp,
|
value: orgHostPath,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
source: "/",
|
source: "/",
|
||||||
};
|
};
|
||||||
|
|
||||||
const matcherConfigOrgMemberPath = {
|
const matcherConfigUserRoute = {
|
||||||
has: [
|
has: [
|
||||||
{
|
{
|
||||||
type: "host",
|
type: "host",
|
||||||
value: orgHostRegExp,
|
value: orgHostPath,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
source: `/:user((?!${pages.join("|")}|_next|public)[a-zA-Z0-9\-_]+)`,
|
source: orgUserRoutePath,
|
||||||
};
|
};
|
||||||
|
|
||||||
const matcherConfigUserPath = {
|
const matcherConfigUserTypeRoute = {
|
||||||
has: [
|
has: [
|
||||||
{
|
{
|
||||||
type: "host",
|
type: "host",
|
||||||
value: `^(?<orgSlug>${subdomainRegExp}[^.]+)\\..*`,
|
value: orgHostPath,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
source: `/:user((?!${pages.join("|")}|_next|public))/:path*`,
|
source: orgUserTypeRoutePath,
|
||||||
|
};
|
||||||
|
|
||||||
|
const matcherConfigUserTypeEmbedRoute = {
|
||||||
|
has: [
|
||||||
|
{
|
||||||
|
type: "host",
|
||||||
|
value: orgHostPath,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
source: orgUserTypeEmbedRoutePath,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {import("next").NextConfig} */
|
/** @type {import("next").NextConfig} */
|
||||||
@@ -220,6 +216,7 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
const beforeFiles = [
|
const beforeFiles = [
|
||||||
|
// These rewrites are other than booking pages rewrites and so that they aren't redirected to org pages ensure that they happen in beforeFiles
|
||||||
...(process.env.ORGANIZATIONS_ENABLED
|
...(process.env.ORGANIZATIONS_ENABLED
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
@@ -227,12 +224,16 @@ const nextConfig = {
|
|||||||
destination: "/team/:orgSlug",
|
destination: "/team/:orgSlug",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...matcherConfigOrgMemberPath,
|
...matcherConfigUserRoute,
|
||||||
destination: "/org/:orgSlug/:user",
|
destination: "/org/:orgSlug/:user",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...matcherConfigUserPath,
|
...matcherConfigUserTypeRoute,
|
||||||
destination: "/:user/:path*",
|
destination: "/org/:orgSlug/:user/:type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...matcherConfigUserTypeEmbedRoute,
|
||||||
|
destination: "/org/:orgSlug/:user/:type/embed",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
@@ -243,115 +244,48 @@ const nextConfig = {
|
|||||||
source: "/org/:slug",
|
source: "/org/:slug",
|
||||||
destination: "/team/:slug",
|
destination: "/team/:slug",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
source: "/:user/avatar.png",
|
|
||||||
destination: "/api/user/avatar?username=:user",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
source: "/team/:teamname/avatar.png",
|
source: "/team/:teamname/avatar.png",
|
||||||
destination: "/api/user/avatar?teamname=:teamname",
|
destination: "/api/user/avatar?teamname=:teamname",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
source: "/forms/:formQuery*",
|
// When updating this also update pagesAndRewritePaths.js
|
||||||
destination: "/apps/routing-forms/routing-link/:formQuery*",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: "/router",
|
|
||||||
destination: "/apps/routing-forms/router",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: "/success/:path*",
|
|
||||||
has: [
|
|
||||||
{
|
|
||||||
type: "query",
|
|
||||||
key: "uid",
|
|
||||||
value: "(?<uid>.*)",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
destination: "/booking/:uid/:path*",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: "/cancel/:path*",
|
|
||||||
destination: "/booking/:path*",
|
|
||||||
},
|
|
||||||
// Keep cookie based booker enabled just in case we disable new-booker globally
|
|
||||||
...[
|
...[
|
||||||
{
|
{
|
||||||
source: userTypeRouteRegExp,
|
source: "/:user/avatar.png",
|
||||||
destination: "/new-booker/:user/:type",
|
destination: "/api/user/avatar?username=:user",
|
||||||
has: [{ type: "cookie", key: "new-booker-enabled" }],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: teamTypeRouteRegExp,
|
source: "/forms/:formQuery*",
|
||||||
destination: "/new-booker/team/:slug/:type",
|
destination: "/apps/routing-forms/routing-link/:formQuery*",
|
||||||
has: [{ type: "cookie", key: "new-booker-enabled" }],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: privateLinkRouteRegExp,
|
source: "/router",
|
||||||
destination: "/new-booker/d/:link/:slug",
|
destination: "/apps/routing-forms/router",
|
||||||
has: [{ type: "cookie", key: "new-booker-enabled" }],
|
|
||||||
},
|
},
|
||||||
],
|
|
||||||
// Keep cookie based booker enabled to test new-booker embed in production
|
|
||||||
...[
|
|
||||||
{
|
{
|
||||||
source: embedUserTypeRouteRegExp,
|
source: "/success/:path*",
|
||||||
destination: "/new-booker/:user/:type/embed",
|
has: [
|
||||||
has: [{ type: "cookie", key: "new-booker-enabled" }],
|
{
|
||||||
|
type: "query",
|
||||||
|
key: "uid",
|
||||||
|
value: "(?<uid>.*)",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
destination: "/booking/:uid/:path*",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: embedTeamTypeRouteRegExp,
|
source: "/cancel/:path*",
|
||||||
destination: "/new-booker/team/:slug/:type/embed",
|
destination: "/booking/:path*",
|
||||||
has: [{ type: "cookie", key: "new-booker-enabled" }],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
/* TODO: have these files being served from another deployment or CDN {
|
/* TODO: have these files being served from another deployment or CDN {
|
||||||
source: "/embed/embed.js",
|
source: "/embed/embed.js",
|
||||||
destination: process.env.NEXT_PUBLIC_EMBED_LIB_URL?,
|
destination: process.env.NEXT_PUBLIC_EMBED_LIB_URL?,
|
||||||
}, */
|
}, */
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables new booker using cookie. It works even if NEW_BOOKER_ENABLED_FOR_NON_EMBED, NEW_BOOKER_ENABLED_FOR_EMBED are disabled
|
|
||||||
*/
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Enable New Booker for all Embed Requests
|
|
||||||
if (process.env.NEW_BOOKER_ENABLED_FOR_EMBED === "1") {
|
|
||||||
console.log("Enabling New Booker for Embed");
|
|
||||||
afterFiles.push(
|
|
||||||
...[
|
|
||||||
{
|
|
||||||
source: embedUserTypeRouteRegExp,
|
|
||||||
destination: "/new-booker/:user/:type/embed",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: embedTeamTypeRouteRegExp,
|
|
||||||
destination: "/new-booker/team/:slug/:type/embed",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable New Booker for All but embed Requests
|
|
||||||
if (process.env.NEW_BOOKER_ENABLED_FOR_NON_EMBED === "1") {
|
|
||||||
console.log("Enabling New Booker for Non-Embed");
|
|
||||||
afterFiles.push(
|
|
||||||
...[
|
|
||||||
{
|
|
||||||
source: userTypeRouteRegExp,
|
|
||||||
destination: "/new-booker/:user/:type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: teamTypeRouteRegExp,
|
|
||||||
destination: "/new-booker/team/:slug/:type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: privateLinkRouteRegExp,
|
|
||||||
destination: "/new-booker/d/:link/:slug",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
beforeFiles,
|
beforeFiles,
|
||||||
afterFiles,
|
afterFiles,
|
||||||
@@ -401,7 +335,7 @@ const nextConfig = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...matcherConfigOrgMemberPath,
|
...matcherConfigUserRoute,
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
key: "X-Cal-Org-path",
|
key: "X-Cal-Org-path",
|
||||||
@@ -410,11 +344,20 @@ const nextConfig = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...matcherConfigUserPath,
|
...matcherConfigUserTypeRoute,
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
key: "X-Cal-Org-path",
|
key: "X-Cal-Org-path",
|
||||||
value: "/:user/:path",
|
value: "/org/:orgSlug/:user/:type",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...matcherConfigUserTypeEmbedRoute,
|
||||||
|
headers: [
|
||||||
|
{
|
||||||
|
key: "X-Cal-Org-path",
|
||||||
|
value: "/org/:orgSlug/:user/:type/embed",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@calcom/web",
|
"name": "@calcom/web",
|
||||||
"version": "3.0.12",
|
"version": "3.1.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "ANALYZE=true next build",
|
"analyze": "ANALYZE=true next build",
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"@next/bundle-analyzer": "^13.1.6",
|
"@next/bundle-analyzer": "^13.1.6",
|
||||||
"@radix-ui/react-avatar": "^1.0.0",
|
"@radix-ui/react-avatar": "^1.0.0",
|
||||||
"@radix-ui/react-collapsible": "^1.0.0",
|
"@radix-ui/react-collapsible": "^1.0.0",
|
||||||
"@radix-ui/react-dialog": "^1.0.0",
|
"@radix-ui/react-dialog": "^1.0.4",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
||||||
"@radix-ui/react-id": "^1.0.0",
|
"@radix-ui/react-id": "^1.0.0",
|
||||||
"@radix-ui/react-popover": "^1.0.2",
|
"@radix-ui/react-popover": "^1.0.2",
|
||||||
@@ -58,6 +58,7 @@
|
|||||||
"@radix-ui/react-tooltip": "^1.0.0",
|
"@radix-ui/react-tooltip": "^1.0.0",
|
||||||
"@stripe/react-stripe-js": "^1.10.0",
|
"@stripe/react-stripe-js": "^1.10.0",
|
||||||
"@stripe/stripe-js": "^1.35.0",
|
"@stripe/stripe-js": "^1.35.0",
|
||||||
|
"@tanem/react-nprogress": "^5.0.44",
|
||||||
"@tanstack/react-query": "^4.3.9",
|
"@tanstack/react-query": "^4.3.9",
|
||||||
"@tremor/react": "^2.0.0",
|
"@tremor/react": "^2.0.0",
|
||||||
"@types/turndown": "^5.0.1",
|
"@types/turndown": "^5.0.1",
|
||||||
@@ -89,7 +90,7 @@
|
|||||||
"micro": "^10.0.1",
|
"micro": "^10.0.1",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"next": "^13.4.6",
|
"next": "^13.4.6",
|
||||||
"next-auth": "^4.20.1",
|
"next-auth": "^4.22.1",
|
||||||
"next-axiom": "^0.17.0",
|
"next-axiom": "^0.17.0",
|
||||||
"next-collect": "^0.2.1",
|
"next-collect": "^0.2.1",
|
||||||
"next-i18next": "^13.2.2",
|
"next-i18next": "^13.2.2",
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
const glob = require("glob");
|
|
||||||
|
|
||||||
/** Needed to rewrite public booking page, gets all static pages but [user] */
|
|
||||||
const pages = glob
|
|
||||||
.sync("pages/**/[^_]*.{tsx,js,ts}", { cwd: __dirname })
|
|
||||||
.map((filename) =>
|
|
||||||
filename
|
|
||||||
.substr(6)
|
|
||||||
.replace(/(\.tsx|\.js|\.ts)/, "")
|
|
||||||
.replace(/\/.*/, "")
|
|
||||||
)
|
|
||||||
.filter((v, i, self) => self.indexOf(v) === i && !v.startsWith("[user]"));
|
|
||||||
|
|
||||||
exports.pages = pages;
|
|
||||||
+34
-16
@@ -4,10 +4,10 @@ import { useRouter } from "next/router";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { orgDomainConfig, subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
|
import { orgDomainConfig, subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { DOCS_URL, JOIN_SLACK, WEBSITE_URL } from "@calcom/lib/constants";
|
import { DOCS_URL, JOIN_DISCORD, WEBSITE_URL, IS_CALCOM } from "@calcom/lib/constants";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { HeadSeo } from "@calcom/ui";
|
import { HeadSeo } from "@calcom/ui";
|
||||||
import { BookOpen, Check, ChevronRight, FileText, Slack, Shield } from "@calcom/ui/components/icon";
|
import { BookOpen, Check, ChevronRight, FileText, Shield } from "@calcom/ui/components/icon";
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
@@ -58,16 +58,21 @@ export default function Custom404() {
|
|||||||
// Accessing a non-existent team
|
// Accessing a non-existent team
|
||||||
setUsername(splitPath[2]);
|
setUsername(splitPath[2]);
|
||||||
setCurrentPageType(pageType.TEAM);
|
setCurrentPageType(pageType.TEAM);
|
||||||
setUrl(`${WEBSITE_URL}/signup?callbackUrl=settings/teams/new%3Fslug%3D${username.replace("/", "")}`);
|
setUrl(
|
||||||
|
`${WEBSITE_URL}/signup?callbackUrl=settings/teams/new%3Fslug%3D${splitPath[2].replace("/", "")}`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setUsername(routerUsername);
|
setUsername(routerUsername);
|
||||||
setUrl(`${WEBSITE_URL}/signup?username=${username.replace("/", "")}`);
|
setUrl(`${WEBSITE_URL}/signup?username=${routerUsername.replace("/", "")}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setUsername(currentOrgDomain);
|
setUsername(currentOrgDomain);
|
||||||
setCurrentPageType(pageType.ORG);
|
setCurrentPageType(pageType.ORG);
|
||||||
setUrl(
|
setUrl(
|
||||||
`${WEBSITE_URL}/signup?callbackUrl=settings/organizations/new%3Fslug%3D${username.replace("/", "")}`
|
`${WEBSITE_URL}/signup?callbackUrl=settings/organizations/new%3Fslug%3D${currentOrgDomain.replace(
|
||||||
|
"/",
|
||||||
|
""
|
||||||
|
)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@@ -75,7 +80,6 @@ export default function Custom404() {
|
|||||||
const isSuccessPage = router.asPath.startsWith("/booking");
|
const isSuccessPage = router.asPath.startsWith("/booking");
|
||||||
const isSubpage = router.asPath.includes("/", 2) || isSuccessPage;
|
const isSubpage = router.asPath.includes("/", 2) || isSuccessPage;
|
||||||
const isSignup = router.asPath.startsWith("/signup");
|
const isSignup = router.asPath.startsWith("/signup");
|
||||||
const isCalcom = process.env.NEXT_PUBLIC_WEBAPP_URL === "https://app.cal.com";
|
|
||||||
/**
|
/**
|
||||||
* If we're on 404 and the route is insights it means it is disabled
|
* If we're on 404 and the route is insights it means it is disabled
|
||||||
* TODO: Abstract this for all disabled features
|
* TODO: Abstract this for all disabled features
|
||||||
@@ -197,18 +201,25 @@ export default function Custom404() {
|
|||||||
</li>
|
</li>
|
||||||
<li className="px-4 py-2">
|
<li className="px-4 py-2">
|
||||||
<a
|
<a
|
||||||
href={JOIN_SLACK}
|
href={JOIN_DISCORD}
|
||||||
className="relative flex items-start space-x-4 py-6 rtl:space-x-reverse">
|
className="relative flex items-start space-x-4 py-6 rtl:space-x-reverse">
|
||||||
<div className="flex-shrink-0">
|
<div className="flex-shrink-0">
|
||||||
<span className="bg-muted flex h-12 w-12 items-center justify-center rounded-lg">
|
<span className="bg-muted flex h-12 w-12 items-center justify-center rounded-lg">
|
||||||
<Slack strokeWidth="1.5" fill="currentColor" className="h-6 w-6" />
|
<svg
|
||||||
|
className="text-default h-6 w-6"
|
||||||
|
fill="currentColor"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 127.14 96.36">
|
||||||
|
<title>Discord Logo</title>
|
||||||
|
<path d="M107.7 8.07A105.15 105.15 0 0 0 81.47 0a72.06 72.06 0 0 0-3.36 6.83 97.68 97.68 0 0 0-29.11 0A72.37 72.37 0 0 0 45.64 0a105.89 105.89 0 0 0-26.25 8.09C2.79 32.65-1.71 56.6.54 80.21a105.73 105.73 0 0 0 32.17 16.15 77.7 77.7 0 0 0 6.89-11.11 68.42 68.42 0 0 1-10.85-5.18c.91-.66 1.8-1.34 2.66-2a75.57 75.57 0 0 0 64.32 0c.87.71 1.76 1.39 2.66 2a68.68 68.68 0 0 1-10.87 5.19 77 77 0 0 0 6.89 11.1 105.25 105.25 0 0 0 32.19-16.14c2.64-27.38-4.51-51.11-18.9-72.15ZM42.45 65.69C36.18 65.69 31 60 31 53s5-12.74 11.43-12.74S54 46 53.89 53s-5.05 12.69-11.44 12.69Zm42.24 0C78.41 65.69 73.25 60 73.25 53s5-12.74 11.44-12.74S96.23 46 96.12 53s-5.04 12.69-11.43 12.69Z" />
|
||||||
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<h3 className="text-emphasis text-base font-medium">
|
<h3 className="text-emphasis text-base font-medium">
|
||||||
<span className="focus-within:ring-empthasis rounded-sm focus-within:ring-2 focus-within:ring-offset-2">
|
<span className="focus-within:ring-empthasis rounded-sm focus-within:ring-2 focus-within:ring-offset-2">
|
||||||
<span className="absolute inset-0" aria-hidden="true" />
|
<span className="absolute inset-0" aria-hidden="true" />
|
||||||
Slack
|
Discord
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-subtle text-base">{t("join_our_community")}</p>
|
<p className="text-subtle text-base">{t("join_our_community")}</p>
|
||||||
@@ -242,7 +253,7 @@ export default function Custom404() {
|
|||||||
<span className="mt-2 inline-block text-lg ">
|
<span className="mt-2 inline-block text-lg ">
|
||||||
{t("check_spelling_mistakes_or_go_back")}
|
{t("check_spelling_mistakes_or_go_back")}
|
||||||
</span>
|
</span>
|
||||||
) : isCalcom ? (
|
) : IS_CALCOM ? (
|
||||||
<a target="_blank" href={url} className="mt-2 inline-block text-lg" rel="noreferrer">
|
<a target="_blank" href={url} className="mt-2 inline-block text-lg" rel="noreferrer">
|
||||||
{t(`404_the_${currentPageType.toLowerCase()}`)}{" "}
|
{t(`404_the_${currentPageType.toLowerCase()}`)}{" "}
|
||||||
<strong className="text-blue-500">
|
<strong className="text-blue-500">
|
||||||
@@ -260,7 +271,7 @@ export default function Custom404() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-12">
|
<div className="mt-12">
|
||||||
{((!isSubpage && isCalcom) ||
|
{((!isSubpage && IS_CALCOM) ||
|
||||||
currentPageType === pageType.ORG ||
|
currentPageType === pageType.ORG ||
|
||||||
currentPageType === pageType.TEAM) && (
|
currentPageType === pageType.TEAM) && (
|
||||||
<ul role="list" className="my-4">
|
<ul role="list" className="my-4">
|
||||||
@@ -310,7 +321,7 @@ export default function Custom404() {
|
|||||||
.filter((_, idx) => currentPageType === pageType.ORG || idx !== 0)
|
.filter((_, idx) => currentPageType === pageType.ORG || idx !== 0)
|
||||||
.map((link, linkIdx) => (
|
.map((link, linkIdx) => (
|
||||||
<li key={linkIdx} className="px-4 py-2">
|
<li key={linkIdx} className="px-4 py-2">
|
||||||
<Link
|
<a
|
||||||
href={link.href}
|
href={link.href}
|
||||||
className="relative flex items-start space-x-4 py-6 rtl:space-x-reverse">
|
className="relative flex items-start space-x-4 py-6 rtl:space-x-reverse">
|
||||||
<div className="flex-shrink-0">
|
<div className="flex-shrink-0">
|
||||||
@@ -330,23 +341,30 @@ export default function Custom404() {
|
|||||||
<div className="flex-shrink-0 self-center">
|
<div className="flex-shrink-0 self-center">
|
||||||
<ChevronRight className="text-muted h-5 w-5" aria-hidden="true" />
|
<ChevronRight className="text-muted h-5 w-5" aria-hidden="true" />
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li className="px-4 py-2">
|
<li className="px-4 py-2">
|
||||||
<a
|
<a
|
||||||
href={JOIN_SLACK}
|
href={JOIN_DISCORD}
|
||||||
className="relative flex items-start space-x-4 py-6 rtl:space-x-reverse">
|
className="relative flex items-start space-x-4 py-6 rtl:space-x-reverse">
|
||||||
<div className="flex-shrink-0">
|
<div className="flex-shrink-0">
|
||||||
<span className="bg-muted flex h-12 w-12 items-center justify-center rounded-lg">
|
<span className="bg-muted flex h-12 w-12 items-center justify-center rounded-lg">
|
||||||
<Slack strokeWidth="1.5" fill="currentColor" className="h-6 w-6" />
|
<svg
|
||||||
|
className="text-default h-6 w-6"
|
||||||
|
fill="currentColor"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 127.14 96.36">
|
||||||
|
<title>Discord Logo</title>
|
||||||
|
<path d="M107.7 8.07A105.15 105.15 0 0 0 81.47 0a72.06 72.06 0 0 0-3.36 6.83 97.68 97.68 0 0 0-29.11 0A72.37 72.37 0 0 0 45.64 0a105.89 105.89 0 0 0-26.25 8.09C2.79 32.65-1.71 56.6.54 80.21a105.73 105.73 0 0 0 32.17 16.15 77.7 77.7 0 0 0 6.89-11.11 68.42 68.42 0 0 1-10.85-5.18c.91-.66 1.8-1.34 2.66-2a75.57 75.57 0 0 0 64.32 0c.87.71 1.76 1.39 2.66 2a68.68 68.68 0 0 1-10.87 5.19 77 77 0 0 0 6.89 11.1 105.25 105.25 0 0 0 32.19-16.14c2.64-27.38-4.51-51.11-18.9-72.15ZM42.45 65.69C36.18 65.69 31 60 31 53s5-12.74 11.43-12.74S54 46 53.89 53s-5.05 12.69-11.44 12.69Zm42.24 0C78.41 65.69 73.25 60 73.25 53s5-12.74 11.44-12.74S96.23 46 96.12 53s-5.04 12.69-11.43 12.69Z" />
|
||||||
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<h3 className="text-emphasis text-base font-medium">
|
<h3 className="text-emphasis text-base font-medium">
|
||||||
<span className="focus-within:ring-empthasis rounded-sm focus-within:ring-2 focus-within:ring-offset-2">
|
<span className="focus-within:ring-empthasis rounded-sm focus-within:ring-2 focus-within:ring-offset-2">
|
||||||
<span className="absolute inset-0" aria-hidden="true" />
|
<span className="absolute inset-0" aria-hidden="true" />
|
||||||
Slack
|
Discord
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-subtle text-base">{t("join_our_community")}</p>
|
<p className="text-subtle text-base">{t("join_our_community")}</p>
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { EventTypeDescriptionLazy as EventTypeDescription } from "@calcom/features/eventtypes/components";
|
import { EventTypeDescriptionLazy as EventTypeDescription } from "@calcom/features/eventtypes/components";
|
||||||
import EmptyPage from "@calcom/features/eventtypes/components/EmptyPage";
|
import EmptyPage from "@calcom/features/eventtypes/components/EmptyPage";
|
||||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
||||||
import defaultEvents, {
|
import defaultEvents, {
|
||||||
getDynamicEventDescription,
|
getDynamicEventDescription,
|
||||||
getGroupName,
|
getGroupName,
|
||||||
@@ -291,7 +290,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
|
|
||||||
const users = usersWithoutAvatar.map((user) => ({
|
const users = usersWithoutAvatar.map((user) => ({
|
||||||
...user,
|
...user,
|
||||||
avatar: `${WEBAPP_URL}/${user.username}/avatar.png`,
|
avatar: `/${user.username}/avatar.png`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!users.length || (!isValidOrgDomain && !users.some((user) => user.organizationId === null))) {
|
if (!users.length || (!isValidOrgDomain && !users.some((user) => user.organizationId === null))) {
|
||||||
|
|||||||
+142
-319
@@ -1,97 +1,61 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
import type { GetServerSidePropsContext } from "next";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { LocationObject } from "@calcom/app-store/locations";
|
import { Booker } from "@calcom/atoms";
|
||||||
|
import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
|
||||||
|
import { getBookingForReschedule, getBookingForSeatedEvent } from "@calcom/features/bookings/lib/get-booking";
|
||||||
|
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
|
import { classNames } from "@calcom/lib";
|
||||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||||
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
|
import slugify from "@calcom/lib/slugify";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import prisma from "@calcom/prisma";
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
|
||||||
import type { User } from "@calcom/prisma/client";
|
|
||||||
|
|
||||||
import { isBrandingHidden } from "@lib/isBrandingHidden";
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||||
import type { EmbedProps } from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
import AvailabilityPage from "@components/booking/pages/AvailabilityPage";
|
|
||||||
|
|
||||||
import { ssrInit } from "@server/lib/ssr";
|
export type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||||
|
|
||||||
export type AvailabilityPageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
|
export default function Type({ slug, user, booking, away, isBrandingHidden, rescheduleUid, org }: PageProps) {
|
||||||
|
const isEmbed = typeof window !== "undefined" && window?.isEmbed?.();
|
||||||
export default function Type(props: AvailabilityPageProps) {
|
return (
|
||||||
const { t } = useLocale();
|
<main className={classNames("flex h-full items-center justify-center", !isEmbed && "min-h-[100dvh]")}>
|
||||||
|
<BookerSeo
|
||||||
return props.away ? (
|
username={user}
|
||||||
<div className="dark:bg-inverted h-screen">
|
eventSlug={slug}
|
||||||
<main className="mx-auto max-w-3xl px-4 py-24">
|
rescheduleUid={rescheduleUid ?? undefined}
|
||||||
<div className="space-y-6" data-testid="event-types">
|
hideBranding={isBrandingHidden}
|
||||||
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
org={org}
|
||||||
<div className="text-muted dark:text-inverted p-8 text-center">
|
/>
|
||||||
<h2 className="font-cal dark:text-inverted text-emphasis600 mb-2 text-3xl">
|
<Booker
|
||||||
😴{" " + t("user_away")}
|
username={user}
|
||||||
</h2>
|
eventSlug={slug}
|
||||||
<p className="mx-auto max-w-md">{t("user_away_description")}</p>
|
bookingData={booking}
|
||||||
</div>
|
isAway={away}
|
||||||
</div>
|
hideBranding={isBrandingHidden}
|
||||||
</div>
|
org={org}
|
||||||
</main>
|
/>
|
||||||
</div>
|
</main>
|
||||||
) : props.isDynamic && !props.profile.allowDynamicBooking ? (
|
|
||||||
<div className="dark:bg-darkgray-50 h-screen">
|
|
||||||
<main className="mx-auto max-w-3xl px-4 py-24">
|
|
||||||
<div className="space-y-6" data-testid="event-types">
|
|
||||||
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
|
||||||
<div className="text-muted dark:text-inverted p-8 text-center">
|
|
||||||
<h2 className="font-cal dark:text-inverted text-emphasis600 mb-2 text-3xl">
|
|
||||||
{" " + t("unavailable")}
|
|
||||||
</h2>
|
|
||||||
<p className="mx-auto max-w-md">{t("user_dynamic_booking_disabled")}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
) : !props.isValidOrgDomain && props.organizationContext ? (
|
|
||||||
<div className="dark:bg-darkgray-50 h-screen">
|
|
||||||
<main className="mx-auto max-w-3xl px-4 py-24">
|
|
||||||
<div className="space-y-6" data-testid="event-types">
|
|
||||||
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
|
||||||
<div className="text-muted dark:text-inverted p-8 text-center">
|
|
||||||
<h2 className="font-cal dark:text-inverted text-emphasis600 mb-2 text-3xl">
|
|
||||||
{" " + t("unavailable")}
|
|
||||||
</h2>
|
|
||||||
<p className="mx-auto max-w-md">{t("user_belongs_organization")}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<AvailabilityPage {...props} />
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type.isBookingPage = true;
|
Type.isBookingPage = true;
|
||||||
Type.PageWrapper = PageWrapper;
|
Type.PageWrapper = PageWrapper;
|
||||||
|
|
||||||
const paramsSchema = z.object({ type: z.string(), user: z.string() });
|
async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
||||||
async function getUserPageProps(context: GetServerSidePropsContext) {
|
const { user: usernames, type: slug } = paramsSchema.parse(context.params);
|
||||||
// load server side dependencies
|
const { rescheduleUid, bookingUid } = context.query;
|
||||||
const prisma = await import("@calcom/prisma").then((mod) => mod.default);
|
|
||||||
const { privacyFilteredLocations } = await import("@calcom/app-store/locations");
|
|
||||||
const { parseRecurringEvent } = await import("@calcom/lib/isRecurringEvent");
|
|
||||||
const { EventTypeMetaDataSchema, teamMetadataSchema } = await import("@calcom/prisma/zod-utils");
|
|
||||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
const { type: slug, user: username } = paramsSchema.parse(context.query);
|
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const { ssrInit } = await import("@server/lib/ssr");
|
||||||
|
const ssr = await ssrInit(context);
|
||||||
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||||
|
|
||||||
|
const users = await prisma.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
/** TODO: We should standarize this */
|
username: {
|
||||||
username: username.toLowerCase().replace(/( |%20)/g, "+"),
|
in: usernames,
|
||||||
|
},
|
||||||
organization: isValidOrgDomain
|
organization: isValidOrgDomain
|
||||||
? {
|
? {
|
||||||
slug: currentOrgDomain,
|
slug: currentOrgDomain,
|
||||||
@@ -99,183 +63,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
|||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
away: true,
|
|
||||||
name: true,
|
|
||||||
hideBranding: true,
|
|
||||||
timeZone: true,
|
|
||||||
theme: true,
|
|
||||||
weekStart: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
metadata: true,
|
|
||||||
organizationId: true,
|
|
||||||
eventTypes: {
|
|
||||||
where: {
|
|
||||||
// Many-to-many relationship causes inclusion of the team events - cool -
|
|
||||||
// but to prevent these from being selected, make sure the teamId is NULL.
|
|
||||||
AND: [{ slug }, { teamId: null }],
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
title: true,
|
|
||||||
slug: true,
|
|
||||||
hidden: true,
|
|
||||||
recurringEvent: true,
|
|
||||||
length: true,
|
|
||||||
locations: true,
|
|
||||||
id: true,
|
|
||||||
description: true,
|
|
||||||
price: true,
|
|
||||||
currency: true,
|
|
||||||
requiresConfirmation: true,
|
|
||||||
schedulingType: true,
|
|
||||||
metadata: true,
|
|
||||||
seatsPerTimeSlot: true,
|
|
||||||
team: {
|
|
||||||
select: {
|
|
||||||
logo: true,
|
|
||||||
parent: {
|
|
||||||
select: {
|
|
||||||
logo: true,
|
|
||||||
name: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
orderBy: [
|
|
||||||
{
|
|
||||||
position: "desc",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "asc",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
teams: {
|
|
||||||
include: {
|
|
||||||
team: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!user || !user.eventTypes.length) return { notFound: true };
|
|
||||||
|
|
||||||
const [eventType]: ((typeof user.eventTypes)[number] & {
|
|
||||||
users: Pick<User, "name" | "username" | "hideBranding" | "timeZone">[];
|
|
||||||
})[] = [
|
|
||||||
{
|
|
||||||
...user.eventTypes[0],
|
|
||||||
users: [
|
|
||||||
{
|
|
||||||
name: user.name,
|
|
||||||
username: user.username,
|
|
||||||
hideBranding: user.hideBranding,
|
|
||||||
timeZone: user.timeZone,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!eventType) return { notFound: true };
|
|
||||||
|
|
||||||
//TODO: Use zodSchema to verify it instead of using Type Assertion
|
|
||||||
const locations = eventType.locations ? (eventType.locations as LocationObject[]) : [];
|
|
||||||
const eventTypeObject = Object.assign({}, eventType, {
|
|
||||||
metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),
|
|
||||||
recurringEvent: parseRecurringEvent(eventType.recurringEvent),
|
|
||||||
locations: privacyFilteredLocations(locations),
|
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
|
||||||
});
|
|
||||||
// Check if the user you are logging into has any active teams or premium user name
|
|
||||||
const hasActiveTeam =
|
|
||||||
user.teams.filter((m) => {
|
|
||||||
if (!IS_TEAM_BILLING_ENABLED) return true;
|
|
||||||
const metadata = teamMetadataSchema.safeParse(m.team.metadata);
|
|
||||||
if (metadata.success && metadata.data?.subscriptionId) return true;
|
|
||||||
return false;
|
|
||||||
}).length > 0;
|
|
||||||
|
|
||||||
const hasPremiumUserName = hasKeyInMetadata(user, "isPremium") ? !!user.metadata.isPremium : false;
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
eventType: eventTypeObject,
|
|
||||||
profile: {
|
|
||||||
...eventType.users[0],
|
|
||||||
theme: user.theme,
|
|
||||||
allowDynamicBooking: false,
|
|
||||||
weekStart: user.weekStart,
|
|
||||||
brandColor: user.brandColor,
|
|
||||||
darkBrandColor: user.darkBrandColor,
|
|
||||||
slug: `${user.username}/${eventType.slug}`,
|
|
||||||
image: `${WEBAPP_URL}/${user.username}/avatar.png`,
|
|
||||||
},
|
|
||||||
// Dynamic group has no theme preference right now. It uses system theme.
|
|
||||||
themeBasis: user.username,
|
|
||||||
organizationContext: user?.organizationId !== null,
|
|
||||||
away: user?.away,
|
|
||||||
isDynamic: false,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
isValidOrgDomain: orgDomainConfig(context.req.headers.host ?? ""),
|
|
||||||
isBrandingHidden: isBrandingHidden(user.hideBranding, hasActiveTeam || hasPremiumUserName),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
|
||||||
// load server side dependencies
|
|
||||||
const { getDefaultEvent, getGroupName, getUsernameList } = await import("@calcom/lib/defaultEvents");
|
|
||||||
const { privacyFilteredLocations } = await import("@calcom/app-store/locations");
|
|
||||||
const { parseRecurringEvent } = await import("@calcom/lib/isRecurringEvent");
|
|
||||||
const prisma = await import("@calcom/prisma").then((mod) => mod.default);
|
|
||||||
const { EventTypeMetaDataSchema, userMetadata: userMetadataSchema } = await import(
|
|
||||||
"@calcom/prisma/zod-utils"
|
|
||||||
);
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
|
|
||||||
const { getAppFromSlug } = await import("@calcom/app-store/utils");
|
|
||||||
|
|
||||||
const { type: typeParam, user: userParam } = paramsSchema.parse(context.params);
|
|
||||||
const usernameList = getUsernameList(userParam);
|
|
||||||
const length = parseInt(typeParam);
|
|
||||||
const eventType = getDefaultEvent("" + length);
|
|
||||||
|
|
||||||
const users = await prisma.user.findMany({
|
|
||||||
where: {
|
|
||||||
username: {
|
|
||||||
in: usernameList,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
bio: true,
|
|
||||||
avatar: true,
|
|
||||||
startTime: true,
|
|
||||||
endTime: true,
|
|
||||||
timeZone: true,
|
|
||||||
weekStart: true,
|
|
||||||
availability: true,
|
|
||||||
hideBranding: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
defaultScheduleId: true,
|
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
metadata: true,
|
|
||||||
organizationId: true,
|
|
||||||
away: true,
|
|
||||||
schedules: {
|
|
||||||
select: {
|
|
||||||
availability: true,
|
|
||||||
timeZone: true,
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
theme: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -284,87 +72,122 @@ async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
|||||||
notFound: true,
|
notFound: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||||
|
|
||||||
// sort and be in the same order as usernameList so first user is the first user in the list
|
let booking: GetBookingType | null = null;
|
||||||
let sortedUsers: typeof users = [];
|
if (rescheduleUid) {
|
||||||
if (users.length > 1) {
|
booking = await getBookingForReschedule(`${rescheduleUid}`);
|
||||||
sortedUsers = users.sort((a, b) => {
|
} else if (bookingUid) {
|
||||||
const aIndex = (a.username && usernameList.indexOf(a.username)) || 0;
|
booking = await getBookingForSeatedEvent(`${bookingUid}`);
|
||||||
const bIndex = (b.username && usernameList.indexOf(b.username)) || 0;
|
|
||||||
return aIndex - bIndex;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let locations = eventType.locations ? (eventType.locations as LocationObject[]) : [];
|
// We use this to both prefetch the query on the server,
|
||||||
|
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
||||||
|
const eventData = await ssr.viewer.public.event.fetch({
|
||||||
|
username: usernames.join("+"),
|
||||||
|
eventSlug: slug,
|
||||||
|
org,
|
||||||
|
});
|
||||||
|
|
||||||
// Get the prefered location type from the first user
|
if (!eventData) {
|
||||||
const firstUsersMetadata = userMetadataSchema.parse(sortedUsers[0].metadata || {});
|
return {
|
||||||
const preferedLocationType = firstUsersMetadata?.defaultConferencingApp;
|
notFound: true,
|
||||||
|
};
|
||||||
if (preferedLocationType?.appSlug) {
|
|
||||||
const foundApp = getAppFromSlug(preferedLocationType.appSlug);
|
|
||||||
const appType = foundApp?.appData?.location?.type;
|
|
||||||
if (appType) {
|
|
||||||
// Replace the location with the prefered location type
|
|
||||||
// This will still be default to daily if the app is not found
|
|
||||||
locations = [{ type: appType, link: preferedLocationType.appLink }] as LocationObject[];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventTypeObject = Object.assign({}, eventType, {
|
|
||||||
metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),
|
|
||||||
recurringEvent: parseRecurringEvent(eventType.recurringEvent),
|
|
||||||
locations: privacyFilteredLocations(locations),
|
|
||||||
users: users.map((user) => {
|
|
||||||
return {
|
|
||||||
name: user.name,
|
|
||||||
username: user.username,
|
|
||||||
hideBranding: user.hideBranding,
|
|
||||||
timeZone: user.timeZone,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
const dynamicNames = users.map((user) => {
|
|
||||||
return user.name || "";
|
|
||||||
});
|
|
||||||
|
|
||||||
const profile = {
|
|
||||||
name: getGroupName(dynamicNames),
|
|
||||||
image: null,
|
|
||||||
slug: "" + length,
|
|
||||||
theme: null as string | null,
|
|
||||||
weekStart: "Sunday",
|
|
||||||
brandColor: "",
|
|
||||||
darkBrandColor: "",
|
|
||||||
allowDynamicBooking: !users.some((user) => {
|
|
||||||
return !user.allowDynamicBooking;
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
eventType: eventTypeObject,
|
org,
|
||||||
profile,
|
booking,
|
||||||
// Dynamic group has no theme preference right now. It uses system theme.
|
user: usernames.join("+"),
|
||||||
themeBasis: null,
|
slug,
|
||||||
isDynamic: true,
|
|
||||||
away: false,
|
away: false,
|
||||||
organizationContext: !users.some((user) => user.organizationId === null),
|
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
isValidOrgDomain: orgDomainConfig(context.req.headers.host ?? ""),
|
isBrandingHidden: false,
|
||||||
isBrandingHidden: false, // I think we should always show branding for dynamic groups - saves us checking every single user
|
themeBasis: null,
|
||||||
|
bookingUid: bookingUid ? `${bookingUid}` : null,
|
||||||
|
rescheduleUid: rescheduleUid ? `${rescheduleUid}` : null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||||
const { user: userParam } = paramsSchema.parse(context.params);
|
const { user: usernames, type: slug } = paramsSchema.parse(context.params);
|
||||||
// dynamic groups are not generated at build time, but otherwise are probably cached until infinity.
|
const username = usernames[0];
|
||||||
const isDynamicGroup = getUsernameList(userParam).length > 1;
|
const { rescheduleUid, bookingUid } = context.query;
|
||||||
if (isDynamicGroup) {
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||||
return await getDynamicGroupPageProps(context);
|
|
||||||
} else {
|
const { ssrInit } = await import("@server/lib/ssr");
|
||||||
return await getUserPageProps(context);
|
const ssr = await ssrInit(context);
|
||||||
|
const user = await prisma.user.findFirst({
|
||||||
|
where: {
|
||||||
|
username,
|
||||||
|
organization: isValidOrgDomain
|
||||||
|
? {
|
||||||
|
slug: currentOrgDomain,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
away: true,
|
||||||
|
hideBranding: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return {
|
||||||
|
notFound: true,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let booking: GetBookingType | null = null;
|
||||||
|
if (rescheduleUid) {
|
||||||
|
booking = await getBookingForReschedule(`${rescheduleUid}`);
|
||||||
|
} else if (bookingUid) {
|
||||||
|
booking = await getBookingForSeatedEvent(`${bookingUid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||||
|
// We use this to both prefetch the query on the server,
|
||||||
|
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
||||||
|
const eventData = await ssr.viewer.public.event.fetch({
|
||||||
|
username,
|
||||||
|
eventSlug: slug,
|
||||||
|
org,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!eventData) {
|
||||||
|
return {
|
||||||
|
notFound: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
booking,
|
||||||
|
away: user?.away,
|
||||||
|
user: username,
|
||||||
|
slug,
|
||||||
|
org,
|
||||||
|
trpcState: ssr.dehydrate(),
|
||||||
|
isBrandingHidden: user?.hideBranding,
|
||||||
|
themeBasis: username,
|
||||||
|
bookingUid: bookingUid ? `${bookingUid}` : null,
|
||||||
|
rescheduleUid: rescheduleUid ? `${rescheduleUid}` : null,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const paramsSchema = z.object({
|
||||||
|
type: z.string().transform((s) => slugify(s)),
|
||||||
|
user: z.string().transform((s) => getUsernameList(s)),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Booker page fetches a tiny bit of data server side, to determine early
|
||||||
|
// whether the page should show an away state or dynamic booking not allowed.
|
||||||
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||||
|
const { user } = paramsSchema.parse(context.params);
|
||||||
|
const isDynamicGroup = user.length > 1;
|
||||||
|
|
||||||
|
return isDynamicGroup ? await getDynamicGroupPageProps(context) : await getUserPageProps(context);
|
||||||
|
};
|
||||||
@@ -1,19 +1,11 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
import withEmbedSsr from "@lib/withEmbedSsr";
|
||||||
|
|
||||||
import { getServerSideProps as _getServerSideProps } from "../[type]";
|
import { getServerSideProps as _getServerSideProps } from "../[type]";
|
||||||
|
|
||||||
export { default } from "../[type]";
|
export { default } from "../[type]";
|
||||||
|
|
||||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
// Somehow these types don't accept the {notFound: true} return type.
|
||||||
const ssrResponse = await _getServerSideProps(context);
|
// Probably still need to fix this. I don't know why this isn't allowed yet.
|
||||||
if (ssrResponse.notFound) {
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
return ssrResponse;
|
// @ts-ignore
|
||||||
}
|
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
|
||||||
return {
|
|
||||||
...ssrResponse,
|
|
||||||
props: {
|
|
||||||
...ssrResponse.props,
|
|
||||||
isEmbed: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,309 +0,0 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import type { LocationObject } from "@calcom/app-store/locations";
|
|
||||||
import { privacyFilteredLocations } from "@calcom/app-store/locations";
|
|
||||||
import { getAppFromSlug } from "@calcom/app-store/utils";
|
|
||||||
import dayjs from "@calcom/dayjs";
|
|
||||||
import getBooking from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
|
||||||
import { parseRecurringEvent } from "@calcom/lib";
|
|
||||||
import {
|
|
||||||
getDefaultEvent,
|
|
||||||
getDynamicEventName,
|
|
||||||
getGroupName,
|
|
||||||
getUsernameList,
|
|
||||||
} from "@calcom/lib/defaultEvents";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
|
||||||
import prisma, { bookEventTypeSelect } from "@calcom/prisma";
|
|
||||||
import {
|
|
||||||
customInputSchema,
|
|
||||||
EventTypeMetaDataSchema,
|
|
||||||
userMetadata as userMetadataSchema,
|
|
||||||
} from "@calcom/prisma/zod-utils";
|
|
||||||
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
|
||||||
import BookingPage from "@components/booking/pages/BookingPage";
|
|
||||||
|
|
||||||
import { ssrInit } from "@server/lib/ssr";
|
|
||||||
|
|
||||||
export type BookPageProps = inferSSRProps<typeof getServerSideProps>;
|
|
||||||
|
|
||||||
export default function Book(props: BookPageProps) {
|
|
||||||
const { t } = useLocale();
|
|
||||||
return props.away ? (
|
|
||||||
<div className="dark:bg-inverted h-screen">
|
|
||||||
<main className="mx-auto max-w-3xl px-4 py-24">
|
|
||||||
<div className="space-y-6" data-testid="event-types">
|
|
||||||
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
|
||||||
<div className="text-muted dark:text-inverted p-8 text-center">
|
|
||||||
<h2 className="font-cal dark:text-inverted text-default mb-2 text-3xl">
|
|
||||||
😴{" " + t("user_away")}
|
|
||||||
</h2>
|
|
||||||
<p className="mx-auto max-w-md">{t("user_away_description")}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
) : props.isDynamicGroupBooking && !props.profile.allowDynamicBooking ? (
|
|
||||||
<div className="dark:bg-inverted h-screen">
|
|
||||||
<main className="mx-auto max-w-3xl px-4 py-24">
|
|
||||||
<div className="space-y-6" data-testid="event-types">
|
|
||||||
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
|
||||||
<div className="text-muted dark:text-inverted p-8 text-center">
|
|
||||||
<h2 className="font-cal dark:text-inverted text-default mb-2 text-3xl">
|
|
||||||
{" " + t("unavailable")}
|
|
||||||
</h2>
|
|
||||||
<p className="mx-auto max-w-md">{t("user_dynamic_booking_disabled")}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<BookingPage {...props} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Book.isBookingPage = true;
|
|
||||||
Book.PageWrapper = PageWrapper;
|
|
||||||
|
|
||||||
const querySchema = z.object({
|
|
||||||
bookingUid: z.string().optional(),
|
|
||||||
count: z.coerce.number().optional(),
|
|
||||||
embed: z.string().optional(),
|
|
||||||
rescheduleUid: z.string().optional(),
|
|
||||||
slug: z.string().optional(),
|
|
||||||
/** This is the event "type" ID */
|
|
||||||
type: z.coerce.number().optional(),
|
|
||||||
user: z.string(),
|
|
||||||
seatReferenceUid: z.string().optional(),
|
|
||||||
date: z.string().optional(),
|
|
||||||
duration: z.coerce.number().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
const query = querySchema.parse(context.query);
|
|
||||||
const usernameList = getUsernameList(query.user);
|
|
||||||
const eventTypeSlug = query.slug;
|
|
||||||
const recurringEventCountQuery = query.count;
|
|
||||||
const users = await prisma.user.findMany({
|
|
||||||
where: {
|
|
||||||
username: {
|
|
||||||
in: usernameList,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
bio: true,
|
|
||||||
avatar: true,
|
|
||||||
theme: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
allowDynamicBooking: true,
|
|
||||||
away: true,
|
|
||||||
metadata: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!users.length) return { notFound: true };
|
|
||||||
const [user] = users;
|
|
||||||
const isDynamicGroupBooking = users.length > 1 && !!eventTypeSlug;
|
|
||||||
|
|
||||||
// Dynamic Group link doesn't need a type but it must have a slug
|
|
||||||
if ((!isDynamicGroupBooking && !query.type) || (users.length > 1 && !eventTypeSlug)) {
|
|
||||||
return { notFound: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
const eventTypeRaw = isDynamicGroupBooking
|
|
||||||
? getDefaultEvent(eventTypeSlug)
|
|
||||||
: await prisma.eventType.findUnique({
|
|
||||||
where: {
|
|
||||||
id: query.type,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
...bookEventTypeSelect,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!eventTypeRaw) return { notFound: true };
|
|
||||||
const eventType = {
|
|
||||||
...eventTypeRaw,
|
|
||||||
metadata: EventTypeMetaDataSchema.parse(eventTypeRaw.metadata || {}),
|
|
||||||
bookingFields: getBookingFieldsWithSystemFields(eventTypeRaw),
|
|
||||||
recurringEvent: parseRecurringEvent(eventTypeRaw.recurringEvent),
|
|
||||||
};
|
|
||||||
|
|
||||||
const getLocations = () => {
|
|
||||||
let locations = eventTypeRaw.locations || [];
|
|
||||||
if (!isDynamicGroupBooking) return locations;
|
|
||||||
|
|
||||||
let sortedUsers: typeof users = [];
|
|
||||||
// sort and be in the same order as usernameList so first user is the first user in the list
|
|
||||||
if (users.length > 1) {
|
|
||||||
sortedUsers = users.sort((a, b) => {
|
|
||||||
const aIndex = (a.username && usernameList.indexOf(a.username)) || 0;
|
|
||||||
const bIndex = (b.username && usernameList.indexOf(b.username)) || 0;
|
|
||||||
return aIndex - bIndex;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the prefered location type from the first user
|
|
||||||
const firstUsersMetadata = userMetadataSchema.parse(sortedUsers[0].metadata || {});
|
|
||||||
const preferedLocationType = firstUsersMetadata?.defaultConferencingApp;
|
|
||||||
|
|
||||||
if (preferedLocationType?.appSlug) {
|
|
||||||
const foundApp = getAppFromSlug(preferedLocationType.appSlug);
|
|
||||||
const appType = foundApp?.appData?.location?.type;
|
|
||||||
if (appType) {
|
|
||||||
// Replace the location with the prefered location type
|
|
||||||
// This will still be default to daily if the app is not found
|
|
||||||
locations = [{ type: appType, link: preferedLocationType.appLink }] as LocationObject[];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return locations;
|
|
||||||
};
|
|
||||||
|
|
||||||
const eventTypeObject = [eventType].map((e) => {
|
|
||||||
let locations = getLocations();
|
|
||||||
locations = privacyFilteredLocations(locations as LocationObject[]);
|
|
||||||
return {
|
|
||||||
...e,
|
|
||||||
locations: locations,
|
|
||||||
periodStartDate: e.periodStartDate?.toString() ?? null,
|
|
||||||
periodEndDate: e.periodEndDate?.toString() ?? null,
|
|
||||||
schedulingType: null,
|
|
||||||
customInputs: customInputSchema.array().parse(e.customInputs || []),
|
|
||||||
users: users.map((u) => ({
|
|
||||||
id: u.id,
|
|
||||||
name: u.name,
|
|
||||||
username: u.username,
|
|
||||||
avatar: u.avatar,
|
|
||||||
image: u.avatar,
|
|
||||||
slug: u.username,
|
|
||||||
theme: u.theme,
|
|
||||||
})),
|
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
|
||||||
};
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
// If rescheduleUid and event has seats lets convert Uid to bookingUid
|
|
||||||
let rescheduleUid = query.rescheduleUid;
|
|
||||||
const rescheduleEventTypeHasSeats = query.rescheduleUid && eventTypeRaw.seatsPerTimeSlot;
|
|
||||||
let attendeeEmail: string;
|
|
||||||
let bookingUidWithSeats: string | null = null;
|
|
||||||
|
|
||||||
if (rescheduleEventTypeHasSeats) {
|
|
||||||
const bookingSeat = await prisma.bookingSeat.findFirst({
|
|
||||||
where: {
|
|
||||||
referenceUid: query.rescheduleUid,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
attendee: true,
|
|
||||||
booking: {
|
|
||||||
select: {
|
|
||||||
uid: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (bookingSeat) {
|
|
||||||
rescheduleUid = bookingSeat.booking.uid;
|
|
||||||
attendeeEmail = bookingSeat.attendee.email;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query.duration) {
|
|
||||||
// If it's not reschedule but event Type has seats we should obtain
|
|
||||||
// the bookingUid regardless and use it to get the booking
|
|
||||||
const currentSeats = await prisma.booking.findFirst({
|
|
||||||
where: {
|
|
||||||
eventTypeId: eventTypeRaw.id,
|
|
||||||
startTime: dayjs(query.date).toISOString(),
|
|
||||||
endTime: dayjs(query.date).add(query.duration, "minutes").toISOString(),
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
uid: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (currentSeats && currentSeats) {
|
|
||||||
bookingUidWithSeats = currentSeats.uid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
|
||||||
if (rescheduleUid || query.bookingUid || bookingUidWithSeats) {
|
|
||||||
booking = await getBooking(prisma, rescheduleUid || query.bookingUid || bookingUidWithSeats || "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rescheduleEventTypeHasSeats && booking?.attendees && booking?.attendees.length > 0) {
|
|
||||||
const currentAttendee = booking?.attendees.find((attendee) => {
|
|
||||||
return attendee.email === attendeeEmail;
|
|
||||||
});
|
|
||||||
if (currentAttendee) {
|
|
||||||
booking.attendees = [currentAttendee] || [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const dynamicNames = isDynamicGroupBooking ? users.map((user) => user.name || "") : [];
|
|
||||||
|
|
||||||
const profile = isDynamicGroupBooking
|
|
||||||
? {
|
|
||||||
name: getGroupName(dynamicNames),
|
|
||||||
image: null,
|
|
||||||
slug: eventTypeSlug,
|
|
||||||
theme: null,
|
|
||||||
brandColor: "",
|
|
||||||
darkBrandColor: "",
|
|
||||||
allowDynamicBooking: !users.some((user) => !user.allowDynamicBooking),
|
|
||||||
eventName: getDynamicEventName(dynamicNames, eventTypeSlug),
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
name: user.name || user.username,
|
|
||||||
image: user.avatar,
|
|
||||||
slug: user.username,
|
|
||||||
theme: user.theme,
|
|
||||||
brandColor: user.brandColor,
|
|
||||||
darkBrandColor: user.darkBrandColor,
|
|
||||||
eventName: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Checking if number of recurring event ocurrances is valid against event type configuration
|
|
||||||
const recurringEventCount =
|
|
||||||
(eventType.recurringEvent?.count &&
|
|
||||||
recurringEventCountQuery &&
|
|
||||||
(recurringEventCountQuery <= eventType.recurringEvent.count
|
|
||||||
? recurringEventCountQuery
|
|
||||||
: eventType.recurringEvent.count)) ||
|
|
||||||
null;
|
|
||||||
|
|
||||||
const currentSlotBooking = await getBooking(prisma, bookingUidWithSeats || "");
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
away: user.away,
|
|
||||||
profile,
|
|
||||||
// Dynamic group has no theme preference right now. It uses system theme.
|
|
||||||
themeBasis: isDynamicGroupBooking ? null : user.username,
|
|
||||||
eventType: eventTypeObject,
|
|
||||||
booking,
|
|
||||||
currentSlotBooking: currentSlotBooking,
|
|
||||||
recurringEventCount,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
isDynamicGroupBooking,
|
|
||||||
hasHashedBookingLink: false,
|
|
||||||
hashedLink: null,
|
|
||||||
isEmbed: !!query.embed,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -48,6 +48,13 @@ class MyDocument extends Document<Props> {
|
|||||||
<meta name="msapplication-TileColor" content="#ff0000" />
|
<meta name="msapplication-TileColor" content="#ff0000" />
|
||||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f9fafb" />
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f9fafb" />
|
||||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1C1C1C" />
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1C1C1C" />
|
||||||
|
{(process.env.NODE_ENV === "development" || process.env.VERCEL_ENV === "preview") && (
|
||||||
|
// eslint-disable-next-line @next/next/no-sync-scripts
|
||||||
|
<script
|
||||||
|
data-project-id="KjpMrKTnXquJVKfeqmjdTffVPf1a6Unw2LZ58iE4"
|
||||||
|
src="https://snippet.meticulous.ai/v1/stagingMeticulousSnippet.js"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<body
|
<body
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import { getTranslation } from "@calcom/lib/server/i18n";
|
|||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const t = await getTranslation(req.body.language ?? "en", "common");
|
|
||||||
|
|
||||||
const email = z
|
const email = z
|
||||||
.string()
|
.string()
|
||||||
.email()
|
.email()
|
||||||
@@ -47,6 +45,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
name: true,
|
name: true,
|
||||||
identityProvider: true,
|
identityProvider: true,
|
||||||
email: true,
|
email: true,
|
||||||
|
locale: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,6 +56,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
.json({ message: "If this email exists in our system, you should receive a Reset email." });
|
.json({ message: "If this email exists in our system, you should receive a Reset email." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const t = await getTranslation(maybeUser.locale ?? "en", "common");
|
||||||
|
|
||||||
const maybePreviousRequest = await prisma.resetPasswordRequest.findMany({
|
const maybePreviousRequest = await prisma.resetPasswordRequest.findMany({
|
||||||
where: {
|
where: {
|
||||||
email: maybeUser.email,
|
email: maybeUser.email,
|
||||||
@@ -88,17 +89,9 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
resetLink,
|
resetLink,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** So we can test the password reset flow on CI */
|
return res
|
||||||
if (process.env.NEXT_PUBLIC_IS_E2E) {
|
.status(201)
|
||||||
return res.status(201).json({
|
.json({ message: "If this email exists in our system, you should receive a Reset email." });
|
||||||
message: "If this email exists in our system, you should receive a Reset email.",
|
|
||||||
resetLink,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return res
|
|
||||||
.status(201)
|
|
||||||
.json({ message: "If this email exists in our system, you should receive a Reset email." });
|
|
||||||
}
|
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
// console.error(reason);
|
// console.error(reason);
|
||||||
return res.status(500).json({ message: "Unable to create password reset request" });
|
return res.status(500).json({ message: "Unable to create password reset request" });
|
||||||
|
|||||||
@@ -1,55 +1,66 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
|
import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
|
||||||
|
import { validPassword } from "@calcom/features/auth/lib/validPassword";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
|
const passwordResetRequestSchema = z.object({
|
||||||
|
password: z.string().refine(validPassword, () => ({
|
||||||
|
message: "Password does not meet the requirements",
|
||||||
|
})),
|
||||||
|
requestId: z.string(), // format doesn't matter.
|
||||||
|
});
|
||||||
|
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
if (req.method !== "POST") {
|
// Bad Method when not POST
|
||||||
return res.status(400).json({ message: "" });
|
if (req.method !== "POST") return res.status(405).end();
|
||||||
}
|
|
||||||
|
|
||||||
|
const { password: rawPassword, requestId: rawRequestId } = passwordResetRequestSchema.parse(req.body);
|
||||||
|
// rate-limited there is a low, very low chance that a password request stays valid long enough
|
||||||
|
// to brute force 3.8126967e+40 options.
|
||||||
|
const maybeRequest = await prisma.resetPasswordRequest.findFirstOrThrow({
|
||||||
|
where: {
|
||||||
|
id: rawRequestId,
|
||||||
|
expires: {
|
||||||
|
gt: new Date(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
email: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const hashedPassword = await hashPassword(rawPassword);
|
||||||
|
// this can fail if a password request has been made for an email that has since changed or-
|
||||||
|
// never existed within Cal. In this case we do not want to disclose the email's existence.
|
||||||
|
// instead, we just return 404
|
||||||
try {
|
try {
|
||||||
const rawPassword = req.body?.password;
|
|
||||||
const rawRequestId = req.body?.requestId;
|
|
||||||
|
|
||||||
if (!rawPassword || !rawRequestId) {
|
|
||||||
return res.status(400).json({ message: "Couldn't find an account for this email" });
|
|
||||||
}
|
|
||||||
|
|
||||||
const maybeRequest = await prisma.resetPasswordRequest.findUnique({
|
|
||||||
where: {
|
|
||||||
id: rawRequestId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!maybeRequest) {
|
|
||||||
return res.status(400).json({ message: "Couldn't find an account for this email" });
|
|
||||||
}
|
|
||||||
|
|
||||||
const maybeUser = await prisma.user.findUnique({
|
|
||||||
where: {
|
|
||||||
email: maybeRequest.email,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!maybeUser) {
|
|
||||||
return res.status(400).json({ message: "Couldn't find an account for this email" });
|
|
||||||
}
|
|
||||||
|
|
||||||
const hashedPassword = await hashPassword(rawPassword);
|
|
||||||
|
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id: maybeUser.id,
|
email: maybeRequest.email,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
return res.status(201).json({ message: "Password reset." });
|
return res.status(404).end();
|
||||||
} catch (reason) {
|
|
||||||
console.error(reason);
|
|
||||||
return res.status(500).json({ message: "Unable to create password reset request" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await expireResetPasswordRequest(rawRequestId);
|
||||||
|
|
||||||
|
return res.status(201).json({ message: "Password reset." });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function expireResetPasswordRequest(rawRequestId: string) {
|
||||||
|
await prisma.resetPasswordRequest.update({
|
||||||
|
where: {
|
||||||
|
id: rawRequestId,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
// We set the expiry to now to invalidate the request
|
||||||
|
expires: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
|
|||||||
import { sendEmailVerification } from "@calcom/features/auth/lib/verifyEmail";
|
import { sendEmailVerification } from "@calcom/features/auth/lib/verifyEmail";
|
||||||
import slugify from "@calcom/lib/slugify";
|
import slugify from "@calcom/lib/slugify";
|
||||||
import { closeComUpsertTeamUser } from "@calcom/lib/sync/SyncServiceManager";
|
import { closeComUpsertTeamUser } from "@calcom/lib/sync/SyncServiceManager";
|
||||||
|
import { validateUsernameInOrg } from "@calcom/lib/validateUsernameInOrg";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
import { IdentityProvider } from "@calcom/prisma/enums";
|
import { IdentityProvider } from "@calcom/prisma/enums";
|
||||||
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||||
@@ -70,6 +71,35 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
return res.status(409).json({ message });
|
return res.status(409).json({ message });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let foundToken: { id: number; teamId: number | null; expires: Date } | null = null;
|
||||||
|
if (token) {
|
||||||
|
foundToken = await prisma.verificationToken.findFirst({
|
||||||
|
where: {
|
||||||
|
token,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
expires: true,
|
||||||
|
teamId: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!foundToken) {
|
||||||
|
return res.status(401).json({ message: "Invalid Token" });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dayjs(foundToken?.expires).isBefore(dayjs())) {
|
||||||
|
return res.status(401).json({ message: "Token expired" });
|
||||||
|
}
|
||||||
|
if (foundToken?.teamId) {
|
||||||
|
const isValidUsername = await validateUsernameInOrg(username, foundToken?.teamId);
|
||||||
|
|
||||||
|
if (!isValidUsername) {
|
||||||
|
return res.status(409).json({ message: "Username already taken" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const hashedPassword = await hashPassword(password);
|
const hashedPassword = await hashPassword(password);
|
||||||
|
|
||||||
const user = await prisma.user.upsert({
|
const user = await prisma.user.upsert({
|
||||||
@@ -88,91 +118,75 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (token) {
|
if (foundToken && foundToken?.teamId) {
|
||||||
const foundToken = await prisma.verificationToken.findFirst({
|
const team = await prisma.team.findUnique({
|
||||||
where: {
|
where: {
|
||||||
token,
|
id: foundToken.teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!foundToken) {
|
if (team) {
|
||||||
return res.status(401).json({ message: "Invalid Token" });
|
const teamMetadata = teamMetadataSchema.parse(team?.metadata);
|
||||||
}
|
if (teamMetadata?.isOrganization) {
|
||||||
|
await prisma.user.update({
|
||||||
|
where: {
|
||||||
|
id: user.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
organizationId: team.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (dayjs(foundToken?.expires).isBefore(dayjs())) {
|
const membership = await prisma.membership.update({
|
||||||
return res.status(401).json({ message: "Token expired" });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundToken.teamId) {
|
|
||||||
const team = await prisma.team.findUnique({
|
|
||||||
where: {
|
where: {
|
||||||
id: foundToken.teamId,
|
userId_teamId: { userId: user.id, teamId: team.id },
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
accepted: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
closeComUpsertTeamUser(team, user, membership.role);
|
||||||
|
|
||||||
if (team) {
|
// Accept any child team invites for orgs.
|
||||||
const teamMetadata = teamMetadataSchema.parse(team?.metadata);
|
if (team.parentId) {
|
||||||
if (teamMetadata?.isOrganization) {
|
// Join ORG
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
where: {
|
|
||||||
id: user.id,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
organizationId: team.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const membership = await prisma.membership.update({
|
|
||||||
where: {
|
where: {
|
||||||
userId_teamId: { userId: user.id, teamId: team.id },
|
id: user.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
organizationId: team.parentId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** We do a membership update twice so we can join the ORG invite if the user is invited to a team witin a ORG. */
|
||||||
|
await prisma.membership.updateMany({
|
||||||
|
where: {
|
||||||
|
userId: user.id,
|
||||||
|
team: {
|
||||||
|
id: team.parentId,
|
||||||
|
},
|
||||||
|
accepted: false,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
accepted: true,
|
accepted: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
closeComUpsertTeamUser(team, user, membership.role);
|
|
||||||
|
|
||||||
// Accept any child team invites for orgs.
|
// Join any other invites
|
||||||
if (team.parentId) {
|
await prisma.membership.updateMany({
|
||||||
// Join ORG
|
where: {
|
||||||
await prisma.user.update({
|
userId: user.id,
|
||||||
where: {
|
team: {
|
||||||
id: user.id,
|
parentId: team.parentId,
|
||||||
},
|
},
|
||||||
data: {
|
accepted: false,
|
||||||
organizationId: team.parentId,
|
},
|
||||||
},
|
data: {
|
||||||
});
|
accepted: true,
|
||||||
|
},
|
||||||
/** We do a membership update twice so we can join the ORG invite if the user is invited to a team witin a ORG. */
|
});
|
||||||
await prisma.membership.updateMany({
|
|
||||||
where: {
|
|
||||||
userId: user.id,
|
|
||||||
team: {
|
|
||||||
id: team.parentId,
|
|
||||||
},
|
|
||||||
accepted: false,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
accepted: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Join any other invites
|
|
||||||
await prisma.membership.updateMany({
|
|
||||||
where: {
|
|
||||||
userId: user.id,
|
|
||||||
team: {
|
|
||||||
parentId: team.parentId,
|
|
||||||
},
|
|
||||||
accepted: false,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
accepted: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||||
|
import handleNewBooking from "@calcom/features/bookings/lib/handleNewBooking";
|
||||||
|
import type { BookingResponse, RecurringBookingCreateBody } from "@calcom/features/bookings/types";
|
||||||
|
import { defaultResponder } from "@calcom/lib/server";
|
||||||
|
import type { AppsStatus } from "@calcom/types/Calendar";
|
||||||
|
|
||||||
|
// @TODO: Didn't look at the contents of this function in order to not break old booking page.
|
||||||
|
|
||||||
|
async function handler(req: NextApiRequest & { userId?: number }, res: NextApiResponse) {
|
||||||
|
const data: RecurringBookingCreateBody[] = req.body;
|
||||||
|
const session = await getServerSession({ req, res });
|
||||||
|
const createdBookings: BookingResponse[] = [];
|
||||||
|
const allRecurringDates: string[] = data.map((booking) => booking.start);
|
||||||
|
let appsStatus: AppsStatus[] | undefined = undefined;
|
||||||
|
|
||||||
|
/* To mimic API behavior and comply with types */
|
||||||
|
req.userId = session?.user?.id || -1;
|
||||||
|
|
||||||
|
// Reversing to accumulate results for noEmail instances first, to then lastly, create the
|
||||||
|
// emailed booking taking into account accumulated results to send app status accurately
|
||||||
|
for (let key = data.length - 1; key >= 0; key--) {
|
||||||
|
const booking = data[key];
|
||||||
|
if (key === 0) {
|
||||||
|
const calcAppsStatus: { [key: string]: AppsStatus } = createdBookings
|
||||||
|
.flatMap((book) => (book.appsStatus !== undefined ? book.appsStatus : []))
|
||||||
|
.reduce((prev, curr) => {
|
||||||
|
if (prev[curr.type]) {
|
||||||
|
prev[curr.type].failures += curr.failures;
|
||||||
|
prev[curr.type].success += curr.success;
|
||||||
|
} else {
|
||||||
|
prev[curr.type] = curr;
|
||||||
|
}
|
||||||
|
return prev;
|
||||||
|
}, {} as { [key: string]: AppsStatus });
|
||||||
|
appsStatus = Object.values(calcAppsStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
const recurringEventReq: NextApiRequest & { userId?: number } = req;
|
||||||
|
|
||||||
|
recurringEventReq.body = {
|
||||||
|
...booking,
|
||||||
|
appsStatus,
|
||||||
|
allRecurringDates,
|
||||||
|
currentRecurringIndex: key,
|
||||||
|
noEmail: key !== 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const eachRecurringBooking = await handleNewBooking(recurringEventReq, {
|
||||||
|
isNotAnApiCall: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
createdBookings.push(eachRecurringBooking);
|
||||||
|
}
|
||||||
|
return createdBookings;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defaultResponder(handler);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default } from "@calcom/features/ee/workflows/api/scheduleWhatsappReminders";
|
||||||
@@ -13,12 +13,14 @@ const defaultIntegrationAddHandler = async ({
|
|||||||
supportsMultipleInstalls,
|
supportsMultipleInstalls,
|
||||||
appType,
|
appType,
|
||||||
user,
|
user,
|
||||||
|
teamId = undefined,
|
||||||
createCredential,
|
createCredential,
|
||||||
}: {
|
}: {
|
||||||
slug: string;
|
slug: string;
|
||||||
supportsMultipleInstalls: boolean;
|
supportsMultipleInstalls: boolean;
|
||||||
appType: string;
|
appType: string;
|
||||||
user?: Session["user"];
|
user?: Session["user"];
|
||||||
|
teamId?: number;
|
||||||
createCredential: AppDeclarativeHandler["createCredential"];
|
createCredential: AppDeclarativeHandler["createCredential"];
|
||||||
}) => {
|
}) => {
|
||||||
if (!user?.id) {
|
if (!user?.id) {
|
||||||
@@ -28,21 +30,21 @@ const defaultIntegrationAddHandler = async ({
|
|||||||
const alreadyInstalled = await prisma.credential.findFirst({
|
const alreadyInstalled = await prisma.credential.findFirst({
|
||||||
where: {
|
where: {
|
||||||
appId: slug,
|
appId: slug,
|
||||||
userId: user.id,
|
...(teamId ? { AND: [{ userId: user.id }, { teamId }] } : { userId: user.id }),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (alreadyInstalled) {
|
if (alreadyInstalled) {
|
||||||
throw new Error("App is already installed");
|
throw new Error("App is already installed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await createCredential({ user: user, appType, slug });
|
await createCredential({ user: user, appType, slug, teamId });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
// Check that user is authenticated
|
// Check that user is authenticated
|
||||||
req.session = await getServerSession({ req, res });
|
req.session = await getServerSession({ req, res });
|
||||||
|
|
||||||
const { args } = req.query;
|
const { args, teamId } = req.query;
|
||||||
|
|
||||||
if (!Array.isArray(args)) {
|
if (!Array.isArray(args)) {
|
||||||
return res.status(404).json({ message: `API route not found` });
|
return res.status(404).json({ message: `API route not found` });
|
||||||
@@ -54,6 +56,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
const handlerMap = (await import("@calcom/app-store/apps.server.generated")).apiHandlers;
|
const handlerMap = (await import("@calcom/app-store/apps.server.generated")).apiHandlers;
|
||||||
const handlerKey = deriveAppDictKeyFromType(appName, handlerMap);
|
const handlerKey = deriveAppDictKeyFromType(appName, handlerMap);
|
||||||
const handlers = await handlerMap[handlerKey as keyof typeof handlerMap];
|
const handlers = await handlerMap[handlerKey as keyof typeof handlerMap];
|
||||||
|
if (!handlers) throw new HttpError({ statusCode: 404, message: `No handlers found for ${handlerKey}` });
|
||||||
const handler = handlers[apiEndpoint as keyof typeof handlers] as AppHandler;
|
const handler = handlers[apiEndpoint as keyof typeof handlers] as AppHandler;
|
||||||
let redirectUrl = "/apps/installed";
|
let redirectUrl = "/apps/installed";
|
||||||
if (typeof handler === "undefined")
|
if (typeof handler === "undefined")
|
||||||
@@ -62,7 +65,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
if (typeof handler === "function") {
|
if (typeof handler === "function") {
|
||||||
await handler(req, res);
|
await handler(req, res);
|
||||||
} else {
|
} else {
|
||||||
await defaultIntegrationAddHandler({ user: req.session?.user, ...handler });
|
await defaultIntegrationAddHandler({ user: req.session?.user, teamId: Number(teamId), ...handler });
|
||||||
redirectUrl = handler.redirect?.url || getInstalledAppPath(handler);
|
redirectUrl = handler.redirect?.url || getInstalledAppPath(handler);
|
||||||
res.json({ url: redirectUrl, newTab: handler.redirect?.newTab });
|
res.json({ url: redirectUrl, newTab: handler.redirect?.newTab });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { defaultResponder } from "@calcom/lib/server";
|
|
||||||
|
|
||||||
const newBookerSchema = z.object({
|
|
||||||
status: z.enum(["enable", "disable"]),
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Very basic temporary api route to enable/disable new booker access.
|
|
||||||
*/
|
|
||||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
||||||
const { status } = newBookerSchema.parse(req.query);
|
|
||||||
|
|
||||||
if (status === "enable") {
|
|
||||||
const expires = new Date();
|
|
||||||
expires.setFullYear(expires.getFullYear() + 1);
|
|
||||||
res.setHeader("Set-Cookie", `new-booker-enabled=true; path=/; expires=${expires.toUTCString()}`);
|
|
||||||
} else {
|
|
||||||
res.setHeader("Set-Cookie", "new-booker-enabled=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT");
|
|
||||||
}
|
|
||||||
res.send({ status: 200, body: `Done – ${status}` });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defaultResponder(handler);
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler";
|
||||||
|
import { adminRouter } from "@calcom/trpc/server/routers/viewer/admin/_router";
|
||||||
|
|
||||||
|
export default createNextApiHandler(adminRouter);
|
||||||
@@ -18,7 +18,7 @@ const querySchema = z
|
|||||||
async function getIdentityData(req: NextApiRequest) {
|
async function getIdentityData(req: NextApiRequest) {
|
||||||
const { username, teamname } = querySchema.parse(req.query);
|
const { username, teamname } = querySchema.parse(req.query);
|
||||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(req.headers.host ?? "");
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(req.headers.host ?? "");
|
||||||
|
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||||
if (username) {
|
if (username) {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@@ -35,6 +35,7 @@ async function getIdentityData(req: NextApiRequest) {
|
|||||||
name: username,
|
name: username,
|
||||||
email: user?.email,
|
email: user?.email,
|
||||||
avatar: user?.avatar,
|
avatar: user?.avatar,
|
||||||
|
org,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (teamname) {
|
if (teamname) {
|
||||||
@@ -50,6 +51,7 @@ async function getIdentityData(req: NextApiRequest) {
|
|||||||
select: { logo: true },
|
select: { logo: true },
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
org,
|
||||||
name: teamname,
|
name: teamname,
|
||||||
email: null,
|
email: null,
|
||||||
avatar: team?.logo || getPlaceholderAvatar(null, teamname),
|
avatar: team?.logo || getPlaceholderAvatar(null, teamname),
|
||||||
@@ -62,6 +64,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
const img = identity?.avatar;
|
const img = identity?.avatar;
|
||||||
// If image isn't set or links to this route itself, use default avatar
|
// If image isn't set or links to this route itself, use default avatar
|
||||||
if (!img) {
|
if (!img) {
|
||||||
|
if (identity?.org) {
|
||||||
|
res.setHeader("x-cal-org", identity.org);
|
||||||
|
}
|
||||||
res.writeHead(302, {
|
res.writeHead(302, {
|
||||||
Location: defaultAvatarSrc({
|
Location: defaultAvatarSrc({
|
||||||
md5: crypto
|
md5: crypto
|
||||||
@@ -70,16 +75,23 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
.digest("hex"),
|
.digest("hex"),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.end();
|
return res.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!img.includes("data:image")) {
|
if (!img.includes("data:image")) {
|
||||||
|
if (identity.org) {
|
||||||
|
res.setHeader("x-cal-org", identity.org);
|
||||||
|
}
|
||||||
res.writeHead(302, { Location: img });
|
res.writeHead(302, { Location: img });
|
||||||
return res.end();
|
return res.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
const decoded = img.toString().replace("data:image/png;base64,", "").replace("data:image/jpeg;base64,", "");
|
const decoded = img.toString().replace("data:image/png;base64,", "").replace("data:image/jpeg;base64,", "");
|
||||||
const imageResp = Buffer.from(decoded, "base64");
|
const imageResp = Buffer.from(decoded, "base64");
|
||||||
|
if (identity.org) {
|
||||||
|
res.setHeader("x-cal-org", identity.org);
|
||||||
|
}
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
"Content-Type": "image/png",
|
"Content-Type": "image/png",
|
||||||
"Content-Length": imageResp.length,
|
"Content-Length": imageResp.length,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ function getRoute(appName: string, pages: string[]) {
|
|||||||
} as NotFound;
|
} as NotFound;
|
||||||
}
|
}
|
||||||
const mainPage = pages[0];
|
const mainPage = pages[0];
|
||||||
const appPage = routingConfig[mainPage] as AppPageType;
|
const appPage = routingConfig.layoutHandler || (routingConfig[mainPage] as AppPageType);
|
||||||
|
|
||||||
if (!appPage) {
|
if (!appPage) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { useState } from "react";
|
|||||||
|
|
||||||
import { getAppRegistry, getAppRegistryWithCredentials } from "@calcom/app-store/_appRegistry";
|
import { getAppRegistry, getAppRegistryWithCredentials } from "@calcom/app-store/_appRegistry";
|
||||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||||
|
import getUserAdminTeams from "@calcom/features/ee/teams/lib/getUserAdminTeams";
|
||||||
|
import type { UserAdminTeams } from "@calcom/features/ee/teams/lib/getUserAdminTeams";
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import type { AppCategories } from "@calcom/prisma/enums";
|
import type { AppCategories } from "@calcom/prisma/enums";
|
||||||
@@ -48,7 +50,11 @@ function AppsSearch({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Apps({ categories, appStore }: inferSSRProps<typeof getServerSideProps>) {
|
export default function Apps({
|
||||||
|
categories,
|
||||||
|
appStore,
|
||||||
|
userAdminTeams,
|
||||||
|
}: inferSSRProps<typeof getServerSideProps>) {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const [searchText, setSearchText] = useState<string | undefined>(undefined);
|
const [searchText, setSearchText] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
@@ -80,6 +86,7 @@ export default function Apps({ categories, appStore }: inferSSRProps<typeof getS
|
|||||||
apps={appStore}
|
apps={appStore}
|
||||||
searchText={searchText}
|
searchText={searchText}
|
||||||
categories={categories.map((category) => category.name)}
|
categories={categories.map((category) => category.name)}
|
||||||
|
userAdminTeams={userAdminTeams}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</AppsLayout>
|
</AppsLayout>
|
||||||
@@ -95,11 +102,13 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
|
|
||||||
const session = await getServerSession({ req, res });
|
const session = await getServerSession({ req, res });
|
||||||
|
|
||||||
let appStore;
|
let appStore, userAdminTeams: UserAdminTeams;
|
||||||
if (session?.user?.id) {
|
if (session?.user?.id) {
|
||||||
appStore = await getAppRegistryWithCredentials(session.user.id);
|
userAdminTeams = await getUserAdminTeams({ userId: session.user.id, getUserInfo: true });
|
||||||
|
appStore = await getAppRegistryWithCredentials(session.user.id, userAdminTeams);
|
||||||
} else {
|
} else {
|
||||||
appStore = await getAppRegistry();
|
appStore = await getAppRegistry();
|
||||||
|
userAdminTeams = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryQuery = appStore.map(({ categories }) => ({
|
const categoryQuery = appStore.map(({ categories }) => ({
|
||||||
@@ -111,6 +120,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}, {} as Record<string, number>);
|
}, {} as Record<string, number>);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
categories: Object.entries(categories)
|
categories: Object.entries(categories)
|
||||||
@@ -122,6 +132,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
return b.count - a.count;
|
return b.count - a.count;
|
||||||
}),
|
}),
|
||||||
appStore,
|
appStore,
|
||||||
|
userAdminTeams,
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { AppSettings } from "@calcom/app-store/_components/AppSettings";
|
|||||||
import { InstallAppButton } from "@calcom/app-store/components";
|
import { InstallAppButton } from "@calcom/app-store/components";
|
||||||
import type { EventLocationType } from "@calcom/app-store/locations";
|
import type { EventLocationType } from "@calcom/app-store/locations";
|
||||||
import { getEventLocationTypeFromApp } from "@calcom/app-store/locations";
|
import { getEventLocationTypeFromApp } from "@calcom/app-store/locations";
|
||||||
|
import type { CredentialOwner } from "@calcom/app-store/types";
|
||||||
import { AppSetDefaultLinkDialog } from "@calcom/features/apps/components/AppSetDefaultLinkDialog";
|
import { AppSetDefaultLinkDialog } from "@calcom/features/apps/components/AppSetDefaultLinkDialog";
|
||||||
import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
|
import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
|
||||||
import { BulkEditDefaultConferencingModal } from "@calcom/features/eventtypes/components/BulkEditDefaultConferencingModal";
|
import { BulkEditDefaultConferencingModal } from "@calcom/features/eventtypes/components/BulkEditDefaultConferencingModal";
|
||||||
@@ -52,16 +53,16 @@ import { CalendarListContainer } from "@components/apps/CalendarListContainer";
|
|||||||
import InstalledAppsLayout from "@components/apps/layouts/InstalledAppsLayout";
|
import InstalledAppsLayout from "@components/apps/layouts/InstalledAppsLayout";
|
||||||
|
|
||||||
function ConnectOrDisconnectIntegrationMenuItem(props: {
|
function ConnectOrDisconnectIntegrationMenuItem(props: {
|
||||||
credentialIds: number[];
|
credentialId: number;
|
||||||
type: App["type"];
|
type: App["type"];
|
||||||
isGlobal?: boolean;
|
isGlobal?: boolean;
|
||||||
installed?: boolean;
|
installed?: boolean;
|
||||||
invalidCredentialIds?: number[];
|
invalidCredentialIds?: number[];
|
||||||
handleDisconnect: (credentialId: number) => void;
|
teamId?: number;
|
||||||
|
handleDisconnect: (credentialId: number, teamId?: number) => void;
|
||||||
}) {
|
}) {
|
||||||
const { type, credentialIds, isGlobal, installed, handleDisconnect } = props;
|
const { type, credentialId, isGlobal, installed, handleDisconnect, teamId } = props;
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const [credentialId] = credentialIds;
|
|
||||||
|
|
||||||
const utils = trpc.useContext();
|
const utils = trpc.useContext();
|
||||||
const handleOpenChange = () => {
|
const handleOpenChange = () => {
|
||||||
@@ -73,7 +74,7 @@ function ConnectOrDisconnectIntegrationMenuItem(props: {
|
|||||||
<DropdownMenuItem>
|
<DropdownMenuItem>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
color="destructive"
|
color="destructive"
|
||||||
onClick={() => handleDisconnect(credentialId)}
|
onClick={() => handleDisconnect(credentialId, teamId)}
|
||||||
disabled={isGlobal}
|
disabled={isGlobal}
|
||||||
StartIcon={Trash}>
|
StartIcon={Trash}>
|
||||||
{t("remove_app")}
|
{t("remove_app")}
|
||||||
@@ -138,72 +139,113 @@ const IntegrationsList = ({ data, handleDisconnect, variant }: IntegrationsListP
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ChildAppCard = ({
|
||||||
|
item,
|
||||||
|
}: {
|
||||||
|
item: RouterOutputs["viewer"]["integrations"]["items"][number] & {
|
||||||
|
credentialOwner?: CredentialOwner;
|
||||||
|
};
|
||||||
|
}) => {
|
||||||
|
const appSlug = item?.slug;
|
||||||
|
const appIsDefault =
|
||||||
|
appSlug === defaultConferencingApp?.appSlug ||
|
||||||
|
(appSlug === "daily-video" && !defaultConferencingApp?.appSlug);
|
||||||
|
return (
|
||||||
|
<AppListCard
|
||||||
|
key={item.name}
|
||||||
|
description={item.description}
|
||||||
|
title={item.name}
|
||||||
|
logo={item.logo}
|
||||||
|
isDefault={appIsDefault}
|
||||||
|
shouldHighlight
|
||||||
|
slug={item.slug}
|
||||||
|
invalidCredential={item?.invalidCredentialIds ? item.invalidCredentialIds.length > 0 : false}
|
||||||
|
credentialOwner={item?.credentialOwner}
|
||||||
|
actions={
|
||||||
|
!item.credentialOwner?.readOnly ? (
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Dropdown modal={false}>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button StartIcon={MoreHorizontal} variant="icon" color="secondary" />
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent>
|
||||||
|
{!appIsDefault && variant === "conferencing" && (
|
||||||
|
<DropdownMenuItem>
|
||||||
|
<DropdownItem
|
||||||
|
type="button"
|
||||||
|
color="secondary"
|
||||||
|
StartIcon={Video}
|
||||||
|
onClick={() => {
|
||||||
|
const locationType = getEventLocationTypeFromApp(item?.locationOption?.value ?? "");
|
||||||
|
if (locationType?.linkType === "static") {
|
||||||
|
setLocationType({ ...locationType, slug: appSlug });
|
||||||
|
} else {
|
||||||
|
updateDefaultAppMutation.mutate({
|
||||||
|
appSlug,
|
||||||
|
});
|
||||||
|
setBulkUpdateModal(true);
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
{t("set_as_default")}
|
||||||
|
</DropdownItem>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<ConnectOrDisconnectIntegrationMenuItem
|
||||||
|
credentialId={item.credentialOwner?.credentialId || item.userCredentialIds[0]}
|
||||||
|
type={item.type}
|
||||||
|
isGlobal={item.isGlobal}
|
||||||
|
installed
|
||||||
|
invalidCredentialIds={item.invalidCredentialIds}
|
||||||
|
handleDisconnect={handleDisconnect}
|
||||||
|
teamId={item.credentialOwner ? item.credentialOwner?.teamId : undefined}
|
||||||
|
/>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
) : null
|
||||||
|
}>
|
||||||
|
<AppSettings slug={item.slug} />
|
||||||
|
</AppListCard>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const appsWithTeamCredentials = data.items.filter((app) => app.teams.length);
|
||||||
|
const cardsForAppsWithTeams = appsWithTeamCredentials.map((app) => {
|
||||||
|
const appCards = [];
|
||||||
|
|
||||||
|
if (app.userCredentialIds.length) {
|
||||||
|
appCards.push(<ChildAppCard item={app} />);
|
||||||
|
}
|
||||||
|
for (const team of app.teams) {
|
||||||
|
if (team) {
|
||||||
|
appCards.push(
|
||||||
|
<ChildAppCard
|
||||||
|
item={{
|
||||||
|
...app,
|
||||||
|
credentialOwner: {
|
||||||
|
name: team.name,
|
||||||
|
avatar: team.logo,
|
||||||
|
teamId: team.teamId,
|
||||||
|
credentialId: team.credentialId,
|
||||||
|
readOnly: !team.isAdmin,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return appCards;
|
||||||
|
});
|
||||||
|
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<List>
|
<List>
|
||||||
|
{cardsForAppsWithTeams.map((apps) => apps.map((cards) => cards))}
|
||||||
{data.items
|
{data.items
|
||||||
.filter((item) => item.invalidCredentialIds)
|
.filter((item) => item.invalidCredentialIds)
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const appSlug = item?.slug;
|
if (!item.teams.length) return <ChildAppCard item={item} />;
|
||||||
const appIsDefault =
|
|
||||||
appSlug === defaultConferencingApp?.appSlug ||
|
|
||||||
(appSlug === "daily-video" && !defaultConferencingApp?.appSlug);
|
|
||||||
return (
|
|
||||||
<AppListCard
|
|
||||||
key={item.name}
|
|
||||||
description={item.description}
|
|
||||||
title={item.name}
|
|
||||||
logo={item.logo}
|
|
||||||
isDefault={appIsDefault}
|
|
||||||
shouldHighlight
|
|
||||||
slug={item.slug}
|
|
||||||
invalidCredential={item.invalidCredentialIds.length > 0}
|
|
||||||
actions={
|
|
||||||
<div className="flex justify-end">
|
|
||||||
<Dropdown modal={false}>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button StartIcon={MoreHorizontal} variant="icon" color="secondary" />
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
|
||||||
{!appIsDefault && variant === "conferencing" && (
|
|
||||||
<DropdownMenuItem>
|
|
||||||
<DropdownItem
|
|
||||||
type="button"
|
|
||||||
color="secondary"
|
|
||||||
StartIcon={Video}
|
|
||||||
onClick={() => {
|
|
||||||
const locationType = getEventLocationTypeFromApp(
|
|
||||||
item?.locationOption?.value ?? ""
|
|
||||||
);
|
|
||||||
if (locationType?.linkType === "static") {
|
|
||||||
setLocationType({ ...locationType, slug: appSlug });
|
|
||||||
} else {
|
|
||||||
updateDefaultAppMutation.mutate({
|
|
||||||
appSlug,
|
|
||||||
});
|
|
||||||
setBulkUpdateModal(true);
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
{t("set_as_default")}
|
|
||||||
</DropdownItem>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
)}
|
|
||||||
<ConnectOrDisconnectIntegrationMenuItem
|
|
||||||
credentialIds={item.credentialIds}
|
|
||||||
type={item.type}
|
|
||||||
isGlobal={item.isGlobal}
|
|
||||||
installed
|
|
||||||
invalidCredentialIds={item.invalidCredentialIds}
|
|
||||||
handleDisconnect={handleDisconnect}
|
|
||||||
/>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</Dropdown>
|
|
||||||
</div>
|
|
||||||
}>
|
|
||||||
<AppSettings slug={item.slug} />
|
|
||||||
</AppListCard>
|
|
||||||
);
|
|
||||||
})}
|
})}
|
||||||
</List>
|
</List>
|
||||||
{locationType && (
|
{locationType && (
|
||||||
@@ -227,7 +269,12 @@ const IntegrationsContainer = ({
|
|||||||
handleDisconnect,
|
handleDisconnect,
|
||||||
}: IntegrationsContainerProps): JSX.Element => {
|
}: IntegrationsContainerProps): JSX.Element => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const query = trpc.viewer.integrations.useQuery({ variant, exclude, onlyInstalled: true });
|
const query = trpc.viewer.integrations.useQuery({
|
||||||
|
variant,
|
||||||
|
exclude,
|
||||||
|
onlyInstalled: true,
|
||||||
|
includeTeamInstalledApps: true,
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: Refactor and reuse getAppCategories?
|
// TODO: Refactor and reuse getAppCategories?
|
||||||
const emptyIcon: Record<AppCategories, LucideIcon> = {
|
const emptyIcon: Record<AppCategories, LucideIcon> = {
|
||||||
@@ -299,6 +346,7 @@ type querySchemaType = z.infer<typeof querySchema>;
|
|||||||
type ModalState = {
|
type ModalState = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
credentialId: null | number;
|
credentialId: null | number;
|
||||||
|
teamId?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function InstalledApps() {
|
export default function InstalledApps() {
|
||||||
@@ -323,8 +371,8 @@ export default function InstalledApps() {
|
|||||||
updateData({ isOpen: false, credentialId: null });
|
updateData({ isOpen: false, credentialId: null });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDisconnect = (credentialId: number) => {
|
const handleDisconnect = (credentialId: number, teamId?: number) => {
|
||||||
updateData({ isOpen: true, credentialId });
|
updateData({ isOpen: true, credentialId, teamId });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -346,6 +394,7 @@ export default function InstalledApps() {
|
|||||||
handleModelClose={handleModelClose}
|
handleModelClose={handleModelClose}
|
||||||
isOpen={data.isOpen}
|
isOpen={data.isOpen}
|
||||||
credentialId={data.credentialId}
|
credentialId={data.credentialId}
|
||||||
|
teamId={data.teamId}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,62 +1,42 @@
|
|||||||
import type { ResetPasswordRequest } from "@prisma/client";
|
|
||||||
import { debounce } from "lodash";
|
|
||||||
import type { GetServerSidePropsContext } from "next";
|
import type { GetServerSidePropsContext } from "next";
|
||||||
import { getCsrfToken } from "next-auth/react";
|
import { getCsrfToken } from "next-auth/react";
|
||||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { CSSProperties } from "react";
|
import type { CSSProperties } from "react";
|
||||||
import React, { useMemo } from "react";
|
import React from "react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
import { Button, TextField } from "@calcom/ui";
|
import { Button, PasswordField, Form } from "@calcom/ui";
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
import AuthContainer from "@components/ui/AuthContainer";
|
import AuthContainer from "@components/ui/AuthContainer";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string;
|
requestId: string;
|
||||||
resetPasswordRequest: ResetPasswordRequest;
|
isRequestExpired: boolean;
|
||||||
csrfToken: string;
|
csrfToken: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Page({ resetPasswordRequest, csrfToken }: Props) {
|
export default function Page({ requestId, isRequestExpired, csrfToken }: Props) {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const [loading, setLoading] = React.useState(false);
|
const formMethods = useForm<{ new_password: string }>();
|
||||||
const [, setError] = React.useState<{ message: string } | null>(null);
|
const success = formMethods.formState.isSubmitSuccessful;
|
||||||
const [success, setSuccess] = React.useState(false);
|
const loading = formMethods.formState.isSubmitting;
|
||||||
|
|
||||||
const [password, setPassword] = React.useState("");
|
|
||||||
|
|
||||||
const submitChangePassword = async ({ password, requestId }: { password: string; requestId: string }) => {
|
const submitChangePassword = async ({ password, requestId }: { password: string; requestId: string }) => {
|
||||||
try {
|
const res = await fetch("/api/auth/reset-password", {
|
||||||
const res = await fetch("/api/auth/reset-password", {
|
method: "POST",
|
||||||
method: "POST",
|
body: JSON.stringify({ requestId, password }),
|
||||||
body: JSON.stringify({ requestId: requestId, password: password }),
|
headers: {
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
"Content-Type": "application/json",
|
},
|
||||||
},
|
});
|
||||||
});
|
const json = await res.json();
|
||||||
|
if (!res.ok) return formMethods.setError("new_password", { type: "server", message: json.message });
|
||||||
const json = await res.json();
|
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
setError(json);
|
|
||||||
} else {
|
|
||||||
setSuccess(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return json;
|
|
||||||
} catch (reason) {
|
|
||||||
setError({ message: t("unexpected_error_try_again") });
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const debouncedChangePassword = debounce(submitChangePassword, 250);
|
|
||||||
|
|
||||||
const Success = () => {
|
const Success = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -95,11 +75,6 @@ export default function Page({ resetPasswordRequest, csrfToken }: Props) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isRequestExpired = useMemo(() => {
|
|
||||||
const now = dayjs();
|
|
||||||
return dayjs(resetPasswordRequest.expires).isBefore(now);
|
|
||||||
}, [resetPasswordRequest]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthContainer
|
<AuthContainer
|
||||||
showLogo
|
showLogo
|
||||||
@@ -109,8 +84,9 @@ export default function Page({ resetPasswordRequest, csrfToken }: Props) {
|
|||||||
{isRequestExpired && <Expired />}
|
{isRequestExpired && <Expired />}
|
||||||
{!isRequestExpired && !success && (
|
{!isRequestExpired && !success && (
|
||||||
<>
|
<>
|
||||||
<form
|
<Form
|
||||||
className="space-y-6"
|
className="space-y-6"
|
||||||
|
form={formMethods}
|
||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
"--cal-brand": "#111827",
|
"--cal-brand": "#111827",
|
||||||
@@ -119,36 +95,26 @@ export default function Page({ resetPasswordRequest, csrfToken }: Props) {
|
|||||||
"--cal-brand-subtle": "#9CA3AF",
|
"--cal-brand-subtle": "#9CA3AF",
|
||||||
} as CSSProperties
|
} as CSSProperties
|
||||||
}
|
}
|
||||||
onSubmit={async (e) => {
|
handleSubmit={async (values) => {
|
||||||
e.preventDefault();
|
await submitChangePassword({
|
||||||
|
password: values.new_password,
|
||||||
if (!password) {
|
requestId,
|
||||||
return;
|
});
|
||||||
}
|
}}>
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(true);
|
|
||||||
setError(null);
|
|
||||||
setSuccess(false);
|
|
||||||
|
|
||||||
await debouncedChangePassword({ password, requestId: resetPasswordRequest.id });
|
|
||||||
}}
|
|
||||||
action="#">
|
|
||||||
<input name="csrfToken" type="hidden" defaultValue={csrfToken} hidden />
|
<input name="csrfToken" type="hidden" defaultValue={csrfToken} hidden />
|
||||||
<div className="mt-1">
|
<div className="mt-1">
|
||||||
<TextField
|
<PasswordField
|
||||||
|
{...formMethods.register("new_password", {
|
||||||
|
minLength: {
|
||||||
|
message: t("password_hint_min"),
|
||||||
|
value: 7, // We don't have user here so we can't check if they are admin or not
|
||||||
|
},
|
||||||
|
pattern: {
|
||||||
|
message: "Should contain a number, uppercase and lowercase letters",
|
||||||
|
value: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).*$/gm,
|
||||||
|
},
|
||||||
|
})}
|
||||||
label={t("new_password")}
|
label={t("new_password")}
|
||||||
onChange={(e) => {
|
|
||||||
setPassword(e.target.value);
|
|
||||||
}}
|
|
||||||
id="password"
|
|
||||||
name="password"
|
|
||||||
type="password"
|
|
||||||
autoComplete="password"
|
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -162,7 +128,7 @@ export default function Page({ resetPasswordRequest, csrfToken }: Props) {
|
|||||||
{t("reset_password")}
|
{t("reset_password")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Form>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!isRequestExpired && success && (
|
{!isRequestExpired && success && (
|
||||||
@@ -179,31 +145,29 @@ Page.PageWrapper = PageWrapper;
|
|||||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
const id = context.params?.id as string;
|
const id = context.params?.id as string;
|
||||||
|
|
||||||
|
let resetPasswordRequest = await prisma.resetPasswordRequest.findFirst({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
expires: {
|
||||||
|
gt: new Date(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
email: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const resetPasswordRequest = await prisma.resetPasswordRequest.findUniqueOrThrow({
|
resetPasswordRequest &&
|
||||||
where: {
|
(await prisma.user.findUniqueOrThrow({ where: { email: resetPasswordRequest.email } }));
|
||||||
id,
|
} catch (e) {
|
||||||
},
|
resetPasswordRequest = null;
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
expires: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
resetPasswordRequest: {
|
|
||||||
...resetPasswordRequest,
|
|
||||||
expires: resetPasswordRequest.expires.toString(),
|
|
||||||
},
|
|
||||||
id,
|
|
||||||
csrfToken: await getCsrfToken({ req: context.req }),
|
|
||||||
...(await serverSideTranslations(context.locale || "en", ["common"])),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} catch (reason) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
isRequestExpired: !resetPasswordRequest,
|
||||||
|
requestId: id,
|
||||||
|
csrfToken: await getCsrfToken({ req: context.req }),
|
||||||
|
...(await serverSideTranslations(context.locale || "en", ["common"])),
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import PageWrapper from "@components/PageWrapper";
|
|||||||
import AuthContainer from "@components/ui/AuthContainer";
|
import AuthContainer from "@components/ui/AuthContainer";
|
||||||
|
|
||||||
export default function ForgotPassword({ csrfToken }: { csrfToken: string }) {
|
export default function ForgotPassword({ csrfToken }: { csrfToken: string }) {
|
||||||
const { t, i18n } = useLocale();
|
const { t } = useLocale();
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
const [error, setError] = React.useState<{ message: string } | null>(null);
|
const [error, setError] = React.useState<{ message: string } | null>(null);
|
||||||
const [success, setSuccess] = React.useState(false);
|
const [success, setSuccess] = React.useState(false);
|
||||||
@@ -31,7 +31,7 @@ export default function ForgotPassword({ csrfToken }: { csrfToken: string }) {
|
|||||||
try {
|
try {
|
||||||
const res = await fetch("/api/auth/forgot-password", {
|
const res = await fetch("/api/auth/forgot-password", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ email: email, language: i18n.language }),
|
body: JSON.stringify({ email }),
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default function Login({
|
|||||||
const errorMessages: { [key: string]: string } = {
|
const errorMessages: { [key: string]: string } = {
|
||||||
// [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"),
|
// [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"),
|
||||||
// Don't leak information about whether an email is registered or not
|
// Don't leak information about whether an email is registered or not
|
||||||
[ErrorCode.IncorrectUsernamePassword]: t("incorrect_username_password"),
|
[ErrorCode.IncorrectEmailPassword]: t("incorrect_email_password"),
|
||||||
[ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`,
|
[ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`,
|
||||||
[ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t("please_try_again_and_contact_us")}`,
|
[ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t("please_try_again_and_contact_us")}`,
|
||||||
[ErrorCode.ThirdPartyIdentityProviderEnabled]: t("account_created_with_identity_provider"),
|
[ErrorCode.ThirdPartyIdentityProviderEnabled]: t("account_created_with_identity_provider"),
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { useState } from "react";
|
|||||||
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import dayjs from "@calcom/dayjs";
|
||||||
import { DateOverrideInputDialog, DateOverrideList } from "@calcom/features/schedules";
|
import { DateOverrideInputDialog, DateOverrideList } from "@calcom/features/schedules";
|
||||||
import Schedule from "@calcom/features/schedules/components/Schedule";
|
import Schedule from "@calcom/features/schedules/components/Schedule";
|
||||||
import Shell from "@calcom/features/shell/Shell";
|
import Shell from "@calcom/features/shell/Shell";
|
||||||
import { availabilityAsString } from "@calcom/lib/availability";
|
import { availabilityAsString } from "@calcom/lib/availability";
|
||||||
import { yyyymmdd } from "@calcom/lib/date-fns";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
||||||
import { HttpError } from "@calcom/lib/http-error";
|
import { HttpError } from "@calcom/lib/http-error";
|
||||||
@@ -53,9 +53,10 @@ type AvailabilityFormValues = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DateOverride = ({ workingHours }: { workingHours: WorkingHours[] }) => {
|
const DateOverride = ({ workingHours }: { workingHours: WorkingHours[] }) => {
|
||||||
const { remove, append, update, fields } = useFieldArray<AvailabilityFormValues, "dateOverrides">({
|
const { remove, append, replace, fields } = useFieldArray<AvailabilityFormValues, "dateOverrides">({
|
||||||
name: "dateOverrides",
|
name: "dateOverrides",
|
||||||
});
|
});
|
||||||
|
const excludedDates = fields.map((field) => dayjs(field.ranges[0].start).utc().format("YYYY-MM-DD"));
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
return (
|
return (
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
@@ -70,15 +71,15 @@ const DateOverride = ({ workingHours }: { workingHours: WorkingHours[] }) => {
|
|||||||
<p className="text-subtle mb-4 text-sm">{t("date_overrides_subtitle")}</p>
|
<p className="text-subtle mb-4 text-sm">{t("date_overrides_subtitle")}</p>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<DateOverrideList
|
<DateOverrideList
|
||||||
excludedDates={fields.map((field) => yyyymmdd(field.ranges[0].start))}
|
excludedDates={excludedDates}
|
||||||
remove={remove}
|
remove={remove}
|
||||||
update={update}
|
replace={replace}
|
||||||
items={fields}
|
items={fields}
|
||||||
workingHours={workingHours}
|
workingHours={workingHours}
|
||||||
/>
|
/>
|
||||||
<DateOverrideInputDialog
|
<DateOverrideInputDialog
|
||||||
workingHours={workingHours}
|
workingHours={workingHours}
|
||||||
excludedDates={fields.map((field) => yyyymmdd(field.ranges[0].start))}
|
excludedDates={excludedDates}
|
||||||
onChange={(ranges) => append({ ranges })}
|
onChange={(ranges) => append({ ranges })}
|
||||||
Trigger={
|
Trigger={
|
||||||
<Button color="secondary" StartIcon={Plus} data-testid="add-override">
|
<Button color="secondary" StartIcon={Plus} data-testid="add-override">
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export function AvailabilityList({ schedules }: RouterOutputs["viewer"]["availab
|
|||||||
Icon={Clock}
|
Icon={Clock}
|
||||||
headline={t("new_schedule_heading")}
|
headline={t("new_schedule_heading")}
|
||||||
description={t("new_schedule_description")}
|
description={t("new_schedule_description")}
|
||||||
|
className="w-full"
|
||||||
buttonRaw={<NewScheduleButton />}
|
buttonRaw={<NewScheduleButton />}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export default function Success(props: SuccessProps) {
|
|||||||
// - It's a paid event and payment is pending.
|
// - It's a paid event and payment is pending.
|
||||||
const needsConfirmation = bookingInfo.status === BookingStatus.PENDING && eventType.requiresConfirmation;
|
const needsConfirmation = bookingInfo.status === BookingStatus.PENDING && eventType.requiresConfirmation;
|
||||||
const userIsOwner = !!(session?.user?.id && eventType.owner?.id === session.user.id);
|
const userIsOwner = !!(session?.user?.id && eventType.owner?.id === session.user.id);
|
||||||
|
const isLoggedIn = session?.user;
|
||||||
const isCancelled =
|
const isCancelled =
|
||||||
status === "CANCELLED" ||
|
status === "CANCELLED" ||
|
||||||
status === "REJECTED" ||
|
status === "REJECTED" ||
|
||||||
@@ -278,7 +278,7 @@ export default function Success(props: SuccessProps) {
|
|||||||
|
|
||||||
// This is a weird case where the same route can be opened in booking flow as a success page or as a booking detail page from the app
|
// This is a weird case where the same route can be opened in booking flow as a success page or as a booking detail page from the app
|
||||||
// As Booking Page it has to support configured theme, but as booking detail page it should not do any change. Let Shell.tsx handle it.
|
// As Booking Page it has to support configured theme, but as booking detail page it should not do any change. Let Shell.tsx handle it.
|
||||||
useTheme(isSuccessBookingPage ? props.profile.theme : undefined);
|
useTheme(isSuccessBookingPage ? props.profile.theme : "system");
|
||||||
useBrandColors({
|
useBrandColors({
|
||||||
brandColor: props.profile.brandColor,
|
brandColor: props.profile.brandColor,
|
||||||
darkBrandColor: props.profile.darkBrandColor,
|
darkBrandColor: props.profile.darkBrandColor,
|
||||||
@@ -310,7 +310,7 @@ export default function Success(props: SuccessProps) {
|
|||||||
status={status}
|
status={status}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{userIsOwner && !isEmbed && (
|
{isLoggedIn && !isEmbed && (
|
||||||
<div className="-mb-4 ml-4 mt-2">
|
<div className="-mb-4 ml-4 mt-2">
|
||||||
<Link
|
<Link
|
||||||
href={allRemainingBookings ? "/bookings/recurring" : "/bookings/upcoming"}
|
href={allRemainingBookings ? "/bookings/recurring" : "/bookings/upcoming"}
|
||||||
|
|||||||
@@ -1,42 +1,54 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
import type { GetServerSidePropsContext } from "next";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { LocationObject } from "@calcom/core/location";
|
import { Booker } from "@calcom/atoms";
|
||||||
import { privacyFilteredLocations } from "@calcom/core/location";
|
import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
|
||||||
|
import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking";
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||||
import { parseRecurringEvent } from "@calcom/lib";
|
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { getWorkingHours } from "@calcom/lib/availability";
|
import slugify from "@calcom/lib/slugify";
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
|
||||||
import { availiblityPageEventTypeSelect } from "@calcom/prisma";
|
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
|
||||||
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||||
import type { EmbedProps } from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
import AvailabilityPage from "@components/booking/pages/AvailabilityPage";
|
|
||||||
|
|
||||||
import { ssrInit } from "@server/lib/ssr";
|
type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||||
|
|
||||||
export type DynamicAvailabilityPageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
|
export default function Type({ slug, user, booking, away, isBrandingHidden, isTeamEvent, org }: PageProps) {
|
||||||
|
return (
|
||||||
export default function Type(props: DynamicAvailabilityPageProps) {
|
<main className="flex h-full min-h-[100dvh] items-center justify-center">
|
||||||
return <AvailabilityPage {...props} />;
|
<BookerSeo
|
||||||
|
username={user}
|
||||||
|
eventSlug={slug}
|
||||||
|
rescheduleUid={booking?.uid}
|
||||||
|
hideBranding={isBrandingHidden}
|
||||||
|
org={org}
|
||||||
|
/>
|
||||||
|
<Booker
|
||||||
|
username={user}
|
||||||
|
eventSlug={slug}
|
||||||
|
bookingData={booking}
|
||||||
|
isAway={away}
|
||||||
|
hideBranding={isBrandingHidden}
|
||||||
|
isTeamEvent={isTeamEvent}
|
||||||
|
org={org}
|
||||||
|
/>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type.isBookingPage = true;
|
|
||||||
Type.PageWrapper = PageWrapper;
|
Type.PageWrapper = PageWrapper;
|
||||||
|
Type.isBookingPage = true;
|
||||||
|
|
||||||
const querySchema = z.object({
|
async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||||
link: z.string().optional().default(""),
|
const { link, slug } = paramsSchema.parse(context.params);
|
||||||
slug: z.string().optional().default(""),
|
const { rescheduleUid } = context.query;
|
||||||
date: z.union([z.string(), z.null()]).optional().default(null),
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||||
});
|
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||||
|
|
||||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
const { ssrInit } = await import("@server/lib/ssr");
|
||||||
const ssr = await ssrInit(context);
|
const ssr = await ssrInit(context);
|
||||||
const { link, slug, date } = querySchema.parse(context.query);
|
|
||||||
|
|
||||||
const hashedLink = await prisma.hashedLink.findUnique({
|
const hashedLink = await prisma.hashedLink.findUnique({
|
||||||
where: {
|
where: {
|
||||||
@@ -45,132 +57,88 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
select: {
|
select: {
|
||||||
eventTypeId: true,
|
eventTypeId: true,
|
||||||
eventType: {
|
eventType: {
|
||||||
select: availiblityPageEventTypeSelect,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const userId = hashedLink?.eventType.userId || hashedLink?.eventType.users[0]?.id;
|
|
||||||
if (!userId)
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
} as {
|
|
||||||
notFound: true;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (hashedLink?.eventType.slug !== slug)
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
} as {
|
|
||||||
notFound: true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const users = await prisma.user.findMany({
|
|
||||||
where: {
|
|
||||||
id: userId,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
bio: true,
|
|
||||||
avatar: true,
|
|
||||||
startTime: true,
|
|
||||||
endTime: true,
|
|
||||||
timeZone: true,
|
|
||||||
weekStart: true,
|
|
||||||
availability: true,
|
|
||||||
hideBranding: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
defaultScheduleId: true,
|
|
||||||
allowDynamicBooking: true,
|
|
||||||
away: true,
|
|
||||||
schedules: {
|
|
||||||
select: {
|
select: {
|
||||||
availability: true,
|
users: {
|
||||||
timeZone: true,
|
select: {
|
||||||
id: true,
|
username: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
team: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
theme: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!users || !users.length) {
|
const username = hashedLink?.eventType.users[0]?.username;
|
||||||
|
|
||||||
|
if (!hashedLink || !username) {
|
||||||
return {
|
return {
|
||||||
notFound: true,
|
notFound: true,
|
||||||
} as {
|
|
||||||
notFound: true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const locations = hashedLink.eventType.locations
|
const user = await prisma.user.findFirst({
|
||||||
? (hashedLink.eventType.locations as LocationObject[])
|
where: {
|
||||||
: [];
|
username,
|
||||||
|
organization: isValidOrgDomain
|
||||||
const eventTypeObject = Object.assign({}, hashedLink.eventType, {
|
? {
|
||||||
metadata: EventTypeMetaDataSchema.parse(hashedLink.eventType.metadata || {}),
|
slug: currentOrgDomain,
|
||||||
recurringEvent: parseRecurringEvent(hashedLink.eventType.recurringEvent),
|
}
|
||||||
periodStartDate: hashedLink.eventType.periodStartDate?.toString() ?? null,
|
: null,
|
||||||
periodEndDate: hashedLink.eventType.periodEndDate?.toString() ?? null,
|
},
|
||||||
slug,
|
select: {
|
||||||
locations: privacyFilteredLocations(locations),
|
away: true,
|
||||||
users: users.map((u) => ({
|
hideBranding: true,
|
||||||
name: u.name,
|
},
|
||||||
username: u.username,
|
|
||||||
hideBranding: u.hideBranding,
|
|
||||||
timeZone: u.timeZone,
|
|
||||||
})),
|
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(hashedLink.eventType.description),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [user] = users;
|
if (!user) {
|
||||||
|
return {
|
||||||
|
notFound: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const schedule = {
|
let booking: GetBookingType | null = null;
|
||||||
...user.schedules.filter(
|
if (rescheduleUid) {
|
||||||
(schedule) => !user.defaultScheduleId || schedule.id === user.defaultScheduleId
|
booking = await getBookingForReschedule(`${rescheduleUid}`);
|
||||||
)[0],
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const timeZone = schedule.timeZone || user.timeZone;
|
const isTeamEvent = !!hashedLink.eventType?.team?.id;
|
||||||
|
|
||||||
const workingHours = getWorkingHours(
|
// We use this to both prefetch the query on the server,
|
||||||
{
|
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
||||||
timeZone,
|
const eventData = await ssr.viewer.public.event.fetch({ username, eventSlug: slug, isTeamEvent, org });
|
||||||
},
|
|
||||||
schedule.availability || user.availability
|
|
||||||
);
|
|
||||||
eventTypeObject.schedule = null;
|
|
||||||
eventTypeObject.availability = [];
|
|
||||||
|
|
||||||
const booking: GetBookingType | null = null;
|
if (!eventData) {
|
||||||
|
return {
|
||||||
const profile = {
|
notFound: true,
|
||||||
name: user.name || user.username,
|
};
|
||||||
image: user.avatar,
|
}
|
||||||
slug: user.username,
|
|
||||||
theme: user.theme,
|
|
||||||
weekStart: user.weekStart,
|
|
||||||
brandColor: user.brandColor,
|
|
||||||
darkBrandColor: user.darkBrandColor,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
away: user.away,
|
org,
|
||||||
themeBasis: user.username,
|
|
||||||
isDynamicGroup: false,
|
|
||||||
profile,
|
|
||||||
date,
|
|
||||||
eventType: eventTypeObject,
|
|
||||||
workingHours,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
previousPage: context.req.headers.referer ?? null,
|
|
||||||
booking,
|
booking,
|
||||||
users: [user.username],
|
away: user?.away,
|
||||||
isBrandingHidden: user.hideBranding,
|
user: username,
|
||||||
|
slug,
|
||||||
|
trpcState: ssr.dehydrate(),
|
||||||
|
isBrandingHidden: user?.hideBranding,
|
||||||
|
// Sending the team event from the server, because this template file
|
||||||
|
// is reused for both team and user events.
|
||||||
|
isTeamEvent,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const paramsSchema = z.object({ link: z.string(), slug: z.string().transform((s) => slugify(s)) });
|
||||||
|
|
||||||
|
// Booker page fetches a tiny bit of data server side, to determine early
|
||||||
|
// whether the page should show an away state or dynamic booking not allowed.
|
||||||
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||||
|
return await getUserPageProps(context);
|
||||||
};
|
};
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import withEmbedSsr from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import { getServerSideProps as _getServerSideProps } from "../[slug]";
|
|
||||||
|
|
||||||
export { default } from "../[slug]";
|
|
||||||
|
|
||||||
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
|
||||||
|
|
||||||
import { parseRecurringEvent } from "@calcom/lib";
|
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
|
||||||
import prisma from "@calcom/prisma";
|
|
||||||
import { bookEventTypeSelect } from "@calcom/prisma/selects";
|
|
||||||
import { customInputSchema, eventTypeBookingFields, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
|
||||||
|
|
||||||
import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
|
||||||
import BookingPage from "@components/booking/pages/BookingPage";
|
|
||||||
|
|
||||||
import { ssrInit } from "@server/lib/ssr";
|
|
||||||
|
|
||||||
export type HashLinkPageProps = inferSSRProps<typeof getServerSideProps>;
|
|
||||||
|
|
||||||
export default function Book(props: HashLinkPageProps) {
|
|
||||||
return <BookingPage {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
Book.isBookingPage = true;
|
|
||||||
Book.PageWrapper = PageWrapper;
|
|
||||||
|
|
||||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
const link = asStringOrThrow(context.query.link as string);
|
|
||||||
const recurringEventCountQuery = asStringOrNull(context.query.count);
|
|
||||||
|
|
||||||
const hashedLink = await prisma.hashedLink.findUnique({
|
|
||||||
where: {
|
|
||||||
link,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
eventTypeId: true,
|
|
||||||
eventType: {
|
|
||||||
select: bookEventTypeSelect,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const userId = hashedLink?.eventType.userId || hashedLink?.eventType.users[0]?.id;
|
|
||||||
|
|
||||||
if (!userId)
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const users = await prisma.user.findMany({
|
|
||||||
where: {
|
|
||||||
id: userId,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
bio: true,
|
|
||||||
avatar: true,
|
|
||||||
theme: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
allowDynamicBooking: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!users.length) return { notFound: true };
|
|
||||||
const [user] = users;
|
|
||||||
const eventTypeRaw = hashedLink?.eventType;
|
|
||||||
|
|
||||||
if (!eventTypeRaw) return { notFound: true };
|
|
||||||
const eventType = {
|
|
||||||
...eventTypeRaw,
|
|
||||||
metadata: EventTypeMetaDataSchema.parse(eventTypeRaw.metadata || {}),
|
|
||||||
recurringEvent: parseRecurringEvent(eventTypeRaw.recurringEvent),
|
|
||||||
bookingFields: eventTypeBookingFields.parse(eventTypeRaw.bookingFields || []),
|
|
||||||
};
|
|
||||||
|
|
||||||
const eventTypeObject = [eventType].map((e) => {
|
|
||||||
return {
|
|
||||||
...e,
|
|
||||||
periodStartDate: e.periodStartDate?.toString() ?? null,
|
|
||||||
periodEndDate: e.periodEndDate?.toString() ?? null,
|
|
||||||
customInputs: customInputSchema.array().parse(e.customInputs || []),
|
|
||||||
schedulingType: null,
|
|
||||||
users: users.map((u) => ({
|
|
||||||
id: u.id,
|
|
||||||
name: u.name,
|
|
||||||
username: u.username,
|
|
||||||
avatar: u.avatar,
|
|
||||||
image: u.avatar,
|
|
||||||
slug: u.username,
|
|
||||||
theme: u.theme,
|
|
||||||
email: u.email,
|
|
||||||
brandColor: u.brandColor,
|
|
||||||
darkBrandColor: u.darkBrandColor,
|
|
||||||
})),
|
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
|
||||||
};
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
const profile = {
|
|
||||||
name: user.name || user.username,
|
|
||||||
image: user.avatar,
|
|
||||||
slug: user.username,
|
|
||||||
theme: user.theme,
|
|
||||||
brandColor: user.brandColor,
|
|
||||||
darkBrandColor: user.darkBrandColor,
|
|
||||||
eventName: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Checking if number of recurring event ocurrances is valid against event type configuration
|
|
||||||
const recurringEventCount =
|
|
||||||
(eventTypeObject.recurringEvent?.count &&
|
|
||||||
recurringEventCountQuery &&
|
|
||||||
(parseInt(recurringEventCountQuery) <= eventTypeObject.recurringEvent.count
|
|
||||||
? parseInt(recurringEventCountQuery)
|
|
||||||
: eventType.recurringEvent?.count)) ||
|
|
||||||
null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
profile,
|
|
||||||
themeBasis: user.username,
|
|
||||||
eventType: eventTypeObject,
|
|
||||||
booking: null,
|
|
||||||
currentSlotBooking: null,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
recurringEventCount,
|
|
||||||
isDynamicGroupBooking: false,
|
|
||||||
hasHashedBookingLink: true,
|
|
||||||
hashedLink: link,
|
|
||||||
isEmbed: typeof context.query.embed === "string",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -101,6 +101,7 @@ export type FormValues = {
|
|||||||
displayLocationPublicly?: boolean;
|
displayLocationPublicly?: boolean;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
hostDefault?: string;
|
hostDefault?: string;
|
||||||
|
credentialId?: number;
|
||||||
}[];
|
}[];
|
||||||
customInputs: CustomInputParsed[];
|
customInputs: CustomInputParsed[];
|
||||||
schedule: number | null;
|
schedule: number | null;
|
||||||
@@ -161,8 +162,10 @@ const EventTypePage = (props: EventTypeSetupProps) => {
|
|||||||
data: { tabName },
|
data: { tabName },
|
||||||
} = useTypedQuery(querySchema);
|
} = useTypedQuery(querySchema);
|
||||||
|
|
||||||
const { data: eventTypeApps } = trpc.viewer.apps.useQuery({
|
const { data: eventTypeApps } = trpc.viewer.integrations.useQuery({
|
||||||
extendsFeature: "EventType",
|
extendsFeature: "EventType",
|
||||||
|
teamId: props.eventType.team?.id || props.eventType.parent?.teamId,
|
||||||
|
onlyInstalled: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { eventType, locationOptions, team, teamMembers, currentUserMembership, destinationCalendar } = props;
|
const { eventType, locationOptions, team, teamMembers, currentUserMembership, destinationCalendar } = props;
|
||||||
@@ -306,12 +309,12 @@ const EventTypePage = (props: EventTypeSetupProps) => {
|
|||||||
|
|
||||||
const appsMetadata = formMethods.getValues("metadata")?.apps;
|
const appsMetadata = formMethods.getValues("metadata")?.apps;
|
||||||
const availability = formMethods.watch("availability");
|
const availability = formMethods.watch("availability");
|
||||||
const numberOfInstalledApps = eventTypeApps?.filter((app) => app.isInstalled).length || 0;
|
|
||||||
let numberOfActiveApps = 0;
|
let numberOfActiveApps = 0;
|
||||||
|
|
||||||
if (appsMetadata) {
|
if (appsMetadata) {
|
||||||
numberOfActiveApps = Object.entries(appsMetadata).filter(
|
numberOfActiveApps = Object.entries(appsMetadata).filter(
|
||||||
([appId, appData]) => eventTypeApps?.find((app) => app.slug === appId)?.isInstalled && appData.enabled
|
([appId, appData]) =>
|
||||||
|
eventTypeApps?.items.find((app) => app.slug === appId)?.isInstalled && appData.enabled
|
||||||
).length;
|
).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +426,7 @@ const EventTypePage = (props: EventTypeSetupProps) => {
|
|||||||
<>
|
<>
|
||||||
<EventTypeSingleLayout
|
<EventTypeSingleLayout
|
||||||
enabledAppsNumber={numberOfActiveApps}
|
enabledAppsNumber={numberOfActiveApps}
|
||||||
installedAppsNumber={numberOfInstalledApps}
|
installedAppsNumber={eventTypeApps?.items.length || 0}
|
||||||
enabledWorkflowsNumber={eventType.workflows.length}
|
enabledWorkflowsNumber={eventType.workflows.length}
|
||||||
eventType={eventType}
|
eventType={eventType}
|
||||||
team={team}
|
team={team}
|
||||||
@@ -500,7 +503,7 @@ const EventTypePage = (props: EventTypeSetupProps) => {
|
|||||||
</Form>
|
</Form>
|
||||||
</EventTypeSingleLayout>
|
</EventTypeSingleLayout>
|
||||||
|
|
||||||
{slugExistsChildrenDialogOpen.length && (
|
{slugExistsChildrenDialogOpen.length ? (
|
||||||
<ManagedEventTypeDialog
|
<ManagedEventTypeDialog
|
||||||
slugExistsChildrenDialogOpen={slugExistsChildrenDialogOpen}
|
slugExistsChildrenDialogOpen={slugExistsChildrenDialogOpen}
|
||||||
isLoading={formMethods.formState.isSubmitting}
|
isLoading={formMethods.formState.isSubmitting}
|
||||||
@@ -515,7 +518,7 @@ const EventTypePage = (props: EventTypeSetupProps) => {
|
|||||||
setSlugExistsChildrenDialogOpen([]);
|
setSlugExistsChildrenDialogOpen([]);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
) : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -103,11 +103,11 @@ const querySchema = z.object({
|
|||||||
|
|
||||||
const MobileTeamsTab: FC<MobileTeamsTabProps> = (props) => {
|
const MobileTeamsTab: FC<MobileTeamsTabProps> = (props) => {
|
||||||
const { eventTypeGroups } = props;
|
const { eventTypeGroups } = props;
|
||||||
|
const orgBranding = useOrgBrandingValues();
|
||||||
const tabs = eventTypeGroups.map((item) => ({
|
const tabs = eventTypeGroups.map((item) => ({
|
||||||
name: item.profile.name ?? "",
|
name: item.profile.name ?? "",
|
||||||
href: item.teamId ? `/event-types?teamId=${item.teamId}` : "/event-types",
|
href: item.teamId ? `/event-types?teamId=${item.teamId}` : "/event-types",
|
||||||
avatar: item.profile.image ?? `${WEBAPP_URL}/${item.profile.slug}/avatar.png`,
|
avatar: item.profile.image ?? `${orgBranding?.fullDomain ?? WEBAPP_URL}/${item.profile.slug}/avatar.png`,
|
||||||
}));
|
}));
|
||||||
const { data } = useTypedQuery(querySchema);
|
const { data } = useTypedQuery(querySchema);
|
||||||
const events = eventTypeGroups.filter((item) => item.teamId === data.teamId);
|
const events = eventTypeGroups.filter((item) => item.teamId === data.teamId);
|
||||||
@@ -404,7 +404,9 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
|
|||||||
items={type.users.map(
|
items={type.users.map(
|
||||||
(organizer: { name: string | null; username: string | null }) => ({
|
(organizer: { name: string | null; username: string | null }) => ({
|
||||||
alt: organizer.name || "",
|
alt: organizer.name || "",
|
||||||
image: `${WEBAPP_URL}/${organizer.username}/avatar.png`,
|
image: `${orgBranding?.fullDomain ?? WEBAPP_URL}/${
|
||||||
|
organizer.username
|
||||||
|
}/avatar.png`,
|
||||||
title: organizer.name || "",
|
title: organizer.name || "",
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
@@ -419,7 +421,7 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
|
|||||||
.flatMap((ch) => ch.users)
|
.flatMap((ch) => ch.users)
|
||||||
.map((user: Pick<User, "name" | "username">) => ({
|
.map((user: Pick<User, "name" | "username">) => ({
|
||||||
alt: user.name || "",
|
alt: user.name || "",
|
||||||
image: `${WEBAPP_URL}/${user.username}/avatar.png`,
|
image: `${orgBranding?.fullDomain ?? WEBAPP_URL}/${user.username}/avatar.png`,
|
||||||
title: user.name || "",
|
title: user.name || "",
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
@@ -714,7 +716,10 @@ const EventTypeListHeading = ({
|
|||||||
<Avatar
|
<Avatar
|
||||||
alt={profile?.name || ""}
|
alt={profile?.name || ""}
|
||||||
href={teamId ? `/settings/teams/${teamId}/profile` : "/settings/my-account/profile"}
|
href={teamId ? `/settings/teams/${teamId}/profile` : "/settings/my-account/profile"}
|
||||||
imageSrc={`${WEBAPP_URL}/${profile.slug}/avatar.png` || undefined}
|
imageSrc={
|
||||||
|
`${orgBranding?.fullDomain ?? WEBAPP_URL}/${teamId ? "team/" : ""}${profile.slug}/avatar.png` ||
|
||||||
|
undefined
|
||||||
|
}
|
||||||
size="md"
|
size="md"
|
||||||
className="mt-1 inline-flex justify-center"
|
className="mt-1 inline-flex justify-center"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { Booker } from "@calcom/atoms";
|
|
||||||
import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
|
|
||||||
import { getBookingByUidOrRescheduleUid } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
|
||||||
import { classNames } from "@calcom/lib";
|
|
||||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
|
||||||
import slugify from "@calcom/lib/slugify";
|
|
||||||
import prisma from "@calcom/prisma";
|
|
||||||
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
|
||||||
|
|
||||||
type PageProps = inferSSRProps<typeof getServerSideProps>;
|
|
||||||
|
|
||||||
export default function Type({ slug, user, booking, away, isBrandingHidden }: PageProps) {
|
|
||||||
const isEmbed = typeof window !== "undefined" && window?.isEmbed?.();
|
|
||||||
return (
|
|
||||||
<main className={classNames("flex h-full items-center justify-center", !isEmbed && "min-h-[100dvh]")}>
|
|
||||||
<BookerSeo
|
|
||||||
username={user}
|
|
||||||
eventSlug={slug}
|
|
||||||
rescheduleUid={booking?.uid}
|
|
||||||
hideBranding={isBrandingHidden}
|
|
||||||
/>
|
|
||||||
<Booker
|
|
||||||
username={user}
|
|
||||||
eventSlug={slug}
|
|
||||||
rescheduleBooking={booking}
|
|
||||||
isAway={away}
|
|
||||||
hideBranding={isBrandingHidden}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Type.PageWrapper = PageWrapper;
|
|
||||||
|
|
||||||
async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
|
||||||
const { user: usernames, type: slug } = paramsSchema.parse(context.params);
|
|
||||||
const { rescheduleUid } = context.query;
|
|
||||||
|
|
||||||
const { ssrInit } = await import("@server/lib/ssr");
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
|
|
||||||
const users = await prisma.user.findMany({
|
|
||||||
where: {
|
|
||||||
username: {
|
|
||||||
in: usernames,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
allowDynamicBooking: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!users.length) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
|
||||||
if (rescheduleUid) {
|
|
||||||
booking = await getBookingByUidOrRescheduleUid(`${rescheduleUid}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use this to both prefetch the query on the server,
|
|
||||||
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
|
||||||
const eventData = await ssr.viewer.public.event.fetch({ username: usernames.join("+"), eventSlug: slug });
|
|
||||||
|
|
||||||
if (!eventData) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
booking,
|
|
||||||
user: usernames.join("+"),
|
|
||||||
slug,
|
|
||||||
away: false,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
isBrandingHidden: false,
|
|
||||||
themeBasis: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getUserPageProps(context: GetServerSidePropsContext) {
|
|
||||||
const { user: usernames, type: slug } = paramsSchema.parse(context.params);
|
|
||||||
const username = usernames[0];
|
|
||||||
const { rescheduleUid } = context.query;
|
|
||||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
|
||||||
|
|
||||||
const { ssrInit } = await import("@server/lib/ssr");
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
const user = await prisma.user.findFirst({
|
|
||||||
where: {
|
|
||||||
username,
|
|
||||||
organization: isValidOrgDomain
|
|
||||||
? {
|
|
||||||
slug: currentOrgDomain,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
away: true,
|
|
||||||
hideBranding: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
|
||||||
if (rescheduleUid) {
|
|
||||||
booking = await getBookingByUidOrRescheduleUid(`${rescheduleUid}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use this to both prefetch the query on the server,
|
|
||||||
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
|
||||||
const eventData = await ssr.viewer.public.event.fetch({ username, eventSlug: slug });
|
|
||||||
|
|
||||||
if (!eventData) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
booking,
|
|
||||||
away: user?.away,
|
|
||||||
user: username,
|
|
||||||
slug,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
isBrandingHidden: user?.hideBranding,
|
|
||||||
themeBasis: username,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const paramsSchema = z.object({
|
|
||||||
type: z.string().transform((s) => slugify(s)),
|
|
||||||
user: z.string().transform((s) => getUsernameList(s)),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Booker page fetches a tiny bit of data server side, to determine early
|
|
||||||
// whether the page should show an away state or dynamic booking not allowed.
|
|
||||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
||||||
const { user } = paramsSchema.parse(context.params);
|
|
||||||
const isDynamicGroup = user.length > 1;
|
|
||||||
|
|
||||||
return isDynamicGroup ? await getDynamicGroupPageProps(context) : await getUserPageProps(context);
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import withEmbedSsr from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import { getServerSideProps as _getServerSideProps } from "../[type]";
|
|
||||||
|
|
||||||
export { default } from "../[type]";
|
|
||||||
|
|
||||||
// Somehow these types don't accept the {notFound: true} return type.
|
|
||||||
// Probably still need to fix this. I don't know why this isn't allowed yet.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import withEmbedSsr from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import { getServerSideProps as _getServerSideProps } from "../../[user]";
|
|
||||||
|
|
||||||
export { default } from "../../[user]";
|
|
||||||
|
|
||||||
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { Booker } from "@calcom/atoms";
|
|
||||||
import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
|
|
||||||
import { getBookingByUidOrRescheduleUid } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
|
||||||
import slugify from "@calcom/lib/slugify";
|
|
||||||
import prisma from "@calcom/prisma";
|
|
||||||
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
|
||||||
|
|
||||||
type PageProps = inferSSRProps<typeof getServerSideProps>;
|
|
||||||
|
|
||||||
export default function Type({ slug, user, booking, away, isBrandingHidden, isTeamEvent }: PageProps) {
|
|
||||||
return (
|
|
||||||
<main className="flex h-full min-h-[100dvh] items-center justify-center">
|
|
||||||
<BookerSeo
|
|
||||||
username={user}
|
|
||||||
eventSlug={slug}
|
|
||||||
rescheduleUid={booking?.uid}
|
|
||||||
hideBranding={isBrandingHidden}
|
|
||||||
/>
|
|
||||||
<Booker
|
|
||||||
username={user}
|
|
||||||
eventSlug={slug}
|
|
||||||
rescheduleBooking={booking}
|
|
||||||
isAway={away}
|
|
||||||
hideBranding={isBrandingHidden}
|
|
||||||
isTeamEvent={isTeamEvent}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Type.PageWrapper = PageWrapper;
|
|
||||||
|
|
||||||
async function getUserPageProps(context: GetServerSidePropsContext) {
|
|
||||||
const { link, slug } = paramsSchema.parse(context.params);
|
|
||||||
const { rescheduleUid } = context.query;
|
|
||||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
|
||||||
|
|
||||||
const { ssrInit } = await import("@server/lib/ssr");
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
|
|
||||||
const hashedLink = await prisma.hashedLink.findUnique({
|
|
||||||
where: {
|
|
||||||
link,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
eventTypeId: true,
|
|
||||||
eventType: {
|
|
||||||
select: {
|
|
||||||
users: {
|
|
||||||
select: {
|
|
||||||
username: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
team: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const username = hashedLink?.eventType.users[0]?.username;
|
|
||||||
|
|
||||||
if (!hashedLink || !username) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
|
||||||
where: {
|
|
||||||
username,
|
|
||||||
organization: isValidOrgDomain
|
|
||||||
? {
|
|
||||||
slug: currentOrgDomain,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
away: true,
|
|
||||||
hideBranding: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
|
||||||
if (rescheduleUid) {
|
|
||||||
booking = await getBookingByUidOrRescheduleUid(`${rescheduleUid}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isTeamEvent = !!hashedLink.eventType?.team?.id;
|
|
||||||
|
|
||||||
// We use this to both prefetch the query on the server,
|
|
||||||
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
|
||||||
const eventData = await ssr.viewer.public.event.fetch({ username, eventSlug: slug, isTeamEvent });
|
|
||||||
|
|
||||||
if (!eventData) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
booking,
|
|
||||||
away: user?.away,
|
|
||||||
user: username,
|
|
||||||
slug,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
isBrandingHidden: user?.hideBranding,
|
|
||||||
// Sending the team event from the server, because this template file
|
|
||||||
// is reused for both team and user events.
|
|
||||||
isTeamEvent,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const paramsSchema = z.object({ link: z.string(), slug: z.string().transform((s) => slugify(s)) });
|
|
||||||
|
|
||||||
// Booker page fetches a tiny bit of data server side, to determine early
|
|
||||||
// whether the page should show an away state or dynamic booking not allowed.
|
|
||||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
||||||
return await getUserPageProps(context);
|
|
||||||
};
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { Booker } from "@calcom/atoms";
|
|
||||||
import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
|
|
||||||
import { getBookingByUidOrRescheduleUid } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import { classNames } from "@calcom/lib";
|
|
||||||
import slugify from "@calcom/lib/slugify";
|
|
||||||
import prisma from "@calcom/prisma";
|
|
||||||
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
|
||||||
|
|
||||||
type PageProps = inferSSRProps<typeof getServerSideProps>;
|
|
||||||
|
|
||||||
export default function Type({ slug, user, booking, away, isBrandingHidden }: PageProps) {
|
|
||||||
const isEmbed = typeof window !== "undefined" && window?.isEmbed?.();
|
|
||||||
return (
|
|
||||||
<main className={classNames("flex h-full items-center justify-center", !isEmbed && "min-h-[100dvh]")}>
|
|
||||||
<BookerSeo
|
|
||||||
username={user}
|
|
||||||
eventSlug={slug}
|
|
||||||
rescheduleUid={booking?.uid}
|
|
||||||
hideBranding={isBrandingHidden}
|
|
||||||
isTeamEvent
|
|
||||||
/>
|
|
||||||
<Booker
|
|
||||||
username={user}
|
|
||||||
eventSlug={slug}
|
|
||||||
rescheduleBooking={booking}
|
|
||||||
isAway={away}
|
|
||||||
hideBranding={isBrandingHidden}
|
|
||||||
isTeamEvent
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Type.PageWrapper = PageWrapper;
|
|
||||||
|
|
||||||
const paramsSchema = z.object({
|
|
||||||
type: z.string().transform((s) => slugify(s)),
|
|
||||||
slug: z.string().transform((s) => slugify(s)),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Booker page fetches a tiny bit of data server side:
|
|
||||||
// 1. Check if team exists, to show 404
|
|
||||||
// 2. If rescheduling, get the booking details
|
|
||||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
||||||
const { slug: teamSlug, type: meetingSlug } = paramsSchema.parse(context.params);
|
|
||||||
const { rescheduleUid } = context.query;
|
|
||||||
const { ssrInit } = await import("@server/lib/ssr");
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
|
|
||||||
const team = await prisma.team.findFirst({
|
|
||||||
where: {
|
|
||||||
slug: teamSlug,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
hideBranding: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!team) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
|
||||||
if (rescheduleUid) {
|
|
||||||
booking = await getBookingByUidOrRescheduleUid(`${rescheduleUid}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use this to both prefetch the query on the server,
|
|
||||||
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
|
||||||
const eventData = await ssr.viewer.public.event.fetch({
|
|
||||||
username: teamSlug,
|
|
||||||
eventSlug: meetingSlug,
|
|
||||||
isTeamEvent: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!eventData) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
booking,
|
|
||||||
away: false,
|
|
||||||
user: teamSlug,
|
|
||||||
slug: meetingSlug,
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
isBrandingHidden: team?.hideBranding,
|
|
||||||
themeBasis: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import withEmbedSsr from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import { getServerSideProps as _getServerSideProps } from "../[type]";
|
|
||||||
|
|
||||||
export { default } from "../[type]";
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import withEmbedSsr from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import { getServerSideProps as _getServerSideProps } from "../../../team/[slug]";
|
|
||||||
|
|
||||||
export { default } from "../../../team/[slug]";
|
|
||||||
|
|
||||||
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { getServerSideProps, default } from "../../../[user]/[type]";
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import type { GetServerSidePropsContext } from "next";
|
||||||
|
|
||||||
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
|
import type { PageProps as UserTypePageProps } from "../../../[user]/[type]";
|
||||||
|
import UserTypePage, { getServerSideProps as GSSUserTypePage } from "../../../[user]/[type]";
|
||||||
|
import TeamTypePage, { getServerSideProps as GSSTeamTypePage } from "../../../team/[slug]/[type]";
|
||||||
|
import type { PageProps as TeamTypePageProps } from "../../../team/[slug]/[type]";
|
||||||
|
|
||||||
|
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
||||||
|
const team = await prisma.team.findFirst({
|
||||||
|
where: {
|
||||||
|
slug: ctx.query.user as string,
|
||||||
|
parentId: {
|
||||||
|
not: null,
|
||||||
|
},
|
||||||
|
parent: {
|
||||||
|
slug: ctx.query.orgSlug as string,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (team) {
|
||||||
|
const params = { slug: ctx.query.user, type: ctx.query.type };
|
||||||
|
return GSSTeamTypePage({
|
||||||
|
...ctx,
|
||||||
|
params: {
|
||||||
|
...ctx.params,
|
||||||
|
...params,
|
||||||
|
},
|
||||||
|
query: {
|
||||||
|
...ctx.query,
|
||||||
|
...params,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const params = { user: ctx.query.user, type: ctx.query.type };
|
||||||
|
return GSSUserTypePage({
|
||||||
|
...ctx,
|
||||||
|
params: {
|
||||||
|
...ctx.params,
|
||||||
|
...params,
|
||||||
|
},
|
||||||
|
query: {
|
||||||
|
...ctx.query,
|
||||||
|
...params,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = UserTypePageProps | TeamTypePageProps;
|
||||||
|
|
||||||
|
export default function Page(props: Props) {
|
||||||
|
if ((props as TeamTypePageProps)?.teamId) return <TeamTypePage {...(props as TeamTypePageProps)} />;
|
||||||
|
return <UserTypePage {...(props as UserTypePageProps)} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
Page.PageWrapper = PageWrapper;
|
||||||
|
Page.isBookingPage = true;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import type { GetServerSidePropsContext } from "next";
|
||||||
|
|
||||||
|
import { getServerSideProps as _getServerSideProps } from "../[type]";
|
||||||
|
|
||||||
|
export { default } from "../[type]";
|
||||||
|
|
||||||
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||||
|
const ssrResponse = await _getServerSideProps(context);
|
||||||
|
if (ssrResponse.notFound) {
|
||||||
|
return ssrResponse;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...ssrResponse,
|
||||||
|
props: {
|
||||||
|
...ssrResponse.props,
|
||||||
|
isEmbed: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -6,7 +6,7 @@ import PageWrapper from "@components/PageWrapper";
|
|||||||
|
|
||||||
import type { UserPageProps } from "../../../[user]";
|
import type { UserPageProps } from "../../../[user]";
|
||||||
import UserPage, { getServerSideProps as GSSUserPage } from "../../../[user]";
|
import UserPage, { getServerSideProps as GSSUserPage } from "../../../[user]";
|
||||||
import type { TeamPageProps } from "../../../team/[slug]";
|
import type { PageProps as TeamPageProps } from "../../../team/[slug]";
|
||||||
import TeamPage, { getServerSideProps as GSSTeamPage } from "../../../team/[slug]";
|
import TeamPage, { getServerSideProps as GSSTeamPage } from "../../../team/[slug]";
|
||||||
|
|
||||||
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
||||||
@@ -33,8 +33,9 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
|||||||
type Props = UserPageProps | TeamPageProps;
|
type Props = UserPageProps | TeamPageProps;
|
||||||
|
|
||||||
export default function Page(props: Props) {
|
export default function Page(props: Props) {
|
||||||
if ((props as TeamPageProps)?.team) return TeamPage(props as TeamPageProps);
|
if ((props as TeamPageProps)?.team) return <TeamPage {...(props as TeamPageProps)} />;
|
||||||
return UserPage(props as UserPageProps);
|
return <UserPage {...(props as UserPageProps)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Page.isBookingPage = true;
|
||||||
Page.PageWrapper = PageWrapper;
|
Page.PageWrapper = PageWrapper;
|
||||||
@@ -12,14 +12,11 @@ export default function Type() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
const { uid: bookingId } = z
|
const { uid: bookingId, seatReferenceUid } = z
|
||||||
.object({ uid: z.string(), seatReferenceUid: z.string().optional() })
|
.object({ uid: z.string(), seatReferenceUid: z.string().optional() })
|
||||||
.parse(context.query);
|
.parse(context.query);
|
||||||
let seatReferenceUid;
|
|
||||||
const uid = await maybeGetBookingUidFromSeat(prisma, bookingId);
|
const uid = await maybeGetBookingUidFromSeat(prisma, bookingId);
|
||||||
if (uid) {
|
|
||||||
seatReferenceUid = bookingId;
|
|
||||||
}
|
|
||||||
const booking = await prisma.booking.findUnique({
|
const booking = await prisma.booking.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid,
|
uid,
|
||||||
@@ -39,6 +36,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|||||||
slug: true,
|
slug: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
seatsPerTimeSlot: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dynamicEventSlugRef: true,
|
dynamicEventSlugRef: true,
|
||||||
@@ -74,15 +72,14 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|||||||
"/" +
|
"/" +
|
||||||
eventType?.slug;
|
eventType?.slug;
|
||||||
const destinationUrl = new URLSearchParams();
|
const destinationUrl = new URLSearchParams();
|
||||||
if (seatReferenceUid) {
|
|
||||||
destinationUrl.set("rescheduleUid", seatReferenceUid);
|
destinationUrl.set("rescheduleUid", seatReferenceUid || bookingId);
|
||||||
} else {
|
|
||||||
destinationUrl.set("rescheduleUid", bookingId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
destination: `/${eventPage}?${destinationUrl.toString()}`,
|
destination: `/${eventPage}?${destinationUrl.toString()}${
|
||||||
|
eventType.seatsPerTimeSlot ? "&bookingUid=null" : ""
|
||||||
|
}`,
|
||||||
permanent: false,
|
permanent: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ const ConferencingLayout = () => {
|
|||||||
disabled={app.isGlobal}
|
disabled={app.isGlobal}
|
||||||
StartIcon={Trash}
|
StartIcon={Trash}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setDeleteCredentialId(app.credentialIds[0]);
|
setDeleteCredentialId(app.userCredentialIds[0]);
|
||||||
setDeleteAppModal(true);
|
setDeleteAppModal(true);
|
||||||
}}>
|
}}>
|
||||||
{t("remove_app")}
|
{t("remove_app")}
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ const SkeletonLoader = ({ title, description }: { title: string; description: st
|
|||||||
return (
|
return (
|
||||||
<SkeletonContainer>
|
<SkeletonContainer>
|
||||||
<Meta title={title} description={description} />
|
<Meta title={title} description={description} />
|
||||||
<div className="mb-8 mt-6 space-y-6">
|
<div className="mb-8 space-y-6">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<SkeletonAvatar className="me-4 h-16 w-16 px-4" />
|
<SkeletonAvatar className="me-4 mt-0 h-16 w-16 px-4" />
|
||||||
<SkeletonButton className="h-6 w-32 rounded-md p-5" />
|
<SkeletonButton className="h-6 w-32 rounded-md p-5" />
|
||||||
</div>
|
</div>
|
||||||
<SkeletonText className="h-8 w-full" />
|
<SkeletonText className="h-8 w-full" />
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { WizardLayout, Meta } from "@calcom/ui";
|
|||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
|
export { getServerSideProps } from "@calcom/features/ee/organizations/pages/organization";
|
||||||
|
|
||||||
const AboutOrganizationPage = () => {
|
const AboutOrganizationPage = () => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { WizardLayout, Meta } from "@calcom/ui";
|
|||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
|
export { getServerSideProps } from "@calcom/features/ee/organizations/pages/organization";
|
||||||
|
|
||||||
const AddNewTeamsPage = () => {
|
const AddNewTeamsPage = () => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { WizardLayout, Meta } from "@calcom/ui";
|
|||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
|
export { getServerSideProps } from "@calcom/features/ee/organizations/pages/organization";
|
||||||
|
|
||||||
const OnboardTeamMembersPage = () => {
|
const OnboardTeamMembersPage = () => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { WizardLayout, Meta } from "@calcom/ui";
|
|||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
|
export { getServerSideProps } from "@calcom/features/ee/organizations/pages/organization";
|
||||||
|
|
||||||
const SetPasswordPage = () => {
|
const SetPasswordPage = () => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
|
import type { GetServerSidePropsContext } from "next";
|
||||||
|
|
||||||
|
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||||
import { CreateANewOrganizationForm } from "@calcom/features/ee/organizations/components";
|
import { CreateANewOrganizationForm } from "@calcom/features/ee/organizations/components";
|
||||||
|
import { getFeatureFlagMap } from "@calcom/features/flags/server/utils";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { WizardLayout, Meta } from "@calcom/ui";
|
import { WizardLayout, Meta } from "@calcom/ui";
|
||||||
|
|
||||||
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
|
|
||||||
const CreateNewOrganizationPage = () => {
|
const CreateNewOrganizationPage = ({ querySlug }: inferSSRProps<typeof getServerSideProps>) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
return (
|
return (
|
||||||
<>
|
<LicenseRequired>
|
||||||
<Meta title={t("set_up_your_organization")} description={t("organizations_description")} />
|
<Meta title={t("set_up_your_organization")} description={t("organizations_description")} />
|
||||||
<CreateANewOrganizationForm />
|
<CreateANewOrganizationForm slug={querySlug} />
|
||||||
</>
|
</LicenseRequired>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const LayoutWrapper = (page: React.ReactElement) => {
|
const LayoutWrapper = (page: React.ReactElement) => {
|
||||||
@@ -21,6 +27,25 @@ const LayoutWrapper = (page: React.ReactElement) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||||
|
const prisma = await import("@calcom/prisma").then((mod) => mod.default);
|
||||||
|
const flags = await getFeatureFlagMap(prisma);
|
||||||
|
// Check if organizations are enabled
|
||||||
|
if (flags["organizations"] !== true) {
|
||||||
|
return {
|
||||||
|
notFound: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const querySlug = context.query.slug as string;
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
querySlug: querySlug ?? null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
CreateNewOrganizationPage.getLayout = LayoutWrapper;
|
CreateNewOrganizationPage.getLayout = LayoutWrapper;
|
||||||
CreateNewOrganizationPage.PageWrapper = PageWrapper;
|
CreateNewOrganizationPage.PageWrapper = PageWrapper;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type { SubmitHandler } from "react-hook-form";
|
|||||||
import { FormProvider, useForm } from "react-hook-form";
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
|
||||||
import { checkPremiumUsername } from "@calcom/features/ee/common/lib/checkPremiumUsername";
|
import { checkPremiumUsername } from "@calcom/features/ee/common/lib/checkPremiumUsername";
|
||||||
import { getOrgFullDomain } from "@calcom/features/ee/organizations/lib/orgDomains";
|
import { getOrgFullDomain } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
|
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
|
||||||
@@ -83,7 +82,7 @@ export default function Signup({ prepopulateFormValues, token, orgSlug }: Signup
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LicenseRequired>
|
<>
|
||||||
<div
|
<div
|
||||||
className="bg-muted flex min-h-screen flex-col justify-center "
|
className="bg-muted flex min-h-screen flex-col justify-center "
|
||||||
style={
|
style={
|
||||||
@@ -166,7 +165,7 @@ export default function Signup({ prepopulateFormValues, token, orgSlug }: Signup
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LicenseRequired>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useEffect } from "react";
|
|||||||
import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import EventTypeDescription from "@calcom/features/eventtypes/components/EventTypeDescription";
|
import EventTypeDescription from "@calcom/features/eventtypes/components/EventTypeDescription";
|
||||||
import { CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
|
import { getFeatureFlagMap } from "@calcom/features/flags/server/utils";
|
||||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import useTheme from "@calcom/lib/hooks/useTheme";
|
import useTheme from "@calcom/lib/hooks/useTheme";
|
||||||
@@ -28,9 +28,9 @@ import Team from "@components/team/screens/Team";
|
|||||||
|
|
||||||
import { ssrInit } from "@server/lib/ssr";
|
import { ssrInit } from "@server/lib/ssr";
|
||||||
|
|
||||||
export type TeamPageProps = inferSSRProps<typeof getServerSideProps>;
|
export type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||||
|
|
||||||
function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }: TeamPageProps) {
|
function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }: PageProps) {
|
||||||
useTheme(team.theme);
|
useTheme(team.theme);
|
||||||
const showMembers = useToggleQuery("members");
|
const showMembers = useToggleQuery("members");
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
@@ -65,7 +65,7 @@ function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }
|
|||||||
}
|
}
|
||||||
|
|
||||||
// slug is a route parameter, we don't want to forward it to the next route
|
// slug is a route parameter, we don't want to forward it to the next route
|
||||||
const { slug: _slug, ...queryParamsToForward } = router.query;
|
const { slug: _slug, orgSlug: _orgSlug, user: _user, ...queryParamsToForward } = router.query;
|
||||||
|
|
||||||
const EventTypes = () => (
|
const EventTypes = () => (
|
||||||
<ul className="border-subtle rounded-md border">
|
<ul className="border-subtle rounded-md border">
|
||||||
@@ -103,7 +103,7 @@ function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }
|
|||||||
items={type.users.map((user) => ({
|
items={type.users.map((user) => ({
|
||||||
alt: user.name || "",
|
alt: user.name || "",
|
||||||
title: user.name || "",
|
title: user.name || "",
|
||||||
image: CAL_URL + "/" + user.username + "/avatar.png" || "",
|
image: "/" + user.username + "/avatar.png" || "",
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,7 +140,7 @@ function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }
|
|||||||
truncateAfter={4}
|
truncateAfter={4}
|
||||||
items={ch.members.map(({ user: member }) => ({
|
items={ch.members.map(({ user: member }) => ({
|
||||||
alt: member.name || "",
|
alt: member.name || "",
|
||||||
image: `${WEBAPP_URL}/${member.username}/avatar.png`,
|
image: `/${member.username}/avatar.png`,
|
||||||
title: member.name || "",
|
title: member.name || "",
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
@@ -153,9 +153,9 @@ function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }
|
|||||||
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
||||||
<div className="text-muted dark:text-inverted p-8 text-center">
|
<div className="text-muted dark:text-inverted p-8 text-center">
|
||||||
<h2 className="font-cal dark:text-inverted text-emphasis600 mb-2 text-3xl">
|
<h2 className="font-cal dark:text-inverted text-emphasis600 mb-2 text-3xl">
|
||||||
{" " + t("no_teams_yet")}
|
{" " + t("org_no_teams_yet")}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="mx-auto max-w-md">{t("no_teams_yet_description")}</p>
|
<p className="mx-auto max-w-md">{t("org_no_teams_yet_description")}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -246,6 +246,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
const ssr = await ssrInit(context);
|
const ssr = await ssrInit(context);
|
||||||
const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug;
|
const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug;
|
||||||
const { isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
const { isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||||
|
const flags = await getFeatureFlagMap(prisma);
|
||||||
|
|
||||||
const team = await getTeamWithMembers(undefined, slug);
|
const team = await getTeamWithMembers(undefined, slug);
|
||||||
const metadata = teamMetadataSchema.parse(team?.metadata ?? {});
|
const metadata = teamMetadataSchema.parse(team?.metadata ?? {});
|
||||||
@@ -254,7 +255,8 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
if (
|
if (
|
||||||
(isValidOrgDomain && team?.parent && !!metadata?.isOrganization) ||
|
(isValidOrgDomain && team?.parent && !!metadata?.isOrganization) ||
|
||||||
(!isValidOrgDomain && team?.parent) ||
|
(!isValidOrgDomain && team?.parent) ||
|
||||||
(!isValidOrgDomain && !!metadata?.isOrganization)
|
(!isValidOrgDomain && !!metadata?.isOrganization) ||
|
||||||
|
flags["organizations"] !== true
|
||||||
) {
|
) {
|
||||||
return { notFound: true } as const;
|
return { notFound: true } as const;
|
||||||
}
|
}
|
||||||
@@ -284,7 +286,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
...type,
|
...type,
|
||||||
users: type.users.map((user) => ({
|
users: type.users.map((user) => ({
|
||||||
...user,
|
...user,
|
||||||
avatar: CAL_URL + "/" + user.username + "/avatar.png",
|
avatar: "/" + user.username + "/avatar.png",
|
||||||
})),
|
})),
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(type.description),
|
descriptionAsSafeHTML: markdownToSafeHTML(type.description),
|
||||||
}));
|
}));
|
||||||
@@ -297,10 +299,12 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
|
|
||||||
const markdownStrippedBio = stripMarkdown(team?.bio || "");
|
const markdownStrippedBio = stripMarkdown(team?.bio || "");
|
||||||
|
|
||||||
|
const { inviteToken: _inviteToken, ...serializableTeam } = team;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
team: { ...team, safeBio, members },
|
team: { ...serializableTeam, safeBio, members },
|
||||||
themeBasis: team.slug,
|
themeBasis: serializableTeam.slug,
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
markdownStrippedBio,
|
markdownStrippedBio,
|
||||||
isValidOrgDomain,
|
isValidOrgDomain,
|
||||||
|
|||||||
@@ -1,214 +1,117 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
import type { GetServerSidePropsContext } from "next";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { LocationObject } from "@calcom/core/location";
|
import { Booker } from "@calcom/atoms";
|
||||||
import { privacyFilteredLocations } from "@calcom/core/location";
|
import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
|
||||||
|
import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking";
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||||
import getBooking from "@calcom/features/bookings/lib/get-booking";
|
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { parseRecurringEvent } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { getWorkingHours } from "@calcom/lib/availability";
|
import slugify from "@calcom/lib/slugify";
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
|
||||||
|
|
||||||
import { asStringOrNull } from "@lib/asStringOrNull";
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||||
import type { EmbedProps } from "@lib/withEmbedSsr";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
import AvailabilityPage from "@components/booking/pages/AvailabilityPage";
|
|
||||||
|
|
||||||
import { ssgInit } from "@server/lib/ssg";
|
export type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||||
|
|
||||||
export type AvailabilityTeamPageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
|
export default function Type({ slug, user, booking, away, isBrandingHidden, org }: PageProps) {
|
||||||
|
const isEmbed = typeof window !== "undefined" && window?.isEmbed?.();
|
||||||
export default function TeamType(props: AvailabilityTeamPageProps) {
|
return (
|
||||||
return <AvailabilityPage {...props} />;
|
<main className={classNames("flex h-full items-center justify-center", !isEmbed && "min-h-[100dvh]")}>
|
||||||
|
<BookerSeo
|
||||||
|
username={user}
|
||||||
|
eventSlug={slug}
|
||||||
|
rescheduleUid={booking?.uid}
|
||||||
|
hideBranding={isBrandingHidden}
|
||||||
|
isTeamEvent
|
||||||
|
org={org}
|
||||||
|
/>
|
||||||
|
<Booker
|
||||||
|
username={user}
|
||||||
|
eventSlug={slug}
|
||||||
|
bookingData={booking}
|
||||||
|
isAway={away}
|
||||||
|
hideBranding={isBrandingHidden}
|
||||||
|
isTeamEvent
|
||||||
|
org={org}
|
||||||
|
/>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamType.isBookingPage = true;
|
Type.PageWrapper = PageWrapper;
|
||||||
TeamType.PageWrapper = PageWrapper;
|
Type.isBookingPage = true;
|
||||||
|
|
||||||
|
const paramsSchema = z.object({
|
||||||
|
type: z.string().transform((s) => slugify(s)),
|
||||||
|
slug: z.string().transform((s) => slugify(s)),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Booker page fetches a tiny bit of data server side:
|
||||||
|
// 1. Check if team exists, to show 404
|
||||||
|
// 2. If rescheduling, get the booking details
|
||||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||||
const slugParam = asStringOrNull(context.query.slug);
|
const { slug: teamSlug, type: meetingSlug } = paramsSchema.parse(context.params);
|
||||||
const typeParam = asStringOrNull(context.query.type);
|
const { rescheduleUid } = context.query;
|
||||||
const dateParam = asStringOrNull(context.query.date);
|
const { ssrInit } = await import("@server/lib/ssr");
|
||||||
const rescheduleUid = asStringOrNull(context.query.rescheduleUid);
|
const ssr = await ssrInit(context);
|
||||||
const ssg = await ssgInit(context);
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||||
|
|
||||||
if (!slugParam || !typeParam) {
|
|
||||||
throw new Error(`File is not named [idOrSlug]/[user]`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const team = await prisma.team.findFirst({
|
const team = await prisma.team.findFirst({
|
||||||
where: {
|
where: {
|
||||||
slug: slugParam,
|
slug: teamSlug,
|
||||||
|
parent: isValidOrgDomain
|
||||||
|
? {
|
||||||
|
slug: currentOrgDomain,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
|
||||||
slug: true,
|
|
||||||
logo: true,
|
|
||||||
hideBranding: true,
|
hideBranding: true,
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
theme: true,
|
|
||||||
eventTypes: {
|
|
||||||
where: {
|
|
||||||
slug: typeParam,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
slug: true,
|
|
||||||
hidden: true,
|
|
||||||
hosts: {
|
|
||||||
select: {
|
|
||||||
isFixed: true,
|
|
||||||
user: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
username: true,
|
|
||||||
timeZone: true,
|
|
||||||
hideBranding: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
title: true,
|
|
||||||
availability: true,
|
|
||||||
description: true,
|
|
||||||
length: true,
|
|
||||||
disableGuests: true,
|
|
||||||
schedulingType: true,
|
|
||||||
periodType: true,
|
|
||||||
periodStartDate: true,
|
|
||||||
periodEndDate: true,
|
|
||||||
periodDays: true,
|
|
||||||
periodCountCalendarDays: true,
|
|
||||||
minimumBookingNotice: true,
|
|
||||||
beforeEventBuffer: true,
|
|
||||||
afterEventBuffer: true,
|
|
||||||
recurringEvent: true,
|
|
||||||
requiresConfirmation: true,
|
|
||||||
locations: true,
|
|
||||||
price: true,
|
|
||||||
currency: true,
|
|
||||||
timeZone: true,
|
|
||||||
slotInterval: true,
|
|
||||||
metadata: true,
|
|
||||||
seatsPerTimeSlot: true,
|
|
||||||
bookingFields: true,
|
|
||||||
customInputs: true,
|
|
||||||
schedule: {
|
|
||||||
select: {
|
|
||||||
timeZone: true,
|
|
||||||
availability: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
workflows: {
|
|
||||||
select: {
|
|
||||||
workflow: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
steps: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
team: {
|
|
||||||
select: {
|
|
||||||
members: {
|
|
||||||
where: {
|
|
||||||
role: "OWNER",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
user: {
|
|
||||||
select: {
|
|
||||||
weekStart: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
parent: {
|
|
||||||
select: {
|
|
||||||
logo: true,
|
|
||||||
name: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!team || team.eventTypes.length != 1) {
|
if (!team) {
|
||||||
return {
|
return {
|
||||||
notFound: true,
|
notFound: true,
|
||||||
} as {
|
} as const;
|
||||||
notFound: true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [eventType] = team.eventTypes;
|
|
||||||
|
|
||||||
const timeZone = eventType.schedule?.timeZone || eventType.timeZone || undefined;
|
|
||||||
|
|
||||||
const workingHours = getWorkingHours(
|
|
||||||
{
|
|
||||||
timeZone,
|
|
||||||
},
|
|
||||||
eventType.schedule?.availability || eventType.availability
|
|
||||||
);
|
|
||||||
|
|
||||||
eventType.schedule = null;
|
|
||||||
|
|
||||||
const locations = eventType.locations ? (eventType.locations as LocationObject[]) : [];
|
|
||||||
const eventTypeObject = Object.assign({}, eventType, {
|
|
||||||
metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),
|
|
||||||
periodStartDate: eventType.periodStartDate?.toString() ?? null,
|
|
||||||
periodEndDate: eventType.periodEndDate?.toString() ?? null,
|
|
||||||
recurringEvent: parseRecurringEvent(eventType.recurringEvent),
|
|
||||||
locations: privacyFilteredLocations(locations),
|
|
||||||
users: eventType.hosts.map(({ user: { name, username, hideBranding, timeZone } }) => ({
|
|
||||||
name,
|
|
||||||
username,
|
|
||||||
hideBranding,
|
|
||||||
timeZone,
|
|
||||||
})),
|
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
|
||||||
});
|
|
||||||
|
|
||||||
eventTypeObject.availability = [];
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
let booking: GetBookingType | null = null;
|
||||||
if (rescheduleUid) {
|
if (rescheduleUid) {
|
||||||
booking = await getBooking(prisma, rescheduleUid);
|
booking = await getBookingForReschedule(`${rescheduleUid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const weekStart = eventType.team?.members?.[0]?.user?.weekStart;
|
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||||
|
// We use this to both prefetch the query on the server,
|
||||||
|
// as well as to check if the event exist, so we c an show a 404 otherwise.
|
||||||
|
const eventData = await ssr.viewer.public.event.fetch({
|
||||||
|
username: teamSlug,
|
||||||
|
eventSlug: meetingSlug,
|
||||||
|
isTeamEvent: true,
|
||||||
|
org,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!eventData) {
|
||||||
|
return {
|
||||||
|
notFound: true,
|
||||||
|
} as const;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
profile: {
|
org,
|
||||||
name: team.name || team.slug,
|
|
||||||
slug: team.slug,
|
|
||||||
image: team.logo,
|
|
||||||
theme: team.theme,
|
|
||||||
weekStart: weekStart ?? "Sunday",
|
|
||||||
brandColor: team.brandColor,
|
|
||||||
darkBrandColor: team.darkBrandColor,
|
|
||||||
},
|
|
||||||
themeBasis: team.slug,
|
|
||||||
date: dateParam,
|
|
||||||
eventType: eventTypeObject,
|
|
||||||
workingHours,
|
|
||||||
previousPage: context.req.headers.referer ?? null,
|
|
||||||
booking,
|
booking,
|
||||||
trpcState: ssg.dehydrate(),
|
away: false,
|
||||||
isBrandingHidden: team.hideBranding,
|
user: teamSlug,
|
||||||
|
teamId: team.id,
|
||||||
|
slug: meetingSlug,
|
||||||
|
trpcState: ssr.dehydrate(),
|
||||||
|
isBrandingHidden: team?.hideBranding,
|
||||||
|
themeBasis: null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
import type { GetServerSidePropsContext } from "next";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import type { LocationObject } from "@calcom/app-store/locations";
|
|
||||||
import { privacyFilteredLocations } from "@calcom/app-store/locations";
|
|
||||||
import getBooking from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
|
||||||
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
|
||||||
import { parseRecurringEvent } from "@calcom/lib";
|
|
||||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
|
||||||
import prisma from "@calcom/prisma";
|
|
||||||
import { customInputSchema, eventTypeBookingFields, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
|
||||||
|
|
||||||
import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";
|
|
||||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
|
||||||
import BookingPage from "@components/booking/pages/BookingPage";
|
|
||||||
|
|
||||||
import { ssrInit } from "@server/lib/ssr";
|
|
||||||
|
|
||||||
export type TeamBookingPageProps = inferSSRProps<typeof getServerSideProps>;
|
|
||||||
|
|
||||||
export default function TeamBookingPage(props: TeamBookingPageProps) {
|
|
||||||
return <BookingPage {...props} />;
|
|
||||||
}
|
|
||||||
TeamBookingPage.isBookingPage = true;
|
|
||||||
TeamBookingPage.PageWrapper = PageWrapper;
|
|
||||||
|
|
||||||
const querySchema = z.object({
|
|
||||||
rescheduleUid: z.string().optional(),
|
|
||||||
bookingUid: z.string().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|
||||||
const ssr = await ssrInit(context);
|
|
||||||
const eventTypeId = parseInt(asStringOrThrow(context.query.type));
|
|
||||||
const recurringEventCountQuery = asStringOrNull(context.query.count);
|
|
||||||
if (typeof eventTypeId !== "number" || eventTypeId % 1 !== 0) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
} as const;
|
|
||||||
}
|
|
||||||
|
|
||||||
const eventTypeRaw = await prisma.eventType.findUnique({
|
|
||||||
where: {
|
|
||||||
id: eventTypeId,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
title: true,
|
|
||||||
slug: true,
|
|
||||||
description: true,
|
|
||||||
length: true,
|
|
||||||
locations: true,
|
|
||||||
customInputs: true,
|
|
||||||
periodType: true,
|
|
||||||
periodDays: true,
|
|
||||||
periodStartDate: true,
|
|
||||||
periodEndDate: true,
|
|
||||||
periodCountCalendarDays: true,
|
|
||||||
recurringEvent: true,
|
|
||||||
requiresConfirmation: true,
|
|
||||||
disableGuests: true,
|
|
||||||
price: true,
|
|
||||||
currency: true,
|
|
||||||
metadata: true,
|
|
||||||
seatsPerTimeSlot: true,
|
|
||||||
schedulingType: true,
|
|
||||||
bookingFields: true,
|
|
||||||
successRedirectUrl: true,
|
|
||||||
workflows: {
|
|
||||||
include: {
|
|
||||||
workflow: {
|
|
||||||
include: {
|
|
||||||
steps: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
team: {
|
|
||||||
select: {
|
|
||||||
slug: true,
|
|
||||||
name: true,
|
|
||||||
logo: true,
|
|
||||||
theme: true,
|
|
||||||
brandColor: true,
|
|
||||||
darkBrandColor: true,
|
|
||||||
parent: {
|
|
||||||
select: {
|
|
||||||
logo: true,
|
|
||||||
name: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
users: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
avatar: true,
|
|
||||||
name: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!eventTypeRaw) return { notFound: true };
|
|
||||||
|
|
||||||
const eventType = {
|
|
||||||
...eventTypeRaw,
|
|
||||||
//TODO: Use zodSchema to verify it instead of using Type Assertion
|
|
||||||
locations: privacyFilteredLocations((eventTypeRaw.locations || []) as LocationObject[]),
|
|
||||||
recurringEvent: parseRecurringEvent(eventTypeRaw.recurringEvent),
|
|
||||||
bookingFields: eventTypeBookingFields.parse(eventTypeRaw.bookingFields || []),
|
|
||||||
};
|
|
||||||
const eventTypeObject = [eventType].map((e) => {
|
|
||||||
return {
|
|
||||||
...e,
|
|
||||||
metadata: EventTypeMetaDataSchema.parse(e.metadata || {}),
|
|
||||||
bookingFields: getBookingFieldsWithSystemFields(eventType),
|
|
||||||
periodStartDate: e.periodStartDate?.toString() ?? null,
|
|
||||||
periodEndDate: e.periodEndDate?.toString() ?? null,
|
|
||||||
customInputs: customInputSchema.array().parse(e.customInputs || []),
|
|
||||||
users: eventType.users.map((u) => ({
|
|
||||||
id: u.id,
|
|
||||||
name: u.name,
|
|
||||||
username: u.username,
|
|
||||||
avatar: u.avatar,
|
|
||||||
image: u.avatar,
|
|
||||||
slug: u.username,
|
|
||||||
})),
|
|
||||||
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
|
||||||
};
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
let booking: GetBookingType | null = null;
|
|
||||||
const { rescheduleUid, bookingUid } = querySchema.parse(context.query);
|
|
||||||
if (rescheduleUid || bookingUid) {
|
|
||||||
booking = await getBooking(prisma, rescheduleUid || bookingUid || "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking if number of recurring event ocurrances is valid against event type configuration
|
|
||||||
const recurringEventCount =
|
|
||||||
(eventType.recurringEvent?.count &&
|
|
||||||
recurringEventCountQuery &&
|
|
||||||
(parseInt(recurringEventCountQuery) <= eventType.recurringEvent.count
|
|
||||||
? parseInt(recurringEventCountQuery)
|
|
||||||
: eventType.recurringEvent.count)) ||
|
|
||||||
null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
trpcState: ssr.dehydrate(),
|
|
||||||
profile: {
|
|
||||||
...eventTypeObject.team,
|
|
||||||
// FIXME: This slug is used as username on success page which is wrong. This is correctly set as username for user booking.
|
|
||||||
slug: "team/" + eventTypeObject.slug,
|
|
||||||
image: eventTypeObject.team?.logo || null,
|
|
||||||
eventName: null,
|
|
||||||
},
|
|
||||||
themeBasis: eventTypeObject.team?.slug,
|
|
||||||
eventType: eventTypeObject,
|
|
||||||
recurringEventCount,
|
|
||||||
booking,
|
|
||||||
currentSlotBooking: null,
|
|
||||||
isDynamicGroupBooking: false,
|
|
||||||
hasHashedBookingLink: false,
|
|
||||||
hashedLink: null,
|
|
||||||
isEmbed: typeof context.query.embed === "string",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loaded 100 of 499 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user