Skip to content

Commit f040135

Browse files
committed
fix: knit picks
1 parent 5fd094f commit f040135

File tree

11 files changed

+61
-36
lines changed

11 files changed

+61
-36
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/molecules/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export { Accordion } from "@components/molecules/accordion";
22
export { ActiveDeploymentWarning } from "@components/molecules/activeDeploymentWarning";
33
export { ActiveIndicator } from "@components/molecules/activeIndicator";
4-
export { AkTimezoneSelect } from "@components/molecules/timezone";
4+
export { TimezoneSelect } from "@components/molecules/timezone";
55
export { ConnectionTableStatus } from "@components/molecules/connectionTableStatus";
66
export { CopyButton } from "@components/molecules/copyButton";
77
export type { CopyButtonRef } from "@components/molecules/copyButton";

src/components/molecules/timezone.tsx

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
import React, { forwardRef, useCallback, useId, useMemo, useState } from "react";
1+
import React, { forwardRef, useId, useMemo } from "react";
22

3-
import { SingleValue } from "react-select";
4-
import TimezoneSelect from "react-timezone-select";
3+
import ReactTimezoneSelect, { useTimezoneSelect } from "react-timezone-select";
54

6-
import { getSelectDarkStyles, getSelectLightStyles } from "@constants";
7-
import { SelectOption, SelectProps } from "@interfaces/components";
5+
import { defaultTimezone, getSelectDarkStyles, getSelectLightStyles } from "@constants";
6+
import { ITimezoneOption, TimezoneSelectProps } from "@interfaces/components";
87
import { cn } from "@utilities";
98

109
import { Hint } from "@components/atoms";
1110

