Skip to content

feat(RelativeRangeDatePicker): allow null values in relative range presets #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SkiffCMC
Copy link

I hereby agree to the terms of the CLA available at: [https://yandex.ru/legal/cla/?lang=en]

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

Comment on lines 91 to 93
allowNullableValues: true,
withPresets: true,
presetTabs: DEFAULT_RANGE_DATE_PICKER_PRESET,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you trying to mess with arguments of the default story? If you want to show example with custom presets, you can do it via argTypes or another story.

@@ -122,7 +127,7 @@ function PresetsList({presets, onChoosePreset, size = 'm'}: PresetsListProps) {
renderItem={(item) => item.title}
itemHeight={SIZE_TO_ITEM_HEIGHT[size]}
onItemClick={(item) => {
onChoosePreset(item.from, item.to);
onChoosePreset(item?.from, item?.to);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need optional chaining here?

Comment on lines 48 to 53
if (!start) {
return `${i18n('To')}: ${endText}`;
}
if (!end) {
return `${i18n('From')}: ${startText}`;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!start) {
return `${i18n('To')}: ${endText}`;
}
if (!end) {
return `${i18n('From')}: ${startText}`;
}
if (!startText) {
return `${i18n('To')}: ${endText}`;
}
if (!endText) {
return `${i18n('From')}: ${startText}`;
}

Comment on lines 55 to 56
if (end === 'now') {
const match = lastRe.exec(startText);
const match = lastRe.exec(startText || '');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (end === 'now') {
const match = lastRe.exec(startText);
const match = lastRe.exec(startText || '');
if (endText === 'now') {
const match = lastRe.exec(startText);

Comment on lines 47 to 59
let start, end;
if (value.start === null) {
start = null;
}
if (value.start?.type === 'relative') {
start = value.start?.value || '';
}
if (value.end === null) {
end = null;
}
if (value.end?.type === 'relative') {
end = value.end?.value || '';
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let start, end;
if (value.start === null) {
start = null;
}
if (value.start?.type === 'relative') {
start = value.start?.value || '';
}
if (value.end === null) {
end = null;
}
if (value.end?.type === 'relative') {
end = value.end?.value || '';
}
let start = null;
let end = null;
if (value.start?.type === 'relative') {
start = value.start.value;
}
if (value.end?.type === 'relative') {
end = value.end.value;
}

Comment on lines 36 to 37
start?: string | null,
end?: string | null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start?: string | null,
end?: string | null,
start: string | null,
end: string | null,

@@ -105,7 +121,7 @@ export function getDefaultPresetTabs({
if (withTime) {
mainPresets.unshift(...DEFAULT_TIME_PRESETS);
}
mainTab.presets = filterPresets(mainPresets, minValue);
mainTab.presets = filterPresets(mainPresets, minValue, allowNullableValues);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to filter DEFAULT_OTHERS_PRESETS with allowNullableValues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants