Skip to content

Commit

Permalink
Merge branch 'main' into refactor-pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
DonKoko authored May 13, 2024
2 parents a955ea6 + 3c96cd9 commit 488bff0
Show file tree
Hide file tree
Showing 28 changed files with 802 additions and 131 deletions.
2 changes: 2 additions & 0 deletions app/components/assets/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export const AssetForm = ({
countKey="totalCategories"
closeOnSelect
selectionMode="set"
allowClear
extraContent={
<Button
to="/categories/new"
Expand Down Expand Up @@ -293,6 +294,7 @@ export const AssetForm = ({
initialDataKey="locations"
countKey="totalLocations"
closeOnSelect
allowClear
extraContent={
<Button
to="/locations/new"
Expand Down
1 change: 0 additions & 1 deletion app/components/booking/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const NewBookingFormSchema = (
) =>
z
.object({
// @TODO this is why its not working, because the id is required even on new bookings
id:
inputFieldIsDisabled || isNewBooking
? z.string().optional()
Expand Down
1 change: 0 additions & 1 deletion app/components/booking/page-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { BookingForm } from "./form";
export function BookingPageContent() {
const { booking, teamMembers } = useLoaderData<typeof loader>();

// @TODO fix this
const bookingStatus = useBookingStatus(booking);

return (
Expand Down
37 changes: 30 additions & 7 deletions app/components/dynamic-select/dynamic-select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo, useRef, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import { ChevronDownIcon } from "@radix-ui/react-icons";
import {
Popover,
Expand Down Expand Up @@ -38,6 +38,10 @@ type Props = ModelFilterProps & {
valueExtractor?: (item: ModelFilterItem) => string;
excludeItems?: string[];
onChange?: ((value: string) => void) | null;
/**
* Allow item to unselect on clicking again
*/
allowClear?: boolean;
};

export default function DynamicSelect({
Expand All @@ -60,6 +64,7 @@ export default function DynamicSelect({
selectionMode = "none",
excludeItems,
onChange = null,
allowClear,
}: Props) {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const triggerRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -94,10 +99,33 @@ export default function DynamicSelect({
[excludeItems, items]
);

function handleItemChange(id: string) {
if (allowClear && selectedValue === id) {
setSelectedValue(undefined);
} else {
setSelectedValue(id);
handleSelectItemChange(id);
}

onChange && onChange(id);

if (closeOnSelect) {
setIsPopoverOpen(false);
}
}

useEffect(
function updateSelectedIfDefaultValueChange() {
setSelectedValue(defaultValue);
},
[defaultValue]
);

return (
<>
<div className="relative w-full">
<input
key={`${selectedValue}-${defaultValue}`}
type="hidden"
value={selectedValue}
name={fieldName ?? model.name}
Expand Down Expand Up @@ -189,12 +217,7 @@ export default function DynamicSelect({
item.id === selectedValue && "bg-gray-100"
)}
onClick={() => {
setSelectedValue(item.id);
handleSelectItemChange(item.id);
onChange && onChange(item.id);
if (closeOnSelect) {
setIsPopoverOpen(false);
}
handleItemChange(item.id);
}}
>
<div>
Expand Down
19 changes: 19 additions & 0 deletions app/components/icons/library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,25 @@ export const CalendarIcon = (props: SVGProps<SVGSVGElement>) => (
</svg>
);

export const BookingsIcon = (props: SVGProps<SVGSVGElement>) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="100%"
height="100%"
viewBox="0 0 20 22"
fill="none"
{...props}
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M19 7H1m13-6v3M6 1v3m4 13v-6m-3 3h6m-7.2 7h8.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C19 18.72 19 17.88 19 16.2V7.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C16.72 3 15.88 3 14.2 3H5.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C1 5.28 1 6.12 1 7.8v8.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C3.28 21 4.12 21 5.8 21Z"
/>
</svg>
);

export const CustomFiedIcon = (props: SVGProps<SVGSVGElement>) => (
<svg
width="16"
Expand Down
7 changes: 4 additions & 3 deletions app/components/layout/sidebar/menu-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const MenuItems = ({ fetcher }: { fetcher: FetcherWithComponents<any> }) => {
) : null}

{menuItemsTop.map((item) =>
item.to === "bookings" ? (
item.to === "bookings" || item.to === "calendar" ? (
<li key={item.label}>
<ControlledActionButton
canUseFeature={canUseBookings}
Expand All @@ -71,8 +71,9 @@ const MenuItems = ({ fetcher }: { fetcher: FetcherWithComponents<any> }) => {
</span>
</span>
),
message:
"Bookings is a premium feature only available for Team workspaces. ",
message: `${
item.to[0].toUpperCase() + item.to.substring(1)
} is a premium feature only available for Team workspaces.`,
ctaText: "upgrading to a team plan",
}}
buttonProps={{
Expand Down
4 changes: 2 additions & 2 deletions app/components/location/location-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const LocationSelect = () => {

const { asset } = useLoaderData<typeof loader>();

const [locationId, setLocationId] = useState(asset.locationId || undefined);
const [locationId, setLocationId] = useState(asset.locationId ?? undefined);
const disabled = isFormProcessing(navigation.state);

return (
Expand All @@ -28,7 +28,7 @@ export const LocationSelect = () => {
<DynamicSelect
disabled={disabled}
fieldName="newLocationId"
defaultValue={locationId || undefined}
defaultValue={locationId}
model={{ name: "location", queryKey: "name" }}
label="Locations"
initialDataKey="locations"
Expand Down
6 changes: 2 additions & 4 deletions app/components/shared/controlled-action-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ const HoverMessage = ({
{buttonContent.message}
{!skipCta ? (
<span>
Please consider{" "}
<Button to="/settings/subscription" variant={"link"}>
{buttonContent.ctaText}
</Button>
{" "}
Please switch to your team workspace to use this feature
</span>
) : null}
.
Expand Down
5 changes: 4 additions & 1 deletion app/components/shared/icons-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
GraphIcon,
ScanQRIcon,
SwitchIcon,
BookingsIcon,
} from "../icons/library";

/** The possible options for icons to be rendered in the button */
Expand Down Expand Up @@ -69,7 +70,8 @@ export type IconType =
| "calendar"
| "graph"
| "scanQR"
| "switch";
| "switch"
| "bookings";

type IconsMap = {
[key in IconType]: JSX.Element;
Expand Down Expand Up @@ -106,6 +108,7 @@ export const iconsMap: IconsMap = {
send: <SendIcon />,
user: <UserIcon />,
calendar: <CalendarIcon className="size-5" />,
bookings: <BookingsIcon />,
graph: <GraphIcon />,
scanQR: <ScanQRIcon />,
switch: <SwitchIcon />,
Expand Down
1 change: 0 additions & 1 deletion app/database/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ enum NoteType {
}

model Qr {
// @TODO we might need to change this to shorten the length of the id
id String @id @default(cuid())
// Version of the QR code based on spec from Denso wave
Expand Down
5 changes: 5 additions & 0 deletions app/hooks/use-main-menu-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export function useMainMenuItems() {
},
{
icon: <Icon icon="calendar" />,
to: "calendar",
label: "Calendar",
},
{
icon: <Icon icon="bookings" />,
to: "bookings",
label: "Bookings (beta)",
},
Expand Down
Loading

0 comments on commit 488bff0

Please sign in to comment.