diff --git a/src/components/common/Input/index.tsx b/src/components/common/Input/index.tsx index 96558ece4ada580848eae9ac9119b22daccffa1d..73af715634f432674afe06cd1924021229946030 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 ddb25b95a2114b9fe7ae79b4ccf5955f366701d0..a4f3239bc327675cab372cfda7af04f692fa7b8b 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