12-
const defaultTimezone = { label: "UTC", value: "UTC" };
13-
14-
interface TimezoneSelectProps extends Omit<SelectProps, "options" | "value" | "onChange"> {
15-
value?: string;
16-
onChange?: (value: SingleValue<SelectOption>) => void;
17-
}
18-
19-
export const AkTimezoneSelect = forwardRef<HTMLDivElement, TimezoneSelectProps>(
11+
const TimezoneSelectBase = forwardRef<HTMLDivElement, TimezoneSelectProps>(
2012
(
2113
{
2214
dataTestid,
@@ -33,17 +25,9 @@ export const AkTimezoneSelect = forwardRef<HTMLDivElement, TimezoneSelectProps>(
3325
},
3426
ref
3527
) => {
36-
const [selectedOption, setSelectedOption] = useState<any>(null);
28+
const { parseTimezone } = useTimezoneSelect({});
3729

38-
const timezoneValue = value ? { label: value, value } : defaultTimezone;
39-
40-
const handleChange = useCallback(
41-
(selected: any) => {
42-
setSelectedOption(selected);
43-
onChange?.(selected);
44-
},
45-
[onChange]
46-
);
30+
const timezoneValue: ITimezoneOption = value ? parseTimezone(value) : defaultTimezone;
4731

4832
const selectStyles = useMemo(
4933
() =>
@@ -57,8 +41,9 @@ export const AkTimezoneSelect = forwardRef<HTMLDivElement, TimezoneSelectProps>(
5741
"pointer-events-none absolute -top-2 left-3 px-1 text-xs opacity-100 transition-all before:bg-gray-950",
5842
{
5943
"before:bg-white": variant === "light",
60-
},
61-
{ "text-gray-900": variant === "light" }
44+
"text-gray-900": variant === "light",
45+
"text-white": variant !== "light",
46+
}
6247
),
6348
[variant]
6449
);
@@ -76,14 +61,14 @@ export const AkTimezoneSelect = forwardRef<HTMLDivElement, TimezoneSelectProps>(
7661
return (
7762
<>
7863
<div className="relative" data-testid={dataTestid} ref={ref}>
79-
<TimezoneSelect
64+
<ReactTimezoneSelect
8065
{...rest}
8166
id={id}
8267
isDisabled={disabled}
83-
onChange={handleChange}
68+
onChange={onChange}
8469
placeholder={isRequired ? `${placeholder} *` : placeholder}
8570
styles={selectStyles as any}
86-
value={selectedOption || timezoneValue}
71+
value={timezoneValue}
8772
/>
8873

8974
<label className={labelClass} htmlFor={id}>
@@ -97,4 +82,6 @@ export const AkTimezoneSelect = forwardRef<HTMLDivElement, TimezoneSelectProps>(
9782
}
9883
);
9984

100-
AkTimezoneSelect.displayName = "AkTimezoneSelect";
85+
TimezoneSelectBase.displayName = "TimezoneSelect";
86+
87+
export const TimezoneSelect = React.memo(TimezoneSelectBase);

src/components/organisms/configuration/triggers/formParts/scheduler.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useTranslation } from "react-i18next";
66
import { TriggerForm } from "@src/types/models";
77

88
import { ErrorMessage, Input } from "@components/atoms";
9-
import { AkTimezoneSelect } from "@components/molecules";
9+
import { TimezoneSelect } from "@components/molecules";
1010

1111
export const SchedulerFields = () => {
1212
const { t } = useTranslation("tabs", { keyPrefix: "triggers.form" });
@@ -37,20 +37,23 @@ export const SchedulerFields = () => {
3737
value={cronValue}
3838
/>
3939

40-
<ErrorMessage>{errors.cron?.message as string}</ErrorMessage>
40+
{errors.cron?.message ? <ErrorMessage>{errors.cron.message}</ErrorMessage> : null}
4141
</div>
4242

43-
<div>
43+
<div className="relative">
4444
<Controller
4545
control={control}
4646
name="timezone"
4747
render={({ field: { onChange, value } }) => (
48-
<AkTimezoneSelect
48+
<TimezoneSelect
49+
isError={!!errors.timezone}
4950
onChange={(selectedOption) => onChange(selectedOption?.value)}
5051
value={value}
5152
/>
5253
)}
5354
/>
55+
56+
{errors.timezone?.message ? <ErrorMessage>{errors.timezone.message}</ErrorMessage> : null}
5457
</div>
5558
</div>
5659
);

src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@ export {
120120
projectSessionsPathPatterns,
121121
} from "./pathPatterns.constants";
122122
export { defaultCodeFixSuggestion, defaultSuggestionAction } from "@constants/monacoEditor.constants";
123+
export { defaultTimezone } from "@constants/timezone.constants";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ITimezoneOption } from "@interfaces/components";
2+
3+
export const defaultTimezone: ITimezoneOption = { label: "UTC", value: "UTC" };

src/interfaces/components/forms/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export type {
1010
IntegrationSelectOption,
1111
} from "@interfaces/components/forms/select.interface";
1212
export type { TextArea } from "@interfaces/components/forms/textarea.interface";
13+
export type { ITimezoneOption, TimezoneSelectProps } from "@interfaces/components/forms/timezoneSelect.interface";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { SelectProps } from "@interfaces/components";
2+
3+
export interface ITimezoneOption {
4+
value: string;
5+
label: string;
6+
abbrev?: string;
7+
altName?: string;
8+
offset?: number;
9+
}
10+
11+
export interface TimezoneSelectProps extends Omit<SelectProps, "options" | "value" | "onChange"> {
12+
value?: string;
13+
onChange?: (timezone: ITimezoneOption) => void;
14+
}

src/interfaces/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export type { DrawerProps } from "@interfaces/components/drawer.interface";
1414
export type { ErrorMessageProps } from "@interfaces/components/error.interface";
1515
export type {
1616
InputProps,
17+
ITimezoneOption,
1718
PartialSelectOption,
1819
SelectOption,
1920
SelectProps,
2021
TextArea,
2122
SelectIconLabel,
23+
TimezoneSelectProps,
2224
} from "@interfaces/components/forms";
2325
export type { SecretInputProps } from "@interfaces/components/forms/secretInput.interface";
2426
export type { FrameProps, SplitFrameProps } from "@interfaces/components/frame.interface";

src/locales/en/tabs/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@
148148
"connectionRequired": "Connection is required",
149149
"functionRequired": "Entry function is required",
150150
"invalidCron": "Cron expression is required and must be valid for schedule triggers",
151-
"nameRequired": "Name is required"
151+
"nameRequired": "Name is required",
152+
"timezoneRequired": "Timezone is required for scheduled triggers"
152153
},
153154
"webhookInfo": {
154155
"firstLink": "https://docs.autokitteh.com/integrations/http/events/#event-types",

0 commit comments

Comments
 (0)