From 7585e9b32eb95d13dc616e2ded539b6d47ba70dd Mon Sep 17 00:00:00 2001 From: Juan Esteban Nieto Cifuentes <89233604+Jenietoc@users.noreply.github.com> Date: Mon, 21 Feb 2022 11:53:16 -0500 Subject: [PATCH] Fix URL by removing slash and backslash (#1733) * Fix URl by removing slash and backslash * Implement slugify * Add data type * Fixing folder structure * Solve zod-utils conflict --- .../components/eventtype/CreateEventType.tsx | 3 +- apps/web/pages/event-types/[type].tsx | 166 +++++++++--------- packages/prisma/zod-utils.ts | 5 +- 3 files changed, 90 insertions(+), 84 deletions(-) diff --git a/apps/web/components/eventtype/CreateEventType.tsx b/apps/web/components/eventtype/CreateEventType.tsx index 4c34499eef..03c9272f0c 100644 --- a/apps/web/components/eventtype/CreateEventType.tsx +++ b/apps/web/components/eventtype/CreateEventType.tsx @@ -12,6 +12,7 @@ import { HttpError } from "@lib/core/http/error"; import { useLocale } from "@lib/hooks/useLocale"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; import showToast from "@lib/notification"; +import { slugify } from "@lib/slugify"; import { trpc } from "@lib/trpc"; import { Dialog, DialogClose, DialogContent } from "@components/Dialog"; @@ -67,7 +68,7 @@ export default function CreateEventTypeButton(props: Props) { useEffect(() => { const subscription = watch((value, { name, type }) => { if (name === "title" && type === "change") { - if (value.title) setValue("slug", value.title.replace(/\s+/g, "-").toLowerCase()); + if (value.title) setValue("slug", slugify(value.title)); else setValue("slug", ""); } }); diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsx index 50bb4cb84f..d3cf1d075f 100644 --- a/apps/web/pages/event-types/[type].tsx +++ b/apps/web/pages/event-types/[type].tsx @@ -38,6 +38,7 @@ import showToast from "@lib/notification"; import prisma from "@lib/prisma"; import { trpc } from "@lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; +import { slugify } from "@lib/slugify"; import DestinationCalendarSelector from "@components/DestinationCalendarSelector"; import { Dialog, DialogContent, DialogTrigger } from "@components/Dialog"; @@ -253,7 +254,7 @@ const EventTypePage = (props: inferSSRProps) => { {...locationFormMethods.register("locationAddress")} id="address" required - className="focus:border-primary-500 focus:ring-primary-500 block w-full rounded-sm border-gray-300 shadow-sm sm:text-sm" + className="block w-full border-gray-300 rounded-sm shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm" defaultValue={ formMethods .getValues("locations") @@ -383,7 +384,7 @@ const EventTypePage = (props: inferSSRProps) => { options={locationOptions} isSearchable={false} classNamePrefix="react-select" - className="react-select-container focus:border-primary-500 focus:ring-primary-500 block w-full min-w-0 flex-1 rounded-sm border border-gray-300 sm:text-sm" + className="flex-1 block w-full min-w-0 border border-gray-300 rounded-sm react-select-container focus:border-primary-500 focus:ring-primary-500 sm:text-sm" onChange={(e) => { if (e?.value) { locationFormMethods.setValue("locationType", e.value); @@ -401,25 +402,25 @@ const EventTypePage = (props: inferSSRProps) => { className="mb-2 rounded-sm border border-neutral-300 py-1.5 px-2 shadow-sm">
{location.type === LocationType.InPerson && ( -
- +
+
)} {location.type === LocationType.Phone && ( -
- +
+ {t("phone_call")}
)} {location.type === LocationType.GoogleMeet && ( -
+
@@ -448,7 +449,7 @@ const EventTypePage = (props: inferSSRProps) => {
)} {location.type === LocationType.Huddle01 && ( -
+
) => {
)} {location.type === LocationType.Zoom && ( -
+
@@ -548,7 +549,7 @@ const EventTypePage = (props: inferSSRProps) => {
)} {location.type === LocationType.Tandem && ( -
+
) => {
)} {location.type === LocationType.Jitsi && ( -
+
@@ -602,11 +603,11 @@ const EventTypePage = (props: inferSSRProps) => {
@@ -617,7 +618,7 @@ const EventTypePage = (props: inferSSRProps) => {
  • @@ -1046,8 +1050,8 @@ const EventTypePage = (props: inferSSRProps) => { )} /> -
    -
    +
    +
    @@ -1072,7 +1076,7 @@ const EventTypePage = (props: inferSSRProps) => { @@ -1172,7 +1176,7 @@ const EventTypePage = (props: inferSSRProps) => {
    -
    +
    @@ -1209,20 +1213,20 @@ const EventTypePage = (props: inferSSRProps) => { <>
    -
    +
    -
    +
    -
    +
    { setRequirePayment(event.target.checked); @@ -1233,7 +1237,7 @@ const EventTypePage = (props: inferSSRProps) => { id="requirePayment" name="requirePayment" type="checkbox" - className="text-primary-600 focus:ring-primary-500 h-4 w-4 rounded border-gray-300" + className="w-4 h-4 border-gray-300 rounded text-primary-600 focus:ring-primary-500" defaultChecked={requirePayment} />
    @@ -1256,7 +1260,7 @@ const EventTypePage = (props: inferSSRProps) => {
    {requirePayment && (
    -
    +
    ) => { min="0.5" type="number" required - className="focus:border-primary-500 focus:ring-primary-500 block w-full rounded-sm border-gray-300 pl-2 pr-12 sm:text-sm" + className="block w-full pl-2 pr-12 border-gray-300 rounded-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm" placeholder="Price" onChange={(e) => { field.onChange(e.target.valueAsNumber * 100); @@ -1279,7 +1283,7 @@ const EventTypePage = (props: inferSSRProps) => { /> )} /> -
    +
    {new Intl.NumberFormat("en", { style: "currency", @@ -1304,7 +1308,7 @@ const EventTypePage = (props: inferSSRProps) => { {/* )} */} -
    +
    @@ -1337,8 +1341,8 @@ const EventTypePage = (props: inferSSRProps) => { href={permalink} target="_blank" rel="noreferrer" - className="text-md inline-flex items-center rounded-sm px-2 py-1 text-sm font-medium text-neutral-700 hover:bg-gray-200 hover:text-gray-900"> -
    -
    +
    -
    - +
    +