Fixes Apple Calendar onboarding and type fixes (#988)

* Type fixes

* Type fixes

* Attemp to prevent unknown error in prod

* Type fixes

* Type fixes for onboarding

* Extracts ConnectIntegration

* Extracts IntegrationListItem

* Extracts CalendarsList

* Uses CalendarList on onboarding

* Removes deprecated Alert

* Extracts DisconnectIntegration

* Extracts CalendarSwitch

* Extracts ConnectedCalendarsList

* Extracted connectedCalendar logic for reuse

* Extracted SubHeadingTitleWithConnections

* Type fixes

* Fetched connected calendars in onboarding

* Refreshes data on when adding/removing calendars on onboarding

* Removed testing code

* Type fixes

* Feedback

* Moved integration helpers

* I was sleepy

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Omar Lópezandkodiakhq[bot] authored and GitHub committed 2021-10-20 15:42:40 +00:00
1 parent bd99a06765
commit 85d7122e43
27 files changed
+698 -614

No files matched your search

+5 -1
View File
@@ -1,6 +1,10 @@
import React from "react";
const UsernameInput = React.forwardRef((props, ref) => (
interface UsernameInputProps extends React.ComponentPropsWithRef<"input"> {
label?: string;
}
const UsernameInput = React.forwardRef<HTMLInputElement, UsernameInputProps>((props, ref) => (
// todo, check if username is already taken here?
<div>
<label htmlFor="username" className="block text-sm font-medium text-gray-700">
+18 -8
View File
@@ -1,8 +1,13 @@
import React, { useEffect, useState } from "react";
export const WeekdaySelect = (props) => {
const [activeDays, setActiveDays] = useState(
[...Array(7).keys()].map((v, i) => (props.defaultValue || []).includes(i))
interface WeekdaySelectProps {
defaultValue: number[];
onSelect: (selected: number[]) => void;
}
export const WeekdaySelect = (props: WeekdaySelectProps) => {
const [activeDays, setActiveDays] = useState<boolean[]>(
Array.from(Array(7).keys()).map((v, i) => (props.defaultValue || []).includes(i))
);
const days = ["S", "M", "T", "W", "T", "F", "S"];
@@ -11,10 +16,9 @@ export const WeekdaySelect = (props) => {
props.onSelect(activeDays.map((v, idx) => (v ? idx : -1)).filter((v) => v !== -1));
}, [activeDays]);
const toggleDay = (e, idx: number) => {
e.preventDefault();
const toggleDay = (idx: number) => {
activeDays[idx] = !activeDays[idx];
setActiveDays([].concat(activeDays));
setActiveDays(([] as boolean[]).concat(activeDays));
};
return (
@@ -24,7 +28,10 @@ export const WeekdaySelect = (props) => {
activeDays[idx] ? (
<button
key={idx}
onClick={(e) => toggleDay(e, idx)}
onClick={(e) => {
e.preventDefault();
toggleDay(idx);
}}
className={`
w-10 h-10
bg-black text-white focus:outline-none px-3 py-1 rounded
@@ -38,7 +45,10 @@ export const WeekdaySelect = (props) => {
) : (
<button
key={idx}
onClick={(e) => toggleDay(e, idx)}
onClick={(e) => {
e.preventDefault();
toggleDay(idx);
}}
style={{ marginTop: "1px", marginBottom: "1px" }}
className={`w-10 h-10 bg-gray-50 focus:outline-none px-3 py-1 rounded-none ${
idx === 0 ? "rounded-l" : "border-l-0"
@@ -1,10 +1,10 @@
import React, { PropsWithChildren, useState } from "react";
import React, { ReactNode, useState } from "react";
import classNames from "@lib/classNames";
type RadioAreaProps = React.InputHTMLAttributes<HTMLInputElement> & {
onChange: (value: string) => void;
defaultChecked: boolean;
type RadioAreaProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
onChange?: (value: string) => void;
defaultChecked?: boolean;
};
const RadioArea = (props: RadioAreaProps) => {
@@ -16,9 +16,13 @@ const RadioArea = (props: RadioAreaProps) => {
props.className
)}>
<input
onChange={(e) => props.onChange(e.target.value)}
onChange={(e) => {
if (typeof props.onChange === "function") {
props.onChange(e.target.value);
}
}}
checked={props.checked}
className="float-right text-neutral-900 focus:ring-neutral-500 ml-3"
className="float-right ml-3 text-neutral-900 focus:ring-neutral-500"
name={props.name}
value={props.value}
type="radio"
@@ -28,17 +32,17 @@ const RadioArea = (props: RadioAreaProps) => {
);
};
type RadioAreaGroupProps = {
name?: string;
onChange?: (value) => void;
type ChildrenProps = {
props: RadioAreaProps;
children?: ReactNode;
};
interface RadioAreaGroupProps extends Omit<React.ComponentPropsWithoutRef<"div">, "onChange"> {
children: ChildrenProps | ChildrenProps[];
name?: string;
onChange?: (value: string) => void;
}
const RadioAreaGroup = ({
children,
name,
onChange,
...passThroughProps
}: PropsWithChildren<RadioAreaGroupProps>) => {
const RadioAreaGroup = ({ children, name, onChange, ...passThroughProps }: RadioAreaGroupProps) => {
const [checkedIdx, setCheckedIdx] = useState<number | null>(null);
const changeHandler = (value: string, idx: number) => {
@@ -50,23 +54,21 @@ const RadioAreaGroup = ({
return (
<div {...passThroughProps}>
{(Array.isArray(children) ? children : [children]).map(
(child: React.ReactElement<RadioAreaProps>, idx: number) => {
if (checkedIdx === null && child.props.defaultChecked) {
setCheckedIdx(idx);
}
return (
<Item
{...child.props}
key={idx}
name={name}
checked={idx === checkedIdx}
onChange={(value: string) => changeHandler(value, idx)}>
{child.props.children}
</Item>
);
{(Array.isArray(children) ? children : [children]).map((child, idx: number) => {
if (checkedIdx === null && child.props.defaultChecked) {
setCheckedIdx(idx);
}
)}
return (
<Item
{...child.props}
key={idx}
name={name}
checked={idx === checkedIdx}
onChange={(value: string) => changeHandler(value, idx)}>
{child.props.children}
</Item>
);
})}
</div>
);
};