-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: replace orgId with slug for readability (#205)
* feat: add slug for org * change command name from camelCase to snake-case, use lowercase for organization's name, limit organization's name * query org in project layout * save orgSlug and orgId into store instead of getting from useParams --------- Co-authored-by: hudy9x <[email protected]>
- Loading branch information
Showing
148 changed files
with
12,966 additions
and
789 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
'use client' | ||
import HamburgerMenu from '@/components/HamburgerMenu' | ||
import ProjectSidebar from './ProjectSidebar' | ||
import { useOrgMemberGet } from '@/services/organizationMember' | ||
import EventUserProjectUpdate from '@/features/Events/EventUserProjectUpdate' | ||
import { useOrgIdBySlug } from '@/hooks/useOrgIdBySlug' | ||
import { Loading } from '@shared/ui' | ||
import { ReactNode, useEffect } from 'react' | ||
import { useGlobalDataFetch } from '@/features/GlobalData/useGlobalDataFetch' | ||
import { useGlobalDataStore } from '@/store/global' | ||
import { setLocalCache } from '@shared/libs' | ||
|
||
// NOTE: do not move these following function inside ProjectLayout | ||
// cuz it causes a re-render to the entire component | ||
// why ? because it contains useParams inside, and this will triggered as url updated | ||
function PrefetchOrgData() { | ||
useOrgMemberGet() | ||
return <></> | ||
} | ||
|
||
function OrgDetailContent({ children }: { children: ReactNode }) { | ||
const { orgId } = useGlobalDataStore() | ||
|
||
console.log('run in <OrgDetailContent/>', orgId) | ||
if (!orgId) { | ||
return <Loading className='h-screen w-screen items-center justify-center' title='Fetching organization data ...' /> | ||
} | ||
|
||
return <> | ||
<PrefetchOrgData /> | ||
<EventUserProjectUpdate /> | ||
<ProjectSidebar /> | ||
<main | ||
className="main-content w-full" | ||
style={{ width: 'calc(100% - 251px)' }}> | ||
<HamburgerMenu /> | ||
{children} | ||
</main> | ||
</> | ||
} | ||
|
||
// This will clear the global data as the org page unmount | ||
function OrgDetailClearGlobalData() { | ||
const { setOrgId } = useGlobalDataStore() | ||
|
||
useEffect(() => { | ||
return () => { | ||
console.log('Clear data inside Global data store !') | ||
setOrgId('') | ||
|
||
setLocalCache('ORG_ID', '') | ||
setLocalCache('ORG_SLUG', '') | ||
} | ||
}, []) | ||
return <></> | ||
} | ||
|
||
// This component used for fetching global data | ||
function OrgDetailFetchGlobalData() { | ||
useGlobalDataFetch() | ||
return <></> | ||
} | ||
|
||
export default function ProjectLayout({ | ||
children | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<> | ||
<OrgDetailFetchGlobalData /> | ||
<OrgDetailClearGlobalData /> | ||
<OrgDetailContent>{children}</OrgDetailContent> | ||
</> | ||
) | ||
} |
File renamed without changes.
Oops, something went wrong.