diff --git a/app/javascript/dashboard/assets/images/auth/signup-bg.jpg b/app/javascript/dashboard/assets/images/auth/signup-bg.jpg new file mode 100644 index 000000000..884a57922 Binary files /dev/null and b/app/javascript/dashboard/assets/images/auth/signup-bg.jpg differ diff --git a/app/javascript/dashboard/constants/globals.js b/app/javascript/dashboard/constants/globals.js index 85dab459c..eb42a270f 100644 --- a/app/javascript/dashboard/constants/globals.js +++ b/app/javascript/dashboard/constants/globals.js @@ -34,7 +34,8 @@ export default { DOCS_URL: 'https://www.chatwoot.com/docs/product/', HELP_CENTER_DOCS_URL: 'https://www.chatwoot.com/docs/product/others/help-center', - TESTIMONIAL_URL: 'https://testimonials.cdn.chatwoot.com/content.json', + TESTIMONIAL_URL: + 'https://testimonials.cdn.chatwoot.com/testimonial-content.json', WHATSAPP_EMBEDDED_SIGNUP_DOCS_URL: 'https://developers.facebook.com/docs/whatsapp/embedded-signup/custom-flows/onboarding-business-app-users#limitations', SMALL_SCREEN_BREAKPOINT: 768, diff --git a/app/javascript/dashboard/i18n/locale/en/signup.json b/app/javascript/dashboard/i18n/locale/en/signup.json index b0e5f5d27..4a90fd322 100644 --- a/app/javascript/dashboard/i18n/locale/en/signup.json +++ b/app/javascript/dashboard/i18n/locale/en/signup.json @@ -1,6 +1,7 @@ { "REGISTER": { "TRY_WOOT": "Create an account", + "GET_STARTED": "Get started with Chatwoot", "TITLE": "Register", "TESTIMONIAL_HEADER": "All it takes is one step to move forward", "TESTIMONIAL_CONTENT": "You're one step away from engaging your customers, retaining them and finding new ones.", diff --git a/app/javascript/v3/api/auth.js b/app/javascript/v3/api/auth.js index 146db4e07..cccd9468e 100644 --- a/app/javascript/v3/api/auth.js +++ b/app/javascript/v3/api/auth.js @@ -4,7 +4,10 @@ import { clearLocalStorageOnLogout, } from 'dashboard/store/utils/api'; import wootAPI from './apiClient'; -import { getLoginRedirectURL } from '../helpers/AuthHelper'; +import { + getLoginRedirectURL, + getCredentialsFromEmail, +} from '../helpers/AuthHelper'; export const login = async ({ ssoAccountId, @@ -46,9 +49,10 @@ export const login = async ({ export const register = async creds => { try { + const { fullName, accountName } = getCredentialsFromEmail(creds.email); const response = await wootAPI.post('api/v1/accounts.json', { - account_name: creds.accountName.trim(), - user_full_name: creds.fullName.trim(), + account_name: accountName, + user_full_name: fullName, email: creds.email, password: creds.password, h_captcha_client_response: creds.hCaptchaClientResponse, diff --git a/app/javascript/v3/helpers/AuthHelper.js b/app/javascript/v3/helpers/AuthHelper.js index 70df55331..c2afec985 100644 --- a/app/javascript/v3/helpers/AuthHelper.js +++ b/app/javascript/v3/helpers/AuthHelper.js @@ -22,6 +22,21 @@ const getSSOAccountPath = ({ ssoAccountId, user }) => { return accountPath; }; +const capitalize = str => + str + .split(/[._-]+/) + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); + +export const getCredentialsFromEmail = email => { + const [localPart, domain] = email.split('@'); + const namePart = localPart.split('+')[0]; + return { + fullName: capitalize(namePart), + accountName: capitalize(domain.split('.')[0]), + }; +}; + export const getLoginRedirectURL = ({ ssoAccountId, ssoConversationId, diff --git a/app/javascript/v3/helpers/specs/AuthHelper.spec.js b/app/javascript/v3/helpers/specs/AuthHelper.spec.js index 2bf3ba450..b422d8530 100644 --- a/app/javascript/v3/helpers/specs/AuthHelper.spec.js +++ b/app/javascript/v3/helpers/specs/AuthHelper.spec.js @@ -1,4 +1,4 @@ -import { getLoginRedirectURL } from '../AuthHelper'; +import { getLoginRedirectURL, getCredentialsFromEmail } from '../AuthHelper'; describe('#URL Helpers', () => { describe('getLoginRedirectURL', () => { @@ -40,4 +40,41 @@ describe('#URL Helpers', () => { expect(getLoginRedirectURL('7500', null)).toBe('/app/'); }); }); + + describe('getCredentialsFromEmail', () => { + it('should capitalize fullName and accountName from a standard email', () => { + expect(getCredentialsFromEmail('john@company.com')).toEqual({ + fullName: 'John', + accountName: 'Company', + }); + }); + + it('should handle subdomains by using the first part of the domain', () => { + expect(getCredentialsFromEmail('jane@mail.example.org')).toEqual({ + fullName: 'Jane', + accountName: 'Mail', + }); + }); + + it('should split by dots and capitalize each word', () => { + expect(getCredentialsFromEmail('john.doe@acme.co')).toEqual({ + fullName: 'John Doe', + accountName: 'Acme', + }); + }); + + it('should omit everything after + in the local part', () => { + expect(getCredentialsFromEmail('user+tag@startup.io')).toEqual({ + fullName: 'User', + accountName: 'Startup', + }); + }); + + it('should split by underscores and hyphens', () => { + expect(getCredentialsFromEmail('first_last@my-company.com')).toEqual({ + fullName: 'First Last', + accountName: 'My Company', + }); + }); + }); }); diff --git a/app/javascript/v3/views/auth/signup/Index.vue b/app/javascript/v3/views/auth/signup/Index.vue index 86baff55c..57ec0b20c 100644 --- a/app/javascript/v3/views/auth/signup/Index.vue +++ b/app/javascript/v3/views/auth/signup/Index.vue @@ -1,83 +1,84 @@ -