Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| type: type.schedulingType, | ||
| teamId: group.teamId, | ||
| locations: encodeURIComponent(JSON.stringify(type.locations)), | ||
| dialog: "duplicate-event-type", |
There was a problem hiding this comment.
new dialog with form and specific action for use case
|
|
||
| // inject selection data into url for correct router history | ||
| const openModal = (group: EventTypeGroup, type: EventType) => { | ||
| const openDuplicateModal = (eventType: EventType) => { |
There was a problem hiding this comment.
Some times we are better off creating a single function for a specific use case that using one and if else everything
| "radio": "Radio", | ||
| "kbar_search_placeholder" : "Start typing to search" | ||
| "kbar_search_placeholder": "Start typing to search", | ||
| "event_type_duplicate_copy_text": "{{slug}}-copy" |
There was a problem hiding this comment.
So we can to "event-slug-copy"
| slug: z.string(), | ||
| title: z.string(), | ||
| description: z.string(), | ||
| length: z.number(), |
There was a problem hiding this comment.
This is all we need for duplicating and event, form inputs and we can get the rest from DB.
| if (!eventType) { | ||
| throw new TRPCError({ code: "NOT_FOUND" }); | ||
| } | ||
| // Validate user is owner of event type or in the team |
There was a problem hiding this comment.
Is this necessary? i am not able to think of a scenario where an user would be able to create an event that is not created by the user itself or it's members. Can you elaborate this?
There was a problem hiding this comment.
It's always a good practice to take security measures both on front end and on server. In this case I only look for an event type based on its id without making sure who the owner of that it is. With this I make sure if someone hijack the frontend request it doesn't leak any other user's sensitive data.
const eventType = await ctx.prisma.eventType.findUnique({
where: {
id: originalEventTypeId,
},
...
There was a problem hiding this comment.
Yeah, that makes a lot of sense, I will try to think about this(security edge cases) more carefully in future PRs.
Thanks for explaining @alannnc.
There was a problem hiding this comment.
No worries, anytime. What you think about this new approach? It's cleaner IMO and if you can tell me if its working for you it will be a lot of help. @harshsinghatz
There was a problem hiding this comment.
Sorry for late replies, our timezones don't match lol. Your notifications starts popping up when i am half asleep.
Regarding the approach I feel there are more duplications which would have been avoided but i think overall it's more readable.
Have you implemented it completely or is it still in progress?
There was a problem hiding this comment.
It's complete right now, obviously just missing webhooks/workflows. But we can add that later.
| data: customInputsData, | ||
| }); | ||
| } | ||
|
|
There was a problem hiding this comment.
@CarinaWolli Which can be the best way to clone/copy webhooks/workflows?
There was a problem hiding this comment.
For workflows, this worked for me:
const ids = _workflows.map(workflow => workflow.workflowId);
const connectWorkflowIds = ids.map(id => { return {workflow: { connect: { id: id } } }});
const data: Prisma.EventTypeCreateInput = {
...rest,
title: newEventTitle,
slug: newSlug,
locations: locations ?? undefined,
team: team ? { connect: { id: team.id } } : undefined,
users: users ? { connect: users.map((user) => ({ id: user.id })) } : undefined,
recurringEvent: recurringEvent || undefined,
bookingLimits: bookingLimits ?? undefined,
metadata: metadata === null ? Prisma.DbNull : metadata,
workflows: {
create: connectWorkflowIds,
}
};
…al.com into fix/duplicate-event-types
…al.com into fix/duplicate-event-types

What does this PR do?
Loom
https://www.loom.com/share/30bb65dec37447c2b0113ca8b675d9d4
Fixes #5835
Environment: Staging(main branch)
Type of change
How should this be tested?
Checklist