11import type { RawLocation } from 'vue-router' ;
2+
23import { useRouter , useContext } from '@nuxtjs/composition-api' ;
34import { useUser } from '~/modules/customer/composables/useUser' ;
45import { useCart } from '~/modules/checkout/composables/useCart' ;
56
67type LinkGroup = { title : string , items : LinkGroupItem [ ] } ;
7- type LinkGroupItem = { label : string , link ?: RawLocation , listeners ?: Record < string , ( ) => ( Promise < void > | void ) > } ;
8+ type LinkGroupItem = { id : string , label : string , link ?: RawLocation } ;
89
910export const useSidebarLinkGroups = ( ) => {
1011 const { localeRoute } = useContext ( ) ;
1112 const { logout } = useUser ( ) ;
1213 const { clear } = useCart ( ) ;
13-
1414 const router = useRouter ( ) ;
15+
1516 const sidebarLinkGroups : LinkGroup [ ] = [
1617 {
1718 title : 'Personal details' ,
1819 items : [
1920 {
21+ id : 'my-profile' ,
2022 label : 'My profile' ,
2123 link : { name : 'customer-my-profile' } ,
2224 } ,
2325 {
26+ id : 'address-details' ,
2427 label : 'Addresses details' ,
2528 link : { name : 'customer-addresses-details' } ,
2629 } ,
2730 {
31+ id : 'my-newsletter' ,
2832 label : 'My newsletter' ,
2933 link : { name : 'customer-my-newsletter' } ,
3034 } ,
3135 {
36+ id : 'my-wishlist' ,
3237 label : 'My wishlist' ,
3338 link : { name : 'customer-my-wishlist' } ,
3439 } ,
@@ -38,26 +43,28 @@ export const useSidebarLinkGroups = () => {
3843 title : 'Order details' ,
3944 items : [
4045 {
46+ id : 'order-history' ,
4147 label : 'Order history' ,
4248 link : { name : 'customer-order-history' } ,
4349 } ,
4450 {
51+ id : 'my-reviews' ,
4552 label : 'My reviews' ,
4653 link : { name : 'customer-my-reviews' } ,
4754 } ,
4855 {
56+ id : 'log-out' ,
4957 label : 'Log out' ,
50- listeners : {
51- click : async ( ) => {
52- await logout ( { } ) ;
53- await clear ( { } ) ;
54- await router . push ( localeRoute ( { name : 'home' } ) ) ;
55- } ,
56- } ,
5758 } ,
5859 ] ,
5960 } ,
6061 ] ;
6162
62- return { sidebarLinkGroups } ;
63+ const logoutUser = async ( ) => {
64+ await logout ( { } ) ;
65+ await clear ( { } ) ;
66+ await router . push ( localeRoute ( { name : 'home' } ) ) ;
67+ } ;
68+
69+ return { sidebarLinkGroups, logoutUser } ;
6370} ;
0 commit comments