get routing working

This commit is contained in:
paul sealock 2024-05-29 12:47:56 +12:00
parent e774182158
commit 5342b6cbcc
2 changed files with 10 additions and 4 deletions

View File

@ -18,7 +18,11 @@ const Settings = ( { params } ) => {
return (
<>
<Tabs data={ settingsData } page={ params.page } />
<Tabs data={ settingsData } page={ params.page }>
<p>
now editing <span>{ params.page }</span>
</p>
</Tabs>
</>
);
};

View File

@ -2,10 +2,12 @@
* External dependencies
*/
import { TabPanel } from '@wordpress/components';
import { getNewPath, navigateTo } from '@woocommerce/navigation';
export const Tabs = ( { data, page } ) => {
export const Tabs = ( { data, page, children } ) => {
const onSelect = ( tabName ) => {
console.log( 'Selecting tab', tabName );
const url = getNewPath( {}, `/settings/${ tabName }` );
navigateTo( { url } );
};
return (
@ -20,7 +22,7 @@ export const Tabs = ( { data, page } ) => {
title: data[ key ].label,
} ) ) }
>
{ ( tab ) => <p>{ tab.title }</p> }
{ () => <div>{ children }</div> }
</TabPanel>
</>
);