diff --git a/.prettierignore b/.prettierignore index 46a963e1..e69de29b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +0,0 @@ -packages/Firecamp-DB \ No newline at end of file diff --git a/platform/firecamp-platform/src/components/tabs/home/Home.tsx b/platform/firecamp-platform/src/components/tabs/home/Home.tsx index 54e9f8d6..6e59e3b4 100644 --- a/platform/firecamp-platform/src/components/tabs/home/Home.tsx +++ b/platform/firecamp-platform/src/components/tabs/home/Home.tsx @@ -9,6 +9,7 @@ import { FcIconSocketIoSquare, FcIconWebSocket, } from '@firecamp/ui'; +import { CalloutSection } from './HomeCalloutSection'; import { usePlatformStore } from '../../../store/platform'; import { useTabStore } from '../../../store/tab'; import { EThemeColor, EThemeMode } from '../../../types'; @@ -74,7 +75,7 @@ const Home: FC = () => { - + @@ -233,37 +234,3 @@ interface IRequestItem { /** Open request tab */ openRequest: () => void; } - -const InviteInfo = ({ organisation = true, info = {workspace: 'My Workspace', organisation: 'Firecamp'} }) => { - return ( -
-

- {organisation - ? `You're in the ${info.workspace} workspace of the ${info.organisation} organization.` - : `You're right now in your personal workspace`} -

- - {organisation ? ( -

- You can invite your team/colleagues to this workspace to work - collaboratively. -

- ) : ( -

- The personal workspace is not meant to work collaboratively, for now, - you can create an organization and invite your team/colleagues to work - collaboratively. -

- )} - - - {organisation - ? 'create an organization' - : 'invite your team/colleagues'} - -
- ); -}; diff --git a/platform/firecamp-platform/src/components/tabs/home/HomeCalloutSection.tsx b/platform/firecamp-platform/src/components/tabs/home/HomeCalloutSection.tsx new file mode 100644 index 00000000..6e324e0b --- /dev/null +++ b/platform/firecamp-platform/src/components/tabs/home/HomeCalloutSection.tsx @@ -0,0 +1,79 @@ +import shallow from 'zustand/shallow'; +import platformContext from '../../../services/platform-context'; +import { EPlatformScope, usePlatformStore } from '../../../store/platform'; +import { useWorkspaceStore } from '../../../store/workspace'; +import { useUserStore } from '../../../store/user'; + +const CalloutSection = () => { + const { workspace } = useWorkspaceStore( + (s) => ({ + workspace: s.workspace, + }), + shallow + ); + const { scope, organization } = usePlatformStore( + (s) => ({ + scope: s.scope, + organization: s.organization, + }), + shallow + ); + const { user, isGuest } = useUserStore( + (s) => ({ + user: s.user, + isGuest: s.isGuest, + }), + shallow + ); + + if (isGuest) return <>; + + if (scope == EPlatformScope.Person) { + return ( + platformContext.platform.createOrganizationPrompt()} + /> + ); + } + + // TODO: set role based condition here, if role is owner or admin then only show this callout message + const workspaceName = workspace.name; + const orgName = organization.name; + return ( + platformContext.app.modals.openInviteMembers()} + /> + ); +}; + +const CalloutBox = ({ + title = '', + description = '', + actionText = '', + action = () => {}, +}) => { + return ( +
+

{title}

+

{description}

+ { + e.preventDefault(); + action(); + }} + > + {actionText} + +
+ ); +}; + +export { CalloutSection }; diff --git a/platform/firecamp-platform/src/services/app.service.ts b/platform/firecamp-platform/src/services/app.service.ts index 84c7196d..89562647 100644 --- a/platform/firecamp-platform/src/services/app.service.ts +++ b/platform/firecamp-platform/src/services/app.service.ts @@ -37,7 +37,8 @@ const switchWorkspace = async ( AppService.initUser(user); AppService.initWorkspace(wrs); - AppService.initOrg(org as IOrganization); + const isPersonal = !wrs.__ref.orgId; + AppService.initOrg(isPersonal ? null : (org as IOrganization)); AppService.notify.success(`You have switched to ${wrs.name}`); await fetchExplorer(wrs.__ref.id); diff --git a/platform/firecamp-platform/src/store/platform.ts b/platform/firecamp-platform/src/store/platform.ts index 04049d48..d5f1e20e 100644 --- a/platform/firecamp-platform/src/store/platform.ts +++ b/platform/firecamp-platform/src/store/platform.ts @@ -68,8 +68,11 @@ export const usePlatformStore = create((set, get) => ({ }, setOrg: (org: Partial) => { - if (!org || !org.__ref?.id) return; - set({ scope: EPlatformScope.Organization, organization: org }); + if (!org || !org.__ref?.id) { + set({ scope: EPlatformScope.Person, organization: null }); + } else { + set({ scope: EPlatformScope.Organization, organization: org }); + } }, setSwitchingOrg: (org: Partial) => {