feat: Changes account creation to support multiple steps (#8859)

* feat: Changes account creation to support multiple steps

* Adds API changes and new routes

* Fixes type
This commit is contained in:
Nithin David Thomas
2024-02-08 02:02:02 -08:00
committed by GitHub
parent 17cb938bc8
commit a649c2733f
6 changed files with 49 additions and 10 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
class AccountBuilder
include CustomExceptions::Account
pattr_initialize [:account_name, :email!, :confirmed, :user, :user_full_name, :user_password, :super_admin, :locale]
pattr_initialize [:email!, :confirmed, :user, :user_password, :super_admin, :locale]
def perform
if @user.nil?
@@ -49,7 +49,7 @@ class AccountBuilder
end
def create_account
@account = Account.create!(name: account_name, locale: I18n.locale)
@account = Account.create!(name: '', locale: I18n.locale)
Current.account = @account
end
@@ -74,7 +74,7 @@ class AccountBuilder
@user = User.new(email: @email,
password: user_password,
password_confirmation: user_password,
name: user_full_name)
name: '')
@user.type = 'SuperAdmin' if @super_admin
@user.confirm if @confirmed
@user.save!
@@ -23,8 +23,6 @@ class Api::V1::AccountsController < Api::BaseController
def create
@user, @account = AccountBuilder.new(
account_name: account_params[:account_name],
user_full_name: account_params[:user_full_name],
email: account_params[:email],
user_password: account_params[:password],
locale: account_params[:locale],
+8
View File
@@ -1,9 +1,17 @@
/* global axios */
import ApiClient from './ApiClient';
class Agents extends ApiClient {
constructor() {
super('agents', { accountScoped: true });
}
bulkInvite({ emails }) {
return axios.post(`${this.url}/bulk_create`, {
emails,
});
}
}
export default new Agents();
@@ -8,7 +8,10 @@ import helpcenterRoutes from './helpcenter/helpcenter.routes';
const AppContainer = () => import('./Dashboard.vue');
const Suspended = () => import('./suspended/Index.vue');
// const SetupProfile = () => import('v3/views/onboarding/SetupProfile.vue');
// const SetupCompany = () => import('v3/views/onboarding/SetupCompany.vue');
// const InviteTeam = () => import('v3/views/onboarding/InviteTeam.vue');
// const FoundersNote = () => import('v3/views/onboarding/FoundersNote.vue');
export default {
routes: [
...helpcenterRoutes.routes,
@@ -29,5 +32,25 @@ export default {
roles: ['administrator', 'agent'],
component: Suspended,
},
// {
// path: frontendURL('accounts/:account_id/start/setup-profile'),
// name: 'onboarding_setup_profile',
// component: SetupProfile,
// },
// {
// path: frontendURL('accounts/:account_id/start/setup-company'),
// name: 'onboarding_setup_company',
// component: SetupCompany,
// },
// {
// path: frontendURL('accounts/:account_id/start/invite-team'),
// name: 'onboarding_invite_team',
// component: InviteTeam,
// },
// {
// path: frontendURL('accounts/:account_id/start/founders-note'),
// name: 'onboarding_founders_note',
// component: FoundersNote,
// },
],
};
+14 -2
View File
@@ -28,8 +28,6 @@ export const login = async ({
export const register = async creds => {
try {
const response = await wootAPI.post('api/v1/accounts.json', {
account_name: creds.accountName.trim(),
user_full_name: creds.fullName.trim(),
email: creds.email,
password: creds.password,
h_captcha_client_response: creds.hCaptchaClientResponse,
@@ -42,6 +40,20 @@ export const register = async creds => {
return null;
};
export const accountSetup = async ({ id, name, locale }) => {
try {
const response = await wootAPI.put(`api/v1/accounts/${id}.json`, {
name,
locale,
});
setAuthCredentials(response);
return response.data;
} catch (error) {
throwErrorMessage(error);
}
return null;
};
export const verifyPasswordToken = async ({ confirmationToken }) => {
try {
const response = await wootAPI.post('auth/confirmation', {
-2
View File
@@ -68,8 +68,6 @@ class User < ApplicationRecord
# work because :validatable in devise overrides this.
# validates_uniqueness_of :email, scope: :account_id
validates :email, presence: true
has_many :account_users, dependent: :destroy_async
has_many :accounts, through: :account_users
accepts_nested_attributes_for :account_users