From cc4e9f13483c7fe1d92d857187b4821dc88eb4cf Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Fri, 4 Apr 2025 01:17:55 -0400
Subject: [PATCH] Fix channel join

---
 src/components/common/Input/index.tsx         |  8 ++--
 .../CreateChannelView/CreateChannelView.tsx   | 47 +++++++++++++++++--
 2 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/src/components/common/Input/index.tsx b/src/components/common/Input/index.tsx
index 96558ec..73af715 100644
--- a/src/components/common/Input/index.tsx
+++ b/src/components/common/Input/index.tsx
@@ -19,10 +19,10 @@ const Input: FC<Props> = ({ size = 'md', ...props }) => (
       w-full block
       rounded-[1.5rem]
       px-4
-      bg-transparent
-      border border-[var(--charcoal-1)]
-      focus:outline-none focus:border-[var(--primary)]
-      placeholder:text-sm placeholder:text-[var(--charcoal-1)]
+      bg-charcoal-4
+      border border-charcoal-1
+      focus:outline-none focus:border-primary
+      placeholder:text-sm placeholder:text-charcoal-1
       ${sizeMap[size]}
       ${props.className || ''}
     `}
diff --git a/src/components/modals/CreateChannelView/CreateChannelView.tsx b/src/components/modals/CreateChannelView/CreateChannelView.tsx
index ddb25b9..a4f3239 100644
--- a/src/components/modals/CreateChannelView/CreateChannelView.tsx
+++ b/src/components/modals/CreateChannelView/CreateChannelView.tsx
@@ -55,16 +55,44 @@ const CreateChannelView: FC = () => {
 
   const onCreate = useCallback(async () => {
     if (error) {
+      console.error('Validation error:', error);
       return;
     }
 
+    const trimmedName = channelName.trim();
+  
+    // Log the actual values for debugging
+    console.log('Attempting to create channel with:', {
+      name: trimmedName,
+      nameLength: trimmedName.length,
+      description: channelDesc,
+      privacyLevel,
+      dmsEnabled
+    });
+
     try {
-      createChannel(channelName, channelDesc, privacyLevel, dmsEnabled);
+      if (!trimmedName) {
+        alert({
+          type: 'error',
+          content: t('Channel name is required')
+        });
+        return;
+      }
+
+      if (!regex.test(trimmedName)) {
+        alert({
+          type: 'error',
+          content: t('Invalid channel name format')
+        });
+        return;
+      }
+
+      await createChannel(trimmedName, channelDesc, privacyLevel, dmsEnabled);
       setChannelName('');
       setChannelDesc('');
       closeModal();
     } catch (e) {
-      console.error((e as any).message);
+      console.error('Failed to create channel:', e);
       alert({
         type: 'error',
         content: t('Something wrong happened, please check your details.')
@@ -89,7 +117,17 @@ const CreateChannelView: FC = () => {
       <ModalTitle>{t('Create New Space')}</ModalTitle>
       <div className='space-y-4 w-full'>
         <Input
-          className={cn({ 'border-red text-red placeholder:text-red': !!nameError })}
+          autoFocus
+          className={cn(`
+            focus:border-primary
+            focus-visible:outline-none w-full
+            rounded-2xl bg-charcoal-4 border border-charcoal-1 px-4 py-2
+            placeholder-charcoal-1 placeholder:text-sm
+            transition-all`,
+            {
+              'border-red text-red': !!nameError
+            }
+          )}
           data-testid='channel-name-input'
           type='text'
           placeholder={t('Name')}
@@ -103,8 +141,7 @@ const CreateChannelView: FC = () => {
           onChange={onChannelNameChange}
         />
         <textarea
-          className={cn(
-            `
+          className={cn(`
             focus:border-primary
             focus-visible:outline-none resize-none h-10 active:outline-0 w-full
             rounded-2xl bg-charcoal-4 border border-charcoal-1 px-4 py-2
-- 
GitLab