2023-08-04 22:59:33 +02:00
|
|
|
import { NavPillItem, NavPills } from '@shlinkio/shlink-frontend-kit';
|
2023-02-18 10:40:37 +01:00
|
|
|
import type { FC, ReactNode } from 'react';
|
2023-02-18 11:11:01 +01:00
|
|
|
import { Navigate, Route, Routes } from 'react-router-dom';
|
2021-12-30 10:02:31 +01:00
|
|
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
2023-09-05 09:08:42 +02:00
|
|
|
import type { FCWithDeps } from '../container/utils';
|
|
|
|
import { componentFactory, useDependencies } from '../container/utils';
|
|
|
|
|
|
|
|
type SettingsDeps = {
|
|
|
|
RealTimeUpdatesSettings: FC;
|
|
|
|
ShortUrlCreationSettings: FC;
|
|
|
|
ShortUrlsListSettings: FC;
|
|
|
|
UserInterfaceSettings: FC;
|
|
|
|
VisitsSettings: FC;
|
|
|
|
TagsSettings: FC;
|
|
|
|
};
|
2020-04-18 20:31:20 +02:00
|
|
|
|
2022-02-13 20:20:20 +01:00
|
|
|
const SettingsSections: FC<{ items: ReactNode[] }> = ({ items }) => (
|
2021-03-06 16:54:43 +01:00
|
|
|
<>
|
2022-02-13 20:20:20 +01:00
|
|
|
{items.map((child, index) => <div key={index} className="mb-3">{child}</div>)}
|
2021-03-06 16:54:43 +01:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
2023-09-05 09:08:42 +02:00
|
|
|
const Settings: FCWithDeps<{}, SettingsDeps> = () => {
|
|
|
|
const {
|
|
|
|
RealTimeUpdatesSettings: RealTimeUpdates,
|
|
|
|
ShortUrlCreationSettings: ShortUrlCreation,
|
|
|
|
ShortUrlsListSettings: ShortUrlsList,
|
|
|
|
UserInterfaceSettings: UserInterface,
|
|
|
|
VisitsSettings: Visits,
|
|
|
|
TagsSettings: Tags,
|
|
|
|
} = useDependencies(Settings);
|
2022-02-13 20:20:20 +01:00
|
|
|
|
2023-09-05 09:08:42 +02:00
|
|
|
return (
|
|
|
|
<NoMenuLayout>
|
|
|
|
<NavPills className="mb-3">
|
|
|
|
<NavPillItem to="general">General</NavPillItem>
|
|
|
|
<NavPillItem to="short-urls">Short URLs</NavPillItem>
|
|
|
|
<NavPillItem to="other-items">Other items</NavPillItem>
|
|
|
|
</NavPills>
|
|
|
|
|
|
|
|
<Routes>
|
|
|
|
<Route path="general" element={<SettingsSections items={[<UserInterface />, <RealTimeUpdates />]} />} />
|
|
|
|
<Route path="short-urls" element={<SettingsSections items={[<ShortUrlCreation />, <ShortUrlsList />]} />} />
|
|
|
|
<Route path="other-items" element={<SettingsSections items={[<Tags />, <Visits />]} />} />
|
|
|
|
<Route path="*" element={<Navigate replace to="general" />} />
|
|
|
|
</Routes>
|
|
|
|
</NoMenuLayout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SettingsFactory = componentFactory(Settings, [
|
|
|
|
'RealTimeUpdatesSettings',
|
|
|
|
'ShortUrlCreationSettings',
|
|
|
|
'ShortUrlsListSettings',
|
|
|
|
'UserInterfaceSettings',
|
|
|
|
'VisitsSettings',
|
|
|
|
'TagsSettings',
|
|
|
|
]);
|