2023-08-04 23:59:33 +03:00
|
|
|
import { LabeledFormGroup, OrderingDropdown, SimpleCard } from '@shlinkio/shlink-frontend-kit';
|
|
|
|
import type { Settings, ShortUrlsListSettings as ShortUrlsSettings } from '@shlinkio/shlink-web-component';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { FC } from 'react';
|
2023-08-02 09:23:48 +03:00
|
|
|
import { SHORT_URLS_ORDERABLE_FIELDS } from '../../shlink-web-component/src/short-urls/data';
|
2023-02-18 12:40:37 +03:00
|
|
|
import { DEFAULT_SHORT_URLS_ORDERING } from './reducers/settings';
|
2021-12-24 16:15:28 +03:00
|
|
|
|
2022-03-12 22:51:30 +03:00
|
|
|
interface ShortUrlsListSettingsProps {
|
2021-12-24 16:15:28 +03:00
|
|
|
settings: Settings;
|
2021-12-25 12:49:12 +03:00
|
|
|
setShortUrlsListSettings: (settings: ShortUrlsSettings) => void;
|
2021-12-24 16:15:28 +03:00
|
|
|
}
|
|
|
|
|
2022-03-12 22:51:30 +03:00
|
|
|
export const ShortUrlsListSettings: FC<ShortUrlsListSettingsProps> = (
|
2021-12-25 12:49:12 +03:00
|
|
|
{ settings: { shortUrlsList }, setShortUrlsListSettings },
|
|
|
|
) => (
|
2021-12-24 16:15:28 +03:00
|
|
|
<SimpleCard title="Short URLs list" className="h-100">
|
2022-03-05 21:57:48 +03:00
|
|
|
<LabeledFormGroup noMargin label="Default ordering for short URLs list:">
|
|
|
|
<OrderingDropdown
|
|
|
|
items={SHORT_URLS_ORDERABLE_FIELDS}
|
|
|
|
order={shortUrlsList?.defaultOrdering ?? DEFAULT_SHORT_URLS_ORDERING}
|
|
|
|
onChange={(field, dir) => setShortUrlsListSettings({ defaultOrdering: { field, dir } })}
|
|
|
|
/>
|
|
|
|
</LabeledFormGroup>
|
2021-12-24 16:15:28 +03:00
|
|
|
</SimpleCard>
|
|
|
|
);
|