Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions client/containers/CommunityCreate/CommunityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const CommunityCreate = () => {
evt.preventDefault();
setCreateIsLoading(true);
if (!acceptTerms) return false;

const formData = new FormData(evt.currentTarget);
const honeypot = (formData.get('website') as string) ?? '';
const payload = {
Expand Down Expand Up @@ -118,7 +119,13 @@ const CommunityCreate = () => {
setIsCreated(true);
} catch (error) {
setCreateIsLoading(false);
setCreateError((error as Error).message);
if (error instanceof Error) {
setCreateError(error.message);
} else if (typeof error === 'string') {
setCreateError(error);
} else {
setCreateError('Error Creating Community');
}
return;
}
};
Expand All @@ -138,6 +145,7 @@ const CommunityCreate = () => {
setHeroLogo(val);
};

console.log('createError', createError);
return (
<div id="community-create-container">
<GridWrapper containerClassName={isCreated ? undefined : 'small'}>
Expand Down Expand Up @@ -173,6 +181,13 @@ const CommunityCreate = () => {
value={subdomain}
onChange={onSubdomainChange}
helperText={`https://${subdomain || '[URL]'}.pubpub.org`}
error={
createError
? createError === 'URL already used'
? 'URL already in use by another community'
: 'Error Creating Community'
: undefined
}
/>
<InputField
label="Title"
Expand Down Expand Up @@ -231,24 +246,17 @@ const CommunityCreate = () => {
</Checkbox>
</InputField>
<Altcha ref={altchaRef} auto="onload" />
<InputField
error={
createError
? createError === 'URL already used'
? 'URL already in use by another community'
: 'Error Creating Community'
: undefined
}
>
<Button
name="create"
type="submit"
className={`${Classes.BUTTON} ${Classes.INTENT_PRIMARY} create-account-button`}
text="Create Community"
disabled={!subdomain || !title || !acceptTerms}
loading={createIsLoading}
/>
</InputField>
<Button
name="create"
type="submit"
className={`${Classes.BUTTON} ${Classes.INTENT_PRIMARY} create-account-button`}
text="Create Community"
disabled={!subdomain || !title || !acceptTerms}
loading={createIsLoading}
/>
{createError && createError !== 'URL already used' && (
<p className="error-message">{createError}</p>
)}
</form>
</div>
)}
Expand Down
8 changes: 4 additions & 4 deletions client/containers/Landing/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ const Landing = () => {
</p>
<h2>Create knowledge. Share it with audiences who care.</h2>
{/* enable soon */}
{/* <div className="buttons">
<div className="buttons">
<a href="/community/create" className="custom-button black">
Create your community
</a>
</div> */}
</div>
{/* <div className="buttons">
<a href="/pricing" className="custom-button">
Support PubPub
Expand Down Expand Up @@ -338,7 +338,7 @@ const Landing = () => {
{/* BEGIN Create Block */}
<div id="create">
<div className="container restricted-width">
{/* <div>
<div>
<h3>Create</h3>
</div>
<div>
Expand All @@ -352,7 +352,7 @@ const Landing = () => {
* A community can be your individual space to create content, or you
can invite others to collaborate with you!
</p>
</div> */}
</div>
</div>
</div>
{/* END Create Block */}
Expand Down