@messenger-box/slack-ui-browser 10.0.3-alpha.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/lib/components/Home/Channels.js +62 -0
- package/lib/components/Home/Channels.js.map +1 -0
- package/lib/components/Home/DirectChannels.js +92 -0
- package/lib/components/Home/DirectChannels.js.map +1 -0
- package/lib/components/Home/InviteMembers.js +70 -0
- package/lib/components/Home/InviteMembers.js.map +1 -0
- package/lib/components/Home/Teams.js +62 -0
- package/lib/components/Home/Teams.js.map +1 -0
- package/lib/components/Home/TopCommonSlider.js +35 -0
- package/lib/components/Home/TopCommonSlider.js.map +1 -0
- package/lib/compute.js +223 -0
- package/lib/compute.js.map +1 -0
- package/lib/constants/routes.js +63 -0
- package/lib/constants/routes.js.map +1 -0
- package/lib/hooks/useOptimizedChannelsQueries.js +107 -0
- package/lib/hooks/useOptimizedChannelsQueries.js.map +1 -0
- package/lib/hooks/useRouteState.js +193 -0
- package/lib/hooks/useRouteState.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/machines/routeMachine.js +804 -0
- package/lib/machines/routeMachine.js.map +1 -0
- package/lib/module.js +3 -0
- package/lib/module.js.map +1 -0
- package/lib/queries/slackuiQueries.js +144 -0
- package/lib/queries/slackuiQueries.js.map +1 -0
- package/lib/routes.json +260 -0
- package/lib/screens/Home/HomeScreen.js +664 -0
- package/lib/screens/Home/HomeScreen.js.map +1 -0
- package/lib/screens/Home/index.js +1 -0
- package/lib/screens/Home/index.js.map +1 -0
- package/package.json +52 -0
- package/rollup.config.mjs +41 -0
- package/src/components/Home/Channels.tsx +135 -0
- package/src/components/Home/DirectChannels.tsx +185 -0
- package/src/components/Home/InviteMembers.tsx +134 -0
- package/src/components/Home/Teams.tsx +129 -0
- package/src/components/Home/TopCommonSlider.tsx +70 -0
- package/src/components/Home/index.ts +5 -0
- package/src/components/index.ts +1 -0
- package/src/compute.ts +156 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/routes.ts +92 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useOptimizedChannelsQueries.ts +165 -0
- package/src/hooks/useRouteState.ts +253 -0
- package/src/icons.ts +137 -0
- package/src/index.ts +11 -0
- package/src/machines/index.ts +9 -0
- package/src/machines/routeMachine.ts +682 -0
- package/src/module.tsx +6 -0
- package/src/queries/index.ts +1 -0
- package/src/queries/slackuiQueries.ts +227 -0
- package/src/screens/Home/HomeScreen.tsx +1308 -0
- package/src/screens/Home/index.ts +4 -0
- package/src/screens/NewChannel/NewChannelScreen.tsx +188 -0
- package/src/screens/NewChannel/index.ts +2 -0
- package/src/screens/index.ts +1 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import React,{createContext,useState,useMemo,useEffect,useCallback}from'react';import {useSelector}from'react-redux';import {userSelector}from'@adminide-stack/user-auth0-client';import {useLocation,useNavigate}from'@remix-run/react';import {RoomType,ApplicationRoles}from'common';import'@react-icons/all-files/fi/FiChevronDown.js';import'@react-icons/all-files/fi/FiChevronRight.js';import'@react-icons/all-files/fi/FiChevronLeft.js';import'@react-icons/all-files/fi/FiPlus.js';import {FiSearch}from'@react-icons/all-files/fi/FiSearch.js';import {FiHash}from'@react-icons/all-files/fi/FiHash.js';import {FiLock}from'@react-icons/all-files/fi/FiLock.js';import'@react-icons/all-files/fi/FiRefreshCw.js';import {FiUser}from'@react-icons/all-files/fi/FiUser.js';import {FiUserPlus}from'@react-icons/all-files/fi/FiUserPlus.js';import {FiShare2}from'@react-icons/all-files/fi/FiShare2.js';import {FiMail}from'@react-icons/all-files/fi/FiMail.js';import {FiX}from'@react-icons/all-files/fi/FiX.js';import {FiEdit}from'@react-icons/all-files/fi/FiEdit.js';import'@react-icons/all-files/fi/FiEdit2.js';import {FiMessageSquare}from'@react-icons/all-files/fi/FiMessageSquare.js';import {FiBookmark}from'@react-icons/all-files/fi/FiBookmark.js';import'@react-icons/all-files/fi/FiSend.js';import'@react-icons/all-files/fi/FiMoreHorizontal.js';import'@react-icons/all-files/fi/FiMoreVertical.js';import'@react-icons/all-files/fi/FiSettings.js';import'@react-icons/all-files/fi/FiHome.js';import'@react-icons/all-files/fi/FiInbox.js';import {FiUsers}from'@react-icons/all-files/fi/FiUsers.js';import'@react-icons/all-files/fi/FiMessageCircle.js';import {FiBell}from'@react-icons/all-files/fi/FiBell.js';import'@react-icons/all-files/fi/FiLogOut.js';import'@react-icons/all-files/fi/FiMenu.js';import'@react-icons/all-files/fi/FiTrash2.js';import'@react-icons/all-files/fi/FiCopy.js';import {FiCheck}from'@react-icons/all-files/fi/FiCheck.js';import {FiAlertCircle}from'@react-icons/all-files/fi/FiAlertCircle.js';import'@react-icons/all-files/fi/FiInfo.js';import'@react-icons/all-files/vsc/VscChromeClose.js';import'@react-icons/all-files/vsc/VscAdd.js';import'@react-icons/all-files/vsc/VscSearch.js';import'@react-icons/all-files/vsc/VscMenu.js';import'@react-icons/all-files/go/GoGlobe.js';import'@react-icons/all-files/go/GoOrganization.js';import'@react-icons/all-files/go/GoPerson.js';import'@react-icons/all-files/go/GoComment.js';import'@react-icons/all-files/ri/RiAdminFill.js';import'@react-icons/all-files/ri/RiAdminLine.js';import'@react-icons/all-files/ri/RiTeamLine.js';import'@react-icons/all-files/ri/RiTeamFill.js';import'@react-icons/all-files/ai/AiOutlineHome.js';import'@react-icons/all-files/ai/AiOutlineInbox.js';import'@react-icons/all-files/ai/AiOutlineMessage.js';import'@react-icons/all-files/ai/AiOutlineTeam.js';import'@react-icons/all-files/ai/AiOutlineSetting.js';import'@react-icons/all-files/ai/AiOutlineUser.js';import'@react-icons/all-files/ai/AiOutlinePlus.js';import'@react-icons/all-files/ai/AiOutlineClose.js';import'@react-icons/all-files/ai/AiOutlineSearch.js';import'@react-icons/all-files/ai/AiOutlineEdit.js';import'@react-icons/all-files/ai/AiOutlineDelete.js';import'@react-icons/all-files/ai/AiOutlineSend.js';import'@react-icons/all-files/ai/AiOutlineBell.js';import'@react-icons/all-files/ai/AiOutlineLogout.js';import'@react-icons/all-files/ai/AiOutlineMenu.js';import'@react-icons/all-files/ai/AiOutlineCopy.js';import'@react-icons/all-files/ai/AiOutlineCheck.js';import'@react-icons/all-files/ai/AiOutlineWarning.js';import'@react-icons/all-files/ai/AiOutlineInfoCircle.js';import'@react-icons/all-files/bs/BsHash.js';import'@react-icons/all-files/bs/BsLock.js';import'@react-icons/all-files/bs/BsPeople.js';import'@react-icons/all-files/bs/BsPerson.js';import'@react-icons/all-files/bs/BsChat.js';import'@react-icons/all-files/bs/BsChatDots.js';import'@react-icons/all-files/bs/BsThreeDots.js';import'@react-icons/all-files/bs/BsThreeDotsVertical.js';import'@react-icons/all-files/hi/HiOutlineHashtag.js';import'@react-icons/all-files/hi/HiOutlineLockClosed.js';import'@react-icons/all-files/hi/HiOutlineUserGroup.js';import'@react-icons/all-files/hi/HiOutlineUser.js';import'@react-icons/all-files/hi/HiOutlineChat.js';import'@react-icons/all-files/hi/HiOutlinePencil.js';import'@react-icons/all-files/hi/HiOutlineDotsHorizontal.js';import'@react-icons/all-files/hi/HiOutlineDotsVertical.js';import'@react-icons/all-files/hi/HiOutlinePlus.js';import'@react-icons/all-files/hi/HiOutlineX.js';import'@react-icons/all-files/hi/HiOutlineSearch.js';import'@react-icons/all-files/hi/HiOutlineHome.js';import'@react-icons/all-files/hi/HiOutlineInbox.js';import'@react-icons/all-files/hi/HiOutlineBell.js';import'@react-icons/all-files/hi/HiOutlineCog.js';import'@react-icons/all-files/io/IoMdAdd.js';import'@react-icons/all-files/io/IoMdClose.js';import'@react-icons/all-files/io/IoMdSearch.js';import'@react-icons/all-files/io/IoMdMenu.js';import'@react-icons/all-files/io/IoMdSettings.js';import'@react-icons/all-files/io/IoMdPerson.js';import'@react-icons/all-files/io/IoMdPeople.js';import'@react-icons/all-files/io/IoMdChatbubbles.js';import'@react-icons/all-files/io/IoMdNotifications.js';import'@react-icons/all-files/md/MdAdd.js';import'@react-icons/all-files/md/MdClose.js';import'@react-icons/all-files/md/MdSearch.js';import'@react-icons/all-files/md/MdMenu.js';import'@react-icons/all-files/md/MdSettings.js';import'@react-icons/all-files/md/MdPerson.js';import'@react-icons/all-files/md/MdPeople.js';import'@react-icons/all-files/md/MdChat.js';import'@react-icons/all-files/md/MdNotifications.js';import'@react-icons/all-files/md/MdHome.js';import'@react-icons/all-files/md/MdInbox.js';import'@react-icons/all-files/md/MdEdit.js';import'@react-icons/all-files/md/MdDelete.js';import'@react-icons/all-files/md/MdSend.js';import'@react-icons/all-files/md/MdRefresh.js';import'@react-icons/all-files/md/MdMoreHoriz.js';import'@react-icons/all-files/md/MdMoreVert.js';import'@react-icons/all-files/md/MdLock.js';import'@react-icons/all-files/md/MdPublic.js';import {FiFile}from'@react-icons/all-files/fi/FiFile.js';import {TopCommonSlider}from'../../components/Home/TopCommonSlider.js';import {Teams}from'../../components/Home/Teams.js';import {Channels}from'../../components/Home/Channels.js';import {DirectChannels}from'../../components/Home/DirectChannels.js';import {InviteMembers}from'../../components/Home/InviteMembers.js';import {useOptimizedChannelsQueries}from'../../hooks/useOptimizedChannelsQueries.js';import {useRouteState}from'../../hooks/useRouteState.js';import {slackUiRoutePaths}from'../../constants/routes.js';import {useAddChannelMutation,useAddDirectChannelMutation,useCreateTeamMutation,useSendOrganizationInvitationMutation}from'../../queries/slackuiQueries.js';import {useGetOrganizationMembersQuery,useGetOrganizationDetailQuery}from'common/graphql';const RefetchContext = createContext({
|
|
2
|
+
shouldRefetch: false,
|
|
3
|
+
setRefetchStatus: (status) => {
|
|
4
|
+
}
|
|
5
|
+
});
|
|
6
|
+
const ChannelsDataContext = createContext({
|
|
7
|
+
channelsData: [],
|
|
8
|
+
directChannelsData: [],
|
|
9
|
+
loading: false,
|
|
10
|
+
error: null,
|
|
11
|
+
refetchChannels: () => {
|
|
12
|
+
},
|
|
13
|
+
hasChannels: false,
|
|
14
|
+
hasDirectChannels: false
|
|
15
|
+
});
|
|
16
|
+
const HomeScreen = () => {
|
|
17
|
+
const currentUser = useSelector(userSelector);
|
|
18
|
+
const location = useLocation();
|
|
19
|
+
const navigate = useNavigate();
|
|
20
|
+
const [shouldRefetch, setShouldRefetch] = useState(false);
|
|
21
|
+
const orgSlug = location.pathname.split("/")[2];
|
|
22
|
+
const {
|
|
23
|
+
channelsData,
|
|
24
|
+
directChannelsData,
|
|
25
|
+
loading,
|
|
26
|
+
error,
|
|
27
|
+
refetchChannels,
|
|
28
|
+
hasChannels,
|
|
29
|
+
hasDirectChannels
|
|
30
|
+
} = useOptimizedChannelsQueries({
|
|
31
|
+
orgName: orgSlug,
|
|
32
|
+
enabled: !!orgSlug
|
|
33
|
+
});
|
|
34
|
+
const refetchContextValue = useMemo(() => ({
|
|
35
|
+
shouldRefetch,
|
|
36
|
+
setRefetchStatus: setShouldRefetch
|
|
37
|
+
}), [shouldRefetch]);
|
|
38
|
+
const channelsDataContextValue = useMemo(() => ({
|
|
39
|
+
channelsData,
|
|
40
|
+
directChannelsData,
|
|
41
|
+
loading,
|
|
42
|
+
error,
|
|
43
|
+
refetchChannels,
|
|
44
|
+
hasChannels,
|
|
45
|
+
hasDirectChannels
|
|
46
|
+
}), [channelsData, directChannelsData, loading, error, refetchChannels, hasChannels, hasDirectChannels]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (orgSlug) {
|
|
49
|
+
refetchChannels();
|
|
50
|
+
}
|
|
51
|
+
}, [orgSlug]);
|
|
52
|
+
const handleNewMessage = useCallback(() => {
|
|
53
|
+
navigate(slackUiRoutePaths.messageNew(orgSlug));
|
|
54
|
+
}, [navigate, orgSlug]);
|
|
55
|
+
if (!currentUser) {
|
|
56
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full bg-white", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-500" }) });
|
|
57
|
+
}
|
|
58
|
+
if (!orgSlug) {
|
|
59
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full bg-white", children: /* @__PURE__ */ jsx("p", { className: "text-gray-500", children: "No Organization found" }) });
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsx(RefetchContext.Provider, { value: refetchContextValue, children: /* @__PURE__ */ jsx(ChannelsDataContext.Provider, { value: channelsDataContextValue, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full bg-white", children: [
|
|
62
|
+
/* @__PURE__ */ jsxs("div", { className: "w-72 flex-shrink-0 border-r border-gray-200 flex flex-col h-full overflow-hidden", children: [
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 border-b border-gray-200", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-900 truncate", children: orgSlug }) }),
|
|
64
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto", children: [
|
|
65
|
+
/* @__PURE__ */ jsx(TopCommonSlider, {}),
|
|
66
|
+
/* @__PURE__ */ jsx("hr", { className: "border-gray-200 my-2" }),
|
|
67
|
+
/* @__PURE__ */ jsx(Teams, { teams: [], loading: false, error: null, onRefetch: () => {
|
|
68
|
+
} }),
|
|
69
|
+
/* @__PURE__ */ jsx("hr", { className: "border-gray-200 my-2" }),
|
|
70
|
+
/* @__PURE__ */ jsx(Channels, { channels: channelsData, loading, error, onRefetch: refetchChannels, currentUser }),
|
|
71
|
+
/* @__PURE__ */ jsx("hr", { className: "border-gray-200 my-2" }),
|
|
72
|
+
/* @__PURE__ */ jsx(DirectChannels, { directChannels: directChannelsData, loading, error, onRefetch: refetchChannels, currentUser }),
|
|
73
|
+
/* @__PURE__ */ jsx("hr", { className: "border-gray-200 my-2" }),
|
|
74
|
+
/* @__PURE__ */ jsx(InviteMembers, { organizationName: orgSlug })
|
|
75
|
+
] }),
|
|
76
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 border-t border-gray-200", children: /* @__PURE__ */ jsxs("button", { onClick: handleNewMessage, className: "w-full flex items-center justify-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors", children: [
|
|
77
|
+
/* @__PURE__ */ jsx(FiEdit, { className: "w-4 h-4" }),
|
|
78
|
+
/* @__PURE__ */ jsx("span", { children: "New Message" })
|
|
79
|
+
] }) })
|
|
80
|
+
] }),
|
|
81
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col h-full overflow-hidden", children: /* @__PURE__ */ jsx(MessagePanel, { orgSlug, currentUser, channelsData, directChannelsData }) })
|
|
82
|
+
] }) }) });
|
|
83
|
+
};
|
|
84
|
+
const MessagePanel = ({
|
|
85
|
+
orgSlug,
|
|
86
|
+
currentUser,
|
|
87
|
+
channelsData,
|
|
88
|
+
directChannelsData
|
|
89
|
+
}) => {
|
|
90
|
+
const routeState = useRouteState(orgSlug);
|
|
91
|
+
const {
|
|
92
|
+
currentState,
|
|
93
|
+
channelName,
|
|
94
|
+
teamName,
|
|
95
|
+
isHome,
|
|
96
|
+
isChannelView,
|
|
97
|
+
isChannelNew,
|
|
98
|
+
isMessageView,
|
|
99
|
+
isMessageNew,
|
|
100
|
+
isTeamView,
|
|
101
|
+
isTeamNew,
|
|
102
|
+
isThreads,
|
|
103
|
+
isActivity,
|
|
104
|
+
isDrafts,
|
|
105
|
+
isSaved,
|
|
106
|
+
isFiles,
|
|
107
|
+
isSearch,
|
|
108
|
+
isInvite,
|
|
109
|
+
isInviteContacts,
|
|
110
|
+
isInviteEmail,
|
|
111
|
+
isInviteLink,
|
|
112
|
+
navigateToHome,
|
|
113
|
+
navigateToChannel,
|
|
114
|
+
navigateToChannelNew,
|
|
115
|
+
navigateToMessage,
|
|
116
|
+
navigateToMessageNew
|
|
117
|
+
} = routeState;
|
|
118
|
+
const selectedChannel = useMemo(() => {
|
|
119
|
+
if (isChannelView && channelName) {
|
|
120
|
+
return channelsData.find((ch) => ch.title === channelName || ch.name === channelName);
|
|
121
|
+
}
|
|
122
|
+
if (isMessageView && channelName) {
|
|
123
|
+
return directChannelsData.find((dm) => {
|
|
124
|
+
var _a;
|
|
125
|
+
return dm.title === channelName || dm.name === channelName || ((_a = dm.displayName) == null ? void 0 : _a.includes(channelName));
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}, [isChannelView, isMessageView, channelName, channelsData, directChannelsData]);
|
|
130
|
+
if (isChannelNew) {
|
|
131
|
+
return /* @__PURE__ */ jsx(NewChannelPanel, { orgSlug, onClose: navigateToHome });
|
|
132
|
+
}
|
|
133
|
+
if (isMessageNew) {
|
|
134
|
+
return /* @__PURE__ */ jsx(NewMessagePanel, { orgSlug, currentUser, onClose: navigateToHome });
|
|
135
|
+
}
|
|
136
|
+
if (isTeamNew) {
|
|
137
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Create a Team", icon: /* @__PURE__ */ jsx(FiUsers, { className: "w-12 h-12 text-blue-600" }), description: "Teams help organize groups of people working together", orgSlug, onClose: navigateToHome, children: /* @__PURE__ */ jsx(NewTeamForm, { orgSlug, onClose: navigateToHome }) });
|
|
138
|
+
}
|
|
139
|
+
if (isTeamView && teamName) {
|
|
140
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: `Team: ${teamName}`, icon: /* @__PURE__ */ jsx(FiUsers, { className: "w-12 h-12 text-blue-600" }), description: "Team details and members", orgSlug });
|
|
141
|
+
}
|
|
142
|
+
if (isThreads) {
|
|
143
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Threads", icon: /* @__PURE__ */ jsx(FiMessageSquare, { className: "w-12 h-12 text-blue-600" }), description: "Your thread replies will appear here", orgSlug });
|
|
144
|
+
}
|
|
145
|
+
if (isInviteContacts) {
|
|
146
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Invite from Contacts", icon: /* @__PURE__ */ jsx(FiUserPlus, { className: "w-12 h-12 text-blue-600" }), description: "Select contacts to invite to your workspace", orgSlug, onClose: () => routeState.navigateToInvite(), children: /* @__PURE__ */ jsx(InviteContactsForm, { orgSlug }) });
|
|
147
|
+
}
|
|
148
|
+
if (isInviteEmail) {
|
|
149
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Invite by Email", icon: /* @__PURE__ */ jsx(FiMail, { className: "w-12 h-12 text-blue-600" }), description: "Send email invitations to join your workspace", orgSlug, onClose: () => routeState.navigateToInvite(), children: /* @__PURE__ */ jsx(InviteEmailForm, { orgSlug }) });
|
|
150
|
+
}
|
|
151
|
+
if (isInviteLink) {
|
|
152
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Invite Link", icon: /* @__PURE__ */ jsx(FiShare2, { className: "w-12 h-12 text-blue-600" }), description: "Share this link to invite people to your workspace", orgSlug, onClose: () => routeState.navigateToInvite(), children: /* @__PURE__ */ jsx(InviteLinkForm, { orgSlug }) });
|
|
153
|
+
}
|
|
154
|
+
if (isInvite) {
|
|
155
|
+
return /* @__PURE__ */ jsx(InvitePanel, { orgSlug, routeState });
|
|
156
|
+
}
|
|
157
|
+
if (isActivity) {
|
|
158
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Activity", icon: /* @__PURE__ */ jsx(FiBell, { className: "w-12 h-12 text-blue-600" }), description: "Your recent activity and notifications", orgSlug });
|
|
159
|
+
}
|
|
160
|
+
if (isDrafts) {
|
|
161
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Drafts", icon: /* @__PURE__ */ jsx(FiEdit, { className: "w-12 h-12 text-blue-600" }), description: "Your unsent message drafts", orgSlug });
|
|
162
|
+
}
|
|
163
|
+
if (isSaved) {
|
|
164
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Saved Items", icon: /* @__PURE__ */ jsx(FiBookmark, { className: "w-12 h-12 text-blue-600" }), description: "Messages and files you've saved for later", orgSlug });
|
|
165
|
+
}
|
|
166
|
+
if (isFiles) {
|
|
167
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Files", icon: /* @__PURE__ */ jsx(FiFile, { className: "w-12 h-12 text-blue-600" }), description: "Files shared in your workspace", orgSlug });
|
|
168
|
+
}
|
|
169
|
+
if (isSearch) {
|
|
170
|
+
return /* @__PURE__ */ jsx(GenericPanel, { title: "Search", icon: /* @__PURE__ */ jsx(FiSearch, { className: "w-12 h-12 text-blue-600" }), description: "Search messages, files, and channels", orgSlug, children: /* @__PURE__ */ jsx(SearchForm, { orgSlug }) });
|
|
171
|
+
}
|
|
172
|
+
if (selectedChannel) {
|
|
173
|
+
return /* @__PURE__ */ jsx(ChannelMessagingView, { channel: selectedChannel, currentUser, isDirectMessage: isMessageView });
|
|
174
|
+
}
|
|
175
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col items-center justify-center text-gray-500 p-8", children: [
|
|
176
|
+
/* @__PURE__ */ jsx("div", { className: "w-24 h-24 bg-blue-100 rounded-full flex items-center justify-center mb-6", children: /* @__PURE__ */ jsx(FiMessageSquare, { className: "w-12 h-12 text-blue-600" }) }),
|
|
177
|
+
/* @__PURE__ */ jsxs("h3", { className: "text-xl font-semibold text-gray-900 mb-2", children: [
|
|
178
|
+
"Welcome to ",
|
|
179
|
+
orgSlug
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ jsx("p", { className: "text-center text-gray-600 mb-6 max-w-md", children: "Select a channel or direct message from the sidebar to start chatting, or create a new conversation." }),
|
|
182
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("button", { onClick: navigateToChannelNew, className: "flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors", children: [
|
|
184
|
+
/* @__PURE__ */ jsx(FiHash, { className: "w-4 h-4" }),
|
|
185
|
+
/* @__PURE__ */ jsx("span", { children: "Create Channel" })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ jsxs("button", { onClick: navigateToMessageNew, className: "flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors", children: [
|
|
188
|
+
/* @__PURE__ */ jsx(FiEdit, { className: "w-4 h-4" }),
|
|
189
|
+
/* @__PURE__ */ jsx("span", { children: "New Message" })
|
|
190
|
+
] })
|
|
191
|
+
] })
|
|
192
|
+
] });
|
|
193
|
+
};
|
|
194
|
+
const NewChannelPanel = ({
|
|
195
|
+
orgSlug,
|
|
196
|
+
onClose,
|
|
197
|
+
onSuccess
|
|
198
|
+
}) => {
|
|
199
|
+
const [channelName, setChannelName] = useState("");
|
|
200
|
+
const [description, setDescription] = useState("");
|
|
201
|
+
const [isPrivate, setIsPrivate] = useState(false);
|
|
202
|
+
const [error, setError] = useState(null);
|
|
203
|
+
const navigate = useNavigate();
|
|
204
|
+
const [createChannel, {
|
|
205
|
+
loading: isLoading
|
|
206
|
+
}] = useAddChannelMutation({
|
|
207
|
+
onCompleted: (data) => {
|
|
208
|
+
if (data == null ? void 0 : data.createChannel) {
|
|
209
|
+
const createdChannel = data.createChannel;
|
|
210
|
+
navigate(slackUiRoutePaths.channel(orgSlug, createdChannel.title || createdChannel.name));
|
|
211
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
onError: (err) => {
|
|
215
|
+
console.error("Error creating channel:", err);
|
|
216
|
+
setError(err.message || "Failed to create channel. Please try again.");
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const handleSubmit = async (e) => {
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
if (!channelName.trim()) return;
|
|
222
|
+
setError(null);
|
|
223
|
+
createChannel({
|
|
224
|
+
variables: {
|
|
225
|
+
name: channelName.toLowerCase().replace(/\s+/g, "-"),
|
|
226
|
+
description: description || void 0,
|
|
227
|
+
type: isPrivate ? RoomType.Private : RoomType.Public
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col h-full", children: [
|
|
232
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200", children: [
|
|
233
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-900", children: "Create a Channel" }),
|
|
234
|
+
/* @__PURE__ */ jsx("button", { onClick: onClose, className: "p-2 hover:bg-gray-100 rounded-full", children: /* @__PURE__ */ jsx(FiX, { className: "w-5 h-5 text-gray-500" }) })
|
|
235
|
+
] }),
|
|
236
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex-1 overflow-y-auto p-6 space-y-6", children: [
|
|
237
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
238
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700", children: "Channel Type" }),
|
|
239
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
|
|
240
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setIsPrivate(false), className: `flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-colors ${!isPrivate ? "border-blue-500 bg-blue-50" : "border-gray-200 hover:border-gray-300"}`, children: [
|
|
241
|
+
/* @__PURE__ */ jsx(FiHash, { className: `w-5 h-5 ${!isPrivate ? "text-blue-600" : "text-gray-400"}` }),
|
|
242
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
243
|
+
/* @__PURE__ */ jsx("div", { className: `font-medium ${!isPrivate ? "text-blue-700" : "text-gray-700"}`, children: "Public" }),
|
|
244
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500", children: "Anyone can join" })
|
|
245
|
+
] })
|
|
246
|
+
] }),
|
|
247
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setIsPrivate(true), className: `flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-colors ${isPrivate ? "border-blue-500 bg-blue-50" : "border-gray-200 hover:border-gray-300"}`, children: [
|
|
248
|
+
/* @__PURE__ */ jsx(FiLock, { className: `w-5 h-5 ${isPrivate ? "text-blue-600" : "text-gray-400"}` }),
|
|
249
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
250
|
+
/* @__PURE__ */ jsx("div", { className: `font-medium ${isPrivate ? "text-blue-700" : "text-gray-700"}`, children: "Private" }),
|
|
251
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500", children: "Invite only" })
|
|
252
|
+
] })
|
|
253
|
+
] })
|
|
254
|
+
] })
|
|
255
|
+
] }),
|
|
256
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
257
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700", children: "Name" }),
|
|
258
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
259
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-gray-400", children: isPrivate ? /* @__PURE__ */ jsx(FiLock, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx(FiHash, { className: "w-4 h-4" }) }),
|
|
260
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: channelName, onChange: (e) => setChannelName(e.target.value.toLowerCase().replace(/\s+/g, "-")), placeholder: "e.g. marketing", className: "w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" })
|
|
261
|
+
] })
|
|
262
|
+
] }),
|
|
263
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
264
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium text-gray-700", children: [
|
|
265
|
+
"Description ",
|
|
266
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "(optional)" })
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ jsx("textarea", { value: description, onChange: (e) => setDescription(e.target.value), placeholder: "What's this channel about?", rows: 3, className: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none" })
|
|
269
|
+
] }),
|
|
270
|
+
error && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700", children: [
|
|
271
|
+
/* @__PURE__ */ jsx(FiAlertCircle, { className: "w-5 h-5 flex-shrink-0" }),
|
|
272
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: error })
|
|
273
|
+
] }),
|
|
274
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: !channelName.trim() || isLoading, className: "w-full py-3 bg-blue-600 text-white rounded-lg font-medium hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors", children: isLoading ? "Creating..." : "Create Channel" })
|
|
275
|
+
] })
|
|
276
|
+
] });
|
|
277
|
+
};
|
|
278
|
+
const NewMessagePanel = ({
|
|
279
|
+
orgSlug,
|
|
280
|
+
currentUser,
|
|
281
|
+
onClose,
|
|
282
|
+
onSuccess
|
|
283
|
+
}) => {
|
|
284
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
285
|
+
const [selectedUsers, setSelectedUsers] = useState([]);
|
|
286
|
+
const [error, setError] = useState(null);
|
|
287
|
+
const navigate = useNavigate();
|
|
288
|
+
const {
|
|
289
|
+
data: membersData,
|
|
290
|
+
loading: membersLoading
|
|
291
|
+
} = useGetOrganizationMembersQuery({
|
|
292
|
+
variables: {
|
|
293
|
+
orgName: orgSlug
|
|
294
|
+
},
|
|
295
|
+
skip: !orgSlug
|
|
296
|
+
});
|
|
297
|
+
const [createDirectChannel, {
|
|
298
|
+
loading: isLoading
|
|
299
|
+
}] = useAddDirectChannelMutation({
|
|
300
|
+
onCompleted: (data) => {
|
|
301
|
+
if (data == null ? void 0 : data.createDirectChannel) {
|
|
302
|
+
const channel = data.createDirectChannel;
|
|
303
|
+
navigate(slackUiRoutePaths.message(orgSlug, channel.title || channel.name || channel.id));
|
|
304
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
onError: (err) => {
|
|
308
|
+
console.error("Error creating direct channel:", err);
|
|
309
|
+
setError(err.message || "Failed to start conversation. Please try again.");
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
const filteredMembers = useMemo(() => {
|
|
313
|
+
var _a;
|
|
314
|
+
if (!((_a = membersData == null ? void 0 : membersData.getOrganizationMembers) == null ? void 0 : _a.data)) return [];
|
|
315
|
+
const members = membersData.getOrganizationMembers.data;
|
|
316
|
+
const availableMembers = members.filter((member) => member.id !== (currentUser == null ? void 0 : currentUser.id) && !selectedUsers.some((u) => u.id === member.id));
|
|
317
|
+
if (!searchQuery.trim()) return availableMembers;
|
|
318
|
+
const query = searchQuery.toLowerCase();
|
|
319
|
+
return availableMembers.filter((member) => {
|
|
320
|
+
var _a2, _b, _c;
|
|
321
|
+
return ((_a2 = member.username) == null ? void 0 : _a2.toLowerCase().includes(query)) || ((_b = member.email) == null ? void 0 : _b.toLowerCase().includes(query)) || ((_c = member.name) == null ? void 0 : _c.toLowerCase().includes(query));
|
|
322
|
+
});
|
|
323
|
+
}, [membersData, searchQuery, selectedUsers, currentUser]);
|
|
324
|
+
const handleSelectUser = (user) => {
|
|
325
|
+
setSelectedUsers([...selectedUsers, user]);
|
|
326
|
+
setSearchQuery("");
|
|
327
|
+
};
|
|
328
|
+
const handleStartConversation = () => {
|
|
329
|
+
if (selectedUsers.length === 0) return;
|
|
330
|
+
setError(null);
|
|
331
|
+
const receiverIds = selectedUsers.map((u) => u.id);
|
|
332
|
+
const displayName = selectedUsers.length === 1 ? selectedUsers[0].username : selectedUsers.map((u) => u.username).join(", ");
|
|
333
|
+
createDirectChannel({
|
|
334
|
+
variables: {
|
|
335
|
+
receiver: receiverIds,
|
|
336
|
+
displayName,
|
|
337
|
+
channelOptions: {
|
|
338
|
+
schemeAdmin: false
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col h-full", children: [
|
|
344
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200", children: [
|
|
345
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-900", children: "New Message" }),
|
|
346
|
+
/* @__PURE__ */ jsx("button", { onClick: onClose, className: "p-2 hover:bg-gray-100 rounded-full", children: /* @__PURE__ */ jsx(FiX, { className: "w-5 h-5 text-gray-500" }) })
|
|
347
|
+
] }),
|
|
348
|
+
/* @__PURE__ */ jsx("div", { className: "px-6 py-4 border-b border-gray-200", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
349
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "To:" }),
|
|
350
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-wrap gap-2", children: [
|
|
351
|
+
selectedUsers.map((user, idx) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-700 rounded-full text-sm", children: [
|
|
352
|
+
user.username || user.email,
|
|
353
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setSelectedUsers(selectedUsers.filter((_, i) => i !== idx)), children: /* @__PURE__ */ jsx(FiX, { className: "w-3 h-3" }) })
|
|
354
|
+
] }, idx)),
|
|
355
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), placeholder: "Search for people...", className: "flex-1 min-w-[200px] outline-none" })
|
|
356
|
+
] })
|
|
357
|
+
] }) }),
|
|
358
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-6", children: [
|
|
359
|
+
membersLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-500" }) }) : filteredMembers.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2", children: filteredMembers.map((member) => /* @__PURE__ */ jsxs("button", { onClick: () => handleSelectUser(member), className: "w-full flex items-center gap-3 p-3 rounded-lg hover:bg-gray-100 transition-colors text-left", children: [
|
|
360
|
+
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 bg-gray-300 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx(FiUser, { className: "w-5 h-5 text-gray-600" }) }),
|
|
361
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
362
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: member.username || member.name }),
|
|
363
|
+
member.email && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: member.email })
|
|
364
|
+
] })
|
|
365
|
+
] }, member.id)) }) : searchQuery ? /* @__PURE__ */ jsxs("div", { className: "text-center text-gray-500 py-8", children: [
|
|
366
|
+
/* @__PURE__ */ jsx(FiUser, { className: "w-12 h-12 mx-auto mb-3 text-gray-300" }),
|
|
367
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
368
|
+
'No members found matching "',
|
|
369
|
+
searchQuery,
|
|
370
|
+
'"'
|
|
371
|
+
] })
|
|
372
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "text-center text-gray-500 py-8", children: [
|
|
373
|
+
/* @__PURE__ */ jsx(FiUser, { className: "w-12 h-12 mx-auto mb-3 text-gray-300" }),
|
|
374
|
+
/* @__PURE__ */ jsx("p", { children: "Search for people to start a conversation" })
|
|
375
|
+
] }),
|
|
376
|
+
error && /* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700", children: [
|
|
377
|
+
/* @__PURE__ */ jsx(FiAlertCircle, { className: "w-5 h-5 flex-shrink-0" }),
|
|
378
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: error })
|
|
379
|
+
] })
|
|
380
|
+
] }),
|
|
381
|
+
selectedUsers.length > 0 && /* @__PURE__ */ jsx("div", { className: "p-4 border-t border-gray-200", children: /* @__PURE__ */ jsx("button", { onClick: handleStartConversation, disabled: isLoading, className: `w-full py-3 rounded-lg font-medium transition-colors ${isLoading ? "bg-gray-400 text-gray-200 cursor-not-allowed" : "bg-blue-600 text-white hover:bg-blue-700"}`, children: isLoading ? "Creating..." : "Start Conversation" }) })
|
|
382
|
+
] });
|
|
383
|
+
};
|
|
384
|
+
const GenericPanel = ({
|
|
385
|
+
title,
|
|
386
|
+
icon,
|
|
387
|
+
description,
|
|
388
|
+
orgSlug,
|
|
389
|
+
onClose,
|
|
390
|
+
children
|
|
391
|
+
}) => {
|
|
392
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col h-full", children: [
|
|
393
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200", children: [
|
|
394
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-900", children: title }),
|
|
395
|
+
onClose && /* @__PURE__ */ jsx("button", { onClick: onClose, className: "p-2 hover:bg-gray-100 rounded-full", children: /* @__PURE__ */ jsx(FiX, { className: "w-5 h-5 text-gray-500" }) })
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-6", children: children ? children : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full text-center", children: [
|
|
398
|
+
/* @__PURE__ */ jsx("div", { className: "w-24 h-24 bg-blue-100 rounded-full flex items-center justify-center mb-6", children: icon }),
|
|
399
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xl font-semibold text-gray-900 mb-2", children: title }),
|
|
400
|
+
/* @__PURE__ */ jsx("p", { className: "text-gray-600 max-w-md", children: description })
|
|
401
|
+
] }) })
|
|
402
|
+
] });
|
|
403
|
+
};
|
|
404
|
+
const InvitePanel = ({
|
|
405
|
+
orgSlug,
|
|
406
|
+
routeState
|
|
407
|
+
}) => {
|
|
408
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col h-full", children: [
|
|
409
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center px-6 py-4 border-b border-gray-200", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-900", children: "Invite People" }) }),
|
|
410
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-6", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md mx-auto space-y-4", children: [
|
|
411
|
+
/* @__PURE__ */ jsxs("p", { className: "text-gray-600 text-center mb-6", children: [
|
|
412
|
+
"Choose how you'd like to invite people to ",
|
|
413
|
+
orgSlug
|
|
414
|
+
] }),
|
|
415
|
+
/* @__PURE__ */ jsxs("button", { onClick: () => routeState.navigateToInviteContacts(), className: "w-full flex items-center gap-4 p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors", children: [
|
|
416
|
+
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx(FiUserPlus, { className: "w-5 h-5 text-blue-600" }) }),
|
|
417
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
418
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: "From Contacts" }),
|
|
419
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: "Invite from your contact list" })
|
|
420
|
+
] })
|
|
421
|
+
] }),
|
|
422
|
+
/* @__PURE__ */ jsxs("button", { onClick: () => routeState.navigateToInviteEmail(), className: "w-full flex items-center gap-4 p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors", children: [
|
|
423
|
+
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 bg-green-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx(FiMail, { className: "w-5 h-5 text-green-600" }) }),
|
|
424
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
425
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: "By Email" }),
|
|
426
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: "Send email invitations" })
|
|
427
|
+
] })
|
|
428
|
+
] }),
|
|
429
|
+
/* @__PURE__ */ jsxs("button", { onClick: () => routeState.navigateToInviteLink(), className: "w-full flex items-center gap-4 p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors", children: [
|
|
430
|
+
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx(FiShare2, { className: "w-5 h-5 text-purple-600" }) }),
|
|
431
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
432
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: "Share Link" }),
|
|
433
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: "Copy and share an invite link" })
|
|
434
|
+
] })
|
|
435
|
+
] })
|
|
436
|
+
] }) })
|
|
437
|
+
] });
|
|
438
|
+
};
|
|
439
|
+
const NewTeamForm = ({
|
|
440
|
+
orgSlug,
|
|
441
|
+
onClose
|
|
442
|
+
}) => {
|
|
443
|
+
const [teamName, setTeamName] = useState("");
|
|
444
|
+
const [description, setDescription] = useState("");
|
|
445
|
+
const [formError, setFormError] = useState(null);
|
|
446
|
+
const navigate = useNavigate();
|
|
447
|
+
const [createTeam, {
|
|
448
|
+
loading,
|
|
449
|
+
error
|
|
450
|
+
}] = useCreateTeamMutation({
|
|
451
|
+
context: {
|
|
452
|
+
headers: {
|
|
453
|
+
orgname: orgSlug
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
onCompleted: (data) => {
|
|
457
|
+
if (data == null ? void 0 : data.createTeam) {
|
|
458
|
+
const teamSlug = data.createTeam.name || teamName.toLowerCase().replace(/\s+/g, "-");
|
|
459
|
+
navigate(slackUiRoutePaths.team(orgSlug, teamSlug));
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
onError: (err) => {
|
|
463
|
+
console.error("Error creating team:", err);
|
|
464
|
+
setFormError(err.message || "Failed to create team. Please try again.");
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
const handleSubmit = async (e) => {
|
|
468
|
+
e.preventDefault();
|
|
469
|
+
if (!teamName.trim()) return;
|
|
470
|
+
setFormError(null);
|
|
471
|
+
createTeam({
|
|
472
|
+
variables: {
|
|
473
|
+
orgName: orgSlug,
|
|
474
|
+
request: {
|
|
475
|
+
name: teamName.trim().toLowerCase().replace(/\s+/g, "-"),
|
|
476
|
+
title: teamName.trim(),
|
|
477
|
+
description: description.trim() || void 0
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [
|
|
483
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
484
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700", children: "Team Name" }),
|
|
485
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: teamName, onChange: (e) => setTeamName(e.target.value), placeholder: "e.g. Engineering", className: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" })
|
|
486
|
+
] }),
|
|
487
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
488
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium text-gray-700", children: [
|
|
489
|
+
"Description ",
|
|
490
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "(optional)" })
|
|
491
|
+
] }),
|
|
492
|
+
/* @__PURE__ */ jsx("textarea", { value: description, onChange: (e) => setDescription(e.target.value), placeholder: "What's this team about?", rows: 3, className: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none" })
|
|
493
|
+
] }),
|
|
494
|
+
(formError || error) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700", children: [
|
|
495
|
+
/* @__PURE__ */ jsx(FiAlertCircle, { className: "w-5 h-5 flex-shrink-0" }),
|
|
496
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: formError || (error == null ? void 0 : error.message) || "An error occurred" })
|
|
497
|
+
] }),
|
|
498
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: !teamName.trim() || loading, className: `w-full py-3 rounded-lg font-medium transition-colors ${loading ? "bg-gray-400 text-gray-200 cursor-not-allowed" : "bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"}`, children: loading ? "Creating..." : "Create Team" })
|
|
499
|
+
] });
|
|
500
|
+
};
|
|
501
|
+
const InviteContactsForm = ({
|
|
502
|
+
orgSlug
|
|
503
|
+
}) => {
|
|
504
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
505
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
506
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), placeholder: "Search contacts...", className: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" }),
|
|
507
|
+
/* @__PURE__ */ jsxs("div", { className: "text-center text-gray-500 py-8", children: [
|
|
508
|
+
/* @__PURE__ */ jsx(FiUsers, { className: "w-12 h-12 mx-auto mb-3 text-gray-300" }),
|
|
509
|
+
/* @__PURE__ */ jsx("p", { children: "Search for contacts to invite" })
|
|
510
|
+
] })
|
|
511
|
+
] });
|
|
512
|
+
};
|
|
513
|
+
const InviteEmailForm = ({
|
|
514
|
+
orgSlug
|
|
515
|
+
}) => {
|
|
516
|
+
var _a;
|
|
517
|
+
const [email, setEmail] = useState("");
|
|
518
|
+
const [emails, setEmails] = useState([]);
|
|
519
|
+
const [formError, setFormError] = useState(null);
|
|
520
|
+
const [successMessage, setSuccessMessage] = useState(null);
|
|
521
|
+
const {
|
|
522
|
+
data: orgData
|
|
523
|
+
} = useGetOrganizationDetailQuery({
|
|
524
|
+
variables: {
|
|
525
|
+
where: {
|
|
526
|
+
name: orgSlug
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
skip: !orgSlug
|
|
530
|
+
});
|
|
531
|
+
const orgId = (_a = orgData == null ? void 0 : orgData.getOrganizationDetail) == null ? void 0 : _a.id;
|
|
532
|
+
const [sendInvitation, {
|
|
533
|
+
loading,
|
|
534
|
+
error
|
|
535
|
+
}] = useSendOrganizationInvitationMutation({
|
|
536
|
+
onCompleted: (data) => {
|
|
537
|
+
if (data == null ? void 0 : data.sendOrganizationInvitation) {
|
|
538
|
+
setSuccessMessage(`Invitation${emails.length > 1 ? "s" : ""} sent successfully!`);
|
|
539
|
+
setEmails([]);
|
|
540
|
+
setEmail("");
|
|
541
|
+
setTimeout(() => setSuccessMessage(null), 3e3);
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
onError: (err) => {
|
|
545
|
+
console.error("Error sending invitation:", err);
|
|
546
|
+
setFormError(err.message || "Failed to send invitation. Please try again.");
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
const handleAddEmail = () => {
|
|
550
|
+
const trimmedEmail = email.trim().toLowerCase();
|
|
551
|
+
if (trimmedEmail && !emails.includes(trimmedEmail) && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmedEmail)) {
|
|
552
|
+
setEmails([...emails, trimmedEmail]);
|
|
553
|
+
setEmail("");
|
|
554
|
+
setFormError(null);
|
|
555
|
+
} else if (trimmedEmail && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmedEmail)) {
|
|
556
|
+
setFormError("Please enter a valid email address");
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
const handleSendInvitations = async () => {
|
|
560
|
+
if (emails.length === 0) return;
|
|
561
|
+
if (!orgId) {
|
|
562
|
+
setFormError("Organization not found. Please try again.");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
setFormError(null);
|
|
566
|
+
setSuccessMessage(null);
|
|
567
|
+
for (const emailAddr of emails) {
|
|
568
|
+
await sendInvitation({
|
|
569
|
+
variables: {
|
|
570
|
+
request: {
|
|
571
|
+
email: emailAddr,
|
|
572
|
+
orgId,
|
|
573
|
+
orgName: orgSlug,
|
|
574
|
+
role: ApplicationRoles.Member
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
581
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
582
|
+
/* @__PURE__ */ jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), placeholder: "Enter email address", className: "flex-1 px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500", onKeyDown: (e) => e.key === "Enter" && (e.preventDefault(), handleAddEmail()) }),
|
|
583
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleAddEmail, className: "px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors", children: "Add" })
|
|
584
|
+
] }),
|
|
585
|
+
emails.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: emails.map((e, idx) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 px-3 py-1 bg-blue-100 text-blue-700 rounded-full text-sm", children: [
|
|
586
|
+
e,
|
|
587
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setEmails(emails.filter((_, i) => i !== idx)), children: /* @__PURE__ */ jsx(FiX, { className: "w-3 h-3" }) })
|
|
588
|
+
] }, idx)) }),
|
|
589
|
+
(formError || error) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700", children: [
|
|
590
|
+
/* @__PURE__ */ jsx(FiAlertCircle, { className: "w-5 h-5 flex-shrink-0" }),
|
|
591
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: formError || (error == null ? void 0 : error.message) || "An error occurred" })
|
|
592
|
+
] }),
|
|
593
|
+
successMessage && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-3 bg-green-50 border border-green-200 rounded-lg text-green-700", children: [
|
|
594
|
+
/* @__PURE__ */ jsx(FiCheck, { className: "w-5 h-5 flex-shrink-0" }),
|
|
595
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: successMessage })
|
|
596
|
+
] }),
|
|
597
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleSendInvitations, disabled: emails.length === 0 || loading, className: `w-full py-3 rounded-lg font-medium transition-colors ${loading ? "bg-gray-400 text-gray-200 cursor-not-allowed" : "bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"}`, children: loading ? "Sending..." : "Send Invitations" })
|
|
598
|
+
] });
|
|
599
|
+
};
|
|
600
|
+
const InviteLinkForm = ({
|
|
601
|
+
orgSlug
|
|
602
|
+
}) => {
|
|
603
|
+
const inviteLink = `${window.location.origin}/o/${orgSlug}/join`;
|
|
604
|
+
const [copied, setCopied] = useState(false);
|
|
605
|
+
const handleCopy = () => {
|
|
606
|
+
navigator.clipboard.writeText(inviteLink);
|
|
607
|
+
setCopied(true);
|
|
608
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
609
|
+
};
|
|
610
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
611
|
+
/* @__PURE__ */ jsxs("p", { className: "text-gray-600 text-sm", children: [
|
|
612
|
+
"Share this link with anyone you'd like to invite to ",
|
|
613
|
+
orgSlug
|
|
614
|
+
] }),
|
|
615
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
616
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: inviteLink, readOnly: true, className: "flex-1 px-4 py-3 border border-gray-300 rounded-lg bg-gray-50 text-gray-600" }),
|
|
617
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleCopy, className: "px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors", children: copied ? "Copied!" : "Copy" })
|
|
618
|
+
] })
|
|
619
|
+
] });
|
|
620
|
+
};
|
|
621
|
+
const SearchForm = ({
|
|
622
|
+
orgSlug
|
|
623
|
+
}) => {
|
|
624
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
625
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
626
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), placeholder: "Search messages, files, and channels...", className: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" }),
|
|
627
|
+
/* @__PURE__ */ jsxs("div", { className: "text-center text-gray-500 py-8", children: [
|
|
628
|
+
/* @__PURE__ */ jsx(FiSearch, { className: "w-12 h-12 mx-auto mb-3 text-gray-300" }),
|
|
629
|
+
/* @__PURE__ */ jsx("p", { children: "Enter a search term to find messages, files, and channels" })
|
|
630
|
+
] })
|
|
631
|
+
] });
|
|
632
|
+
};
|
|
633
|
+
const ChannelMessagingView = ({
|
|
634
|
+
channel,
|
|
635
|
+
currentUser,
|
|
636
|
+
isDirectMessage
|
|
637
|
+
}) => {
|
|
638
|
+
const [message, setMessage] = useState("");
|
|
639
|
+
const handleSendMessage = (e) => {
|
|
640
|
+
e.preventDefault();
|
|
641
|
+
if (!message.trim()) return;
|
|
642
|
+
console.log("Sending message:", message);
|
|
643
|
+
setMessage("");
|
|
644
|
+
};
|
|
645
|
+
const channelTitle = (channel == null ? void 0 : channel.title) || (channel == null ? void 0 : channel.name) || (channel == null ? void 0 : channel.displayName) || "Channel";
|
|
646
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col h-full", children: [
|
|
647
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center px-6 py-4 border-b border-gray-200", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
648
|
+
isDirectMessage ? /* @__PURE__ */ jsx("div", { className: "w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx(FiUser, { className: "w-4 h-4 text-gray-600" }) }) : /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: (channel == null ? void 0 : channel.type) === "PRIVATE" ? /* @__PURE__ */ jsx(FiLock, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(FiHash, { className: "w-5 h-5" }) }),
|
|
649
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
650
|
+
/* @__PURE__ */ jsx("h2", { className: "font-semibold text-gray-900", children: channelTitle }),
|
|
651
|
+
(channel == null ? void 0 : channel.description) && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 truncate", children: channel.description })
|
|
652
|
+
] })
|
|
653
|
+
] }) }),
|
|
654
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-6", children: /* @__PURE__ */ jsx("div", { className: "text-center text-gray-500 py-8", children: /* @__PURE__ */ jsxs("p", { className: "text-sm", children: [
|
|
655
|
+
"This is the start of your conversation in ",
|
|
656
|
+
/* @__PURE__ */ jsx("strong", { children: channelTitle })
|
|
657
|
+
] }) }) }),
|
|
658
|
+
/* @__PURE__ */ jsx("form", { onSubmit: handleSendMessage, className: "p-4 border-t border-gray-200", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
659
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: message, onChange: (e) => setMessage(e.target.value), placeholder: `Message ${isDirectMessage ? "" : "#"}${channelTitle}`, className: "flex-1 px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" }),
|
|
660
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: !message.trim(), className: "px-6 py-3 bg-blue-600 text-white rounded-lg font-medium hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors", children: "Send" })
|
|
661
|
+
] }) })
|
|
662
|
+
] });
|
|
663
|
+
};
|
|
664
|
+
var HomeScreen$1 = React.memo(HomeScreen);export{ChannelsDataContext,RefetchContext,HomeScreen$1 as default};//# sourceMappingURL=HomeScreen.js.map
|