Skip to content

Commit fe93d6a

Browse files
committed
chore: useUserPrefernces function from dashboard
1 parent 729efdd commit fe93d6a

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

src/Shared/Components/ReactSelect/constants.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,21 @@ export const AppSelectorDropdownIndicator = (props: DropdownIndicatorProps) => {
190190
)
191191
}
192192

193-
export const AppSelectorNoOptionsMessage = (
194-
inputObj: { inputValue: string },
195-
hideCharacterResultInfo?: boolean,
196-
): string => {
197-
if (inputObj && (inputObj.inputValue === '' || inputObj.inputValue.length < 3) && !hideCharacterResultInfo) {
193+
/**
194+
*
195+
* @returns {string}
196+
* @description Returns the no matching result text for the select component.
197+
*/
198+
export const getNoMatchingResultText = () => NO_MATCHING_RESULT
199+
200+
/**
201+
* @param inputObj
202+
* @returns {string}
203+
* @description Returns the no options message for the select component.
204+
*/
205+
export const AppSelectorNoOptionsMessage = (inputObj: { inputValue: string }): string => {
206+
if (inputObj && (inputObj.inputValue === '' || inputObj.inputValue.length < 3)) {
198207
return TYPE_3_CHARACTERS_TO_SEE_MATCHING_RESULTS
199208
}
200-
return NO_MATCHING_RESULT
209+
return getNoMatchingResultText()
201210
}

src/Shared/Components/SelectPicker/SelectPicker.component.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
221221
borderRadiusConfig,
222222
labelTippyCustomizedConfig,
223223
labelTooltipConfig,
224+
shouldShowLoadingMessage = false,
224225
...props
225226
}: SelectPickerProps<OptionValue, IsMulti>) => {
226227
const innerRef = useRef<SelectPickerProps<OptionValue, IsMulti>['selectRef']['current']>(null)
@@ -331,6 +332,13 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
331332
return null
332333
}
333334

335+
const renderLoadingMessage = () => {
336+
if (shouldShowLoadingMessage) {
337+
return <p className="m-0 cn-7 fs-13 fw-4 lh-20 py-6 px-8">Loading...</p>
338+
}
339+
return null
340+
}
341+
334342
const renderDisabledTippy = (children: ReactElement) => (
335343
<Tippy content={disabledTippyContent} placement="top" className="default-tt" arrow={false}>
336344
{children}
@@ -454,6 +462,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
454462
MultiValueRemove: SelectPickerMultiValueRemove,
455463
GroupHeading: renderGroupHeading,
456464
NoOptionsMessage: renderNoOptionsMessage,
465+
LoadingMessage: renderLoadingMessage,
457466
Input: SelectPickerInput,
458467
...(shouldHideMenu && {
459468
Menu: () => null,

src/Shared/Components/SelectPicker/common.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ export const SelectPickerDropdownIndicator = <OptionValue,>(
7474

7575
return (
7676
<components.DropdownIndicator {...props}>
77-
{isLoading ? <Progressing /> : <ICCaretDown className={isDisabled ? 'scn-3' : 'scn-6'} />}
77+
{isLoading ? (
78+
<Progressing fillColor="var(--N500)" />
79+
) : (
80+
<ICCaretDown className={isDisabled ? 'scn-3' : 'scn-6'} />
81+
)}
7882
</components.DropdownIndicator>
7983
)
8084
}

src/Shared/Components/SelectPicker/type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
277277
* @default true
278278
*/
279279
shouldShowNoOptionsMessage?: boolean
280+
/**
281+
* If true, the loading message is shown when loading
282+
*
283+
* @default false
284+
*/
285+
shouldShowLoadingMessage?: boolean
280286
/**
281287
* If true, the menu list and the dropdown indicator are hidden. Suitable for use cases like multi-inputs
282288
*

0 commit comments

Comments
 (0)