feat: allow timezones selection in Booker atom via prop (#20044)
* expose props to pass in timezones and booking dry run values from outside * fix merge conflicts * update typings * add props values to test * fixup: PR feedback * PR feedback * fix wrong prop name * fix merge conflicts * fixup * update docs * update docs examples * fix props naming * fix timezone component logic and typo * extract typings of timeZones * update typings for Timezone * update docs * resolve merge conflicts * fix typings --------- Co-authored-by: Morgan <[email protected]>
This commit is contained in:
1 parent
efeb0a8f41
commit
08d4c800e9
11 files changed
+488
-17
No files matched your search
@@ -48,9 +48,11 @@ export function TimezoneSelect(props: TimezoneSelectProps) {
|
||||
trpc: { context: { skipBatch: true } },
|
||||
}
|
||||
);
|
||||
const cityTimezonesFormatted = data.map(({ city, timezone }) => ({ label: city, timezone }));
|
||||
|
||||
return (
|
||||
<TimezoneSelectComponent
|
||||
data={data.map(({ city, timezone }) => ({ label: city, timezone }))}
|
||||
data={[...cityTimezonesFormatted, ...SELECT_SEARCH_DATA]}
|
||||
isPending={isPending}
|
||||
{...props}
|
||||
/>
|
||||
@@ -64,6 +66,7 @@ export type TimezoneSelectComponentProps = SelectProps & {
|
||||
timezoneSelectCustomClassname?: string;
|
||||
size?: "sm" | "md";
|
||||
grow?: boolean;
|
||||
isWebTimezoneSelect?: boolean;
|
||||
};
|
||||
|
||||
// TODO: I wonder if we move this to ui package, and keep the TRPC version in features
|
||||
@@ -77,9 +80,10 @@ export function TimezoneSelectComponent({
|
||||
value,
|
||||
size = "md",
|
||||
grow = false,
|
||||
isWebTimezoneSelect = true,
|
||||
...props
|
||||
}: TimezoneSelectComponentProps) {
|
||||
const data = [...(props.data || []), ...SELECT_SEARCH_DATA];
|
||||
const data = [...(props.data || [])];
|
||||
/*
|
||||
* we support multiple timezones for the different labels
|
||||
* e.g. 'Sao Paulo' and 'Brazil Time' both being 'America/Sao_Paulo'
|
||||
@@ -108,7 +112,7 @@ export function TimezoneSelectComponent({
|
||||
{...reactSelectProps}
|
||||
timezones={{
|
||||
...(props.data ? addTimezonesToDropdown(data) : {}),
|
||||
...addTimezonesToDropdown(additionalTimezones),
|
||||
...(isWebTimezoneSelect ? addTimezonesToDropdown(additionalTimezones) : {}),
|
||||
}}
|
||||
styles={{
|
||||
control: (base) => ({
|
||||
|
||||
Reference in new issue
Block a user