Added booking tabs, type fixing and refactoring (#825)

* More type fixes

* More type fixes

* Type fixes

* Adds inputMode to email fields

* Added booking tabs

* Adds aditional notes to bookings
This commit is contained in:
Omar López authored and GitHub committed 2021-09-29 22:33:18 +01:00
1 parent 5318047794
commit a04336ba06
29 files changed
+609 -519

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
import { Menu, Transition } from "@headlessui/react";
import { DotsHorizontalIcon } from "@heroicons/react/solid";
import React, { FC, Fragment } from "react";
import classNames from "@lib/classNames";
import { SVGComponent } from "@lib/types/SVGComponent";
import Button from "./Button";
type ActionType = {
id: string;
icon: SVGComponent;
label: string;
disabled?: boolean;
} & ({ href?: never; onClick: () => any } | { href: string; onClick?: never });
interface Props {
actions: ActionType[];
}
const TableActions: FC<Props> = ({ actions }) => {
return (
<>
<div className="space-x-2 hidden lg:block">
{actions.map((action) => (
<Button
key={action.id}
data-testid={action.id}
href={action.href}
onClick={action.onClick}
StartIcon={action.icon}
disabled={action.disabled}
color="secondary">
{action.label}
</Button>
))}
</div>
<Menu as="div" className="inline-block lg:hidden text-left ">
{({ open }) => (
<>
<div>
<Menu.Button className="text-neutral-400 mt-1 p-2 border border-transparent hover:border-gray-200">
<span className="sr-only">Open options</span>
<DotsHorizontalIcon className="h-5 w-5" aria-hidden="true" />
</Menu.Button>
</div>
<Transition
show={open}
as={Fragment}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95">
<Menu.Items
static
className="origin-top-right absolute right-0 mt-2 w-56 rounded-sm shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none divide-y divide-neutral-100">
<div className="py-1">
{actions.map((action) => {
const Element = typeof action.onClick === "function" ? "span" : "a";
return (
<Menu.Item key={action.id} disabled={action.disabled}>
{({ active }) => (
<Element
href={action.href}
onClick={action.onClick}
className={classNames(
active ? "bg-neutral-100 text-neutral-900" : "text-neutral-700",
"group flex items-center px-4 py-2 text-sm font-medium"
)}>
<action.icon
className="mr-3 h-5 w-5 text-neutral-400 group-hover:text-neutral-500"
aria-hidden="true"
/>
{action.label}
</Element>
)}
</Menu.Item>
);
})}
</div>
</Menu.Items>
</Transition>
</>
)}
</Menu>
</>
);
};
export default TableActions;
+13 -8
View File
@@ -1,21 +1,26 @@
import { XIcon, CheckIcon } from "@heroicons/react/outline";
import { CheckIcon, XIcon } from "@heroicons/react/outline";
import React, { ForwardedRef, useEffect, useState } from "react";
import { OptionsType } from "react-select/lib/types";
import Avatar from "@components/ui/Avatar";
import Select from "@components/ui/form/Select";
type CheckedSelectValue = {
avatar: string;
label: string;
value: string;
}[];
export type CheckedSelectProps = {
defaultValue?: [];
defaultValue?: CheckedSelectValue;
placeholder?: string;
name?: string;
options: [];
onChange: (options: OptionsType) => void;
disabled: [];
options: CheckedSelectValue;
onChange: (options: CheckedSelectValue) => void;
disabled: boolean;
};
export const CheckedSelect = React.forwardRef((props: CheckedSelectProps, ref: ForwardedRef<unknown>) => {
const [selectedOptions, setSelectedOptions] = useState<[]>(props.defaultValue || []);
const [selectedOptions, setSelectedOptions] = useState<CheckedSelectValue>(props.defaultValue || []);
useEffect(() => {
props.onChange(selectedOptions);
@@ -38,7 +43,7 @@ export const CheckedSelect = React.forwardRef((props: CheckedSelectProps, ref: F
disabled: !!selectedOptions.find((selectedOption) => selectedOption.value === option.value),
}));
const removeOption = (value) =>
const removeOption = (value: string) =>
setSelectedOptions(selectedOptions.filter((option) => option.value !== value));
const changeHandler = (selections) =>
+2 -2
View File
@@ -6,8 +6,8 @@ import React from "react";
import "react-calendar/dist/Calendar.css";
type Props = {
startDate: string;
endDate: string;
startDate: Date;
endDate: Date;
onDatesChange?: ((arg: { startDate: Date; endDate: Date }) => void) | undefined;
};
+1 -1
View File
@@ -7,7 +7,7 @@ export const SelectComp = (props: PropsWithChildren<NamedProps>) => (
<Select
theme={(theme) => ({
...theme,
borderRadius: "2px",
borderRadius: 2,
colors: {
...theme.colors,
primary: "rgba(17, 17, 17, var(--tw-bg-opacity))",