Skip to content

Commit 4a347a6

Browse files
committed
refactor: update imports to use centralized store for dashboard components
1 parent f5c2f17 commit 4a347a6

File tree

6 files changed

+14
-32
lines changed

6 files changed

+14
-32
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,7 @@ import { DashboardNav } from '../../components/dashboard-nav';
1313
import { MobileDashboardNav } from '../../components/mobile-dashboard-nav';
1414
import styles from '../../components/styles.module.scss';
1515
import { getOrgDetailsQryDoc } from './schema';
16-
17-
interface DashboardStore {
18-
entityDetails: any;
19-
userDetails: any;
20-
setEntityDetails: (data: any) => void;
21-
setUserDetails: (data: any) => void;
22-
allEntityDetails: any;
23-
setAllEntityDetails: (data: any) => void;
24-
}
25-
26-
export const useDashboardStore = create<DashboardStore>((set) => ({
27-
entityDetails: null,
28-
userDetails: null,
29-
setEntityDetails: (data) => set({ entityDetails: data }),
30-
setUserDetails: (data) => set({ userDetails: data }),
31-
allEntityDetails: null,
32-
setAllEntityDetails: (data) => set({ allEntityDetails: data }),
33-
}));
16+
import { useDashboardStore } from '@/config/store';
3417

3518
interface DashboardLayoutProps {
3619
children?: React.ReactNode;

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/orgProfile.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useMutation } from '@tanstack/react-query';
99
import { useParams, useRouter } from 'next/navigation';
1010
import { Button, DropZone, Select, Text, TextField, toast } from 'opub-ui';
1111
import React, { useEffect } from 'react';
12-
import { useDashboardStore } from '../layout';
12+
import { useDashboardStore } from '@/config/store';
1313

1414
const organizationUpdateMutation: any = graphql(`
1515
mutation updateOrganization($input: OrganizationInputPartial!) {
@@ -82,8 +82,7 @@ const OrgProfile = () => {
8282
id: res?.updateOrganization?.id,
8383
});
8484
setEntityDetails({
85-
...entityDetails,
86-
organizations: [res?.updateOrganization],
85+
organizations: [formData],
8786
});
8887
if (res?.updateOrganization?.slug && res.updateOrganization.slug !== params.entitySlug) {
8988
const newPath = `/dashboard/${params.entityType}/${res.updateOrganization.slug}/profile`;
@@ -95,6 +94,7 @@ const OrgProfile = () => {
9594
},
9695
}
9796
);
97+
9898
const handleSave = () => {
9999
// Create mutation input with only changed fields
100100
const inputData: OrganizationInputPartial = {

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/userProfile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation } from '@tanstack/react-query';
88
import { Button, DropZone, Text, TextField, toast } from 'opub-ui';
99

1010
import { GraphQL } from '@/lib/api';
11-
import { useDashboardStore } from '../layout';
11+
import { useDashboardStore } from '@/config/store';
1212

1313
const updateUserMutation: any = graphql(`
1414
mutation updateUser($input: UpdateUserInput!) {

app/[locale]/dashboard/[entityType]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { GraphQL } from '@/lib/api';
1515
import { cn } from '@/lib/utils';
1616
import LoadingPage from '../loading';
1717
import styles from './../components/styles.module.scss';
18-
import { useDashboardStore } from './[entitySlug]/layout';
18+
import { useDashboardStore } from '@/config/store';
1919
import { organizationCreationMutation } from './schema';
2020

2121
const Page = () => {

app/[locale]/dashboard/components/main-nav.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
'use client';
22

3-
import React, { useEffect } from 'react';
4-
import Image from 'next/image';
5-
import Link from 'next/link';
6-
import { usePathname } from 'next/navigation';
73
import { useMetaKeyPress } from '@/hooks/use-meta-key-press';
84
import { Session } from 'next-auth';
95
import { signIn, signOut, useSession } from 'next-auth/react';
6+
import Image from 'next/image';
7+
import Link from 'next/link';
8+
import { usePathname } from 'next/navigation';
109
import {
1110
Avatar,
1211
Button,
@@ -19,14 +18,14 @@ import {
1918
Divider,
2019
IconButton,
2120
Popover,
22-
SearchInput,
2321
Spinner,
24-
Text,
22+
Text
2523
} from 'opub-ui';
24+
import React, { useEffect } from 'react';
2625

27-
import { GraphQL } from '@/lib/api';
2826
import { Icons } from '@/components/icons';
29-
import { useDashboardStore } from '../[entityType]/[entitySlug]/layout';
27+
import { useDashboardStore } from '@/config/store';
28+
import { GraphQL } from '@/lib/api';
3029
import { UserDetailsQryDoc } from '../[entityType]/[entitySlug]/schema';
3130
import { allOrganizationsListingDoc } from '../[entityType]/schema';
3231
import Sidebar from './sidebar';

app/[locale]/dashboard/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Icon, Text } from 'opub-ui';
55

66
import BreadCrumbs from '@/components/BreadCrumbs';
77
import { Icons } from '@/components/icons';
8-
import { useDashboardStore } from './[entityType]/[entitySlug]/layout';
8+
import { useDashboardStore } from '@/config/store';
99

1010
const UserDashboard = () => {
1111
const { userDetails, allEntityDetails } = useDashboardStore();

0 commit comments

Comments
 (0)