11import { mergeDeepRight } from '@shlinkio/data-manipulation' ;
22import { NavPillItem , NavPills } from '@shlinkio/shlink-frontend-kit' ;
3+ import { clsx } from 'clsx' ;
34import type { FC , PropsWithChildren } from 'react' ;
4- import { Children , useCallback } from 'react' ;
5+ import { useCallback } from 'react' ;
56import { Navigate , Route , Routes } from 'react-router' ;
67import type { DeepPartial } from '../../utils/types' ;
8+ import type { QrCodeSettings } from '..' ;
79import { SettingsProvider } from '..' ;
810import type { RealTimeUpdatesSettings , Settings , ShortUrlsListSettings } from '../types' ;
11+ import { QrCodeColorSettings } from './qr-codes/QrCodeColorSettings' ;
12+ import { QrCodeFormatSettings } from './qr-codes/QrCodeFormatSettings' ;
13+ import { QrCodeSizeSettings } from './qr-codes/QrCodeSizeSettings' ;
914import { RealTimeUpdatesSettings as RealTimeUpdates } from './RealTimeUpdatesSettings' ;
1015import { ShortUrlCreationSettings as ShortUrlCreation } from './ShortUrlCreationSettings' ;
1116import { ShortUrlsListSettings as ShortUrlsList } from './ShortUrlsListSettings' ;
@@ -23,9 +28,10 @@ export type ShlinkWebSettingsProps = {
2328 updateSettings ?: ( settings : Settings ) => void ;
2429} ;
2530
26- const SettingsSections : FC < PropsWithChildren > = ( { children } ) => Children . map (
27- children ,
28- ( child , index ) => < div key = { index } className = "mb-3" > { child } </ div > ,
31+ const SettingsSections : FC < PropsWithChildren < { className ?: string } > > = ( { children, className } ) => (
32+ < div className = { clsx ( 'd-flex flex-column gap-3' , className ) } >
33+ { children }
34+ </ div >
2935) ;
3036
3137export const ShlinkWebSettings : FC < ShlinkWebSettingsProps > = ( {
@@ -50,12 +56,17 @@ export const ShlinkWebSettings: FC<ShlinkWebSettingsProps> = ({
5056 < Prop extends keyof Settings > ( prop : Prop , value : Settings [ Prop ] ) => updatePartialSettings ( { [ prop ] : value } ) ,
5157 [ updatePartialSettings ] ,
5258 ) ;
59+ const updateQrCodeSettings = useCallback (
60+ ( s : QrCodeSettings ) => updateSettingsProp ( 'qrCodes' , s ) ,
61+ [ updateSettingsProp ] ,
62+ ) ;
5363
5464 return (
5565 < SettingsProvider value = { settings } >
5666 < NavPills className = "mb-3" >
5767 < NavPillItem to = "../general" > General</ NavPillItem >
5868 < NavPillItem to = "../short-urls" > Short URLs</ NavPillItem >
69+ < NavPillItem to = "../qr-codes" > QR codes</ NavPillItem >
5970 < NavPillItem to = "../other-items" > Other items</ NavPillItem >
6071 </ NavPills >
6172
@@ -64,10 +75,10 @@ export const ShlinkWebSettings: FC<ShlinkWebSettingsProps> = ({
6475 path = "general"
6576 element = { (
6677 < SettingsSections >
67- < UserInterfaceSettings updateUiSettings = { ( v ) => updateSettingsProp ( 'ui' , v ) } />
78+ < UserInterfaceSettings onChange = { ( v ) => updateSettingsProp ( 'ui' , v ) } />
6879 < RealTimeUpdates
6980 toggleRealTimeUpdates = { toggleRealTimeUpdates }
70- setRealTimeUpdatesInterval = { setRealTimeUpdatesInterval }
81+ onIntervalChange = { setRealTimeUpdatesInterval }
7182 />
7283 </ SettingsSections >
7384 ) }
@@ -76,10 +87,10 @@ export const ShlinkWebSettings: FC<ShlinkWebSettingsProps> = ({
7687 path = "short-urls"
7788 element = { (
7889 < SettingsSections >
79- < ShortUrlCreation updateShortUrlCreationSettings = { ( v ) => updateSettingsProp ( 'shortUrlCreation' , v ) } />
90+ < ShortUrlCreation onChange = { ( v ) => updateSettingsProp ( 'shortUrlCreation' , v ) } />
8091 < ShortUrlsList
8192 defaultOrdering = { defaultShortUrlsListOrdering }
82- updateShortUrlsListSettings = { ( v ) => updateSettingsProp ( 'shortUrlsList' , v ) }
93+ onChange = { ( v ) => updateSettingsProp ( 'shortUrlsList' , v ) }
8394 />
8495 </ SettingsSections >
8596 ) }
@@ -88,8 +99,20 @@ export const ShlinkWebSettings: FC<ShlinkWebSettingsProps> = ({
8899 path = "other-items"
89100 element = { (
90101 < SettingsSections >
91- < Tags updateTagsSettings = { ( v ) => updateSettingsProp ( 'tags' , v ) } />
92- < Visits updateVisitsSettings = { ( v ) => updateSettingsProp ( 'visits' , v ) } />
102+ < Tags onChange = { ( v ) => updateSettingsProp ( 'tags' , v ) } />
103+ < Visits onChange = { ( v ) => updateSettingsProp ( 'visits' , v ) } />
104+ </ SettingsSections >
105+ ) }
106+ />
107+ < Route
108+ path = "qr-codes"
109+ element = { (
110+ < SettingsSections >
111+ < div className = "d-flex flex-column flex-lg-row gap-3" >
112+ < QrCodeSizeSettings onChange = { updateQrCodeSettings } className = "w-100" />
113+ < QrCodeColorSettings onChange = { updateQrCodeSettings } className = "w-100" />
114+ </ div >
115+ < QrCodeFormatSettings onChange = { updateQrCodeSettings } />
93116 </ SettingsSections >
94117 ) }
95118 />
0 commit comments