Copy the Chatwoot (v4.14.0) frontend runnable subset into frontend/ for customization: - app/javascript/ (Vue SPA: dashboard, widget, sdk, portal, superadmin) - app/views/ (ERB templates for vite-plugin-ruby entrypoint resolution) - app/helpers/, app/assets/ (Rails view helpers, static assets) - enterprise/ (Enterprise edition frontend overlay) - config/vite.json, vite.config.ts, bin/vite (Vite-Rails toolchain) - package.json, pnpm-lock.yaml, tailwind/postcss/eslint configs - Gemfile, Gemfile.lock (vite_rails gem for bin/vite binstub) Excluded Rails backend: controllers, models, services, jobs, mailers, policies, db, lib, spec, public, node_modules. Update references to the new frontend location: - .gitignore: exclude frontend build artifacts (node_modules, tmp, packs), keep frontend/bin/ and frontend/vendor/ via negation - backend/scripts/parity_frontend_smoke.sh: CHATWOOT_DIR default reference/chatwoot -> ../frontend - backend/scripts/parity_frontend_browser_smoke.mjs: same default update - AGENTS.md: add frontend section with Rails/Vite coupling notes - README: architecture tree includes frontend/
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
import * as types from '../../mutation-types';
|
|
import InboxesAPI from '../../../api/inboxes';
|
|
import AnalyticsHelper from '../../../helper/AnalyticsHelper';
|
|
import { ACCOUNT_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
|
|
|
export const buildInboxData = inboxParams => {
|
|
const formData = new FormData();
|
|
const { channel = {}, ...inboxProperties } = inboxParams;
|
|
Object.keys(inboxProperties).forEach(key => {
|
|
formData.append(key, inboxProperties[key]);
|
|
});
|
|
const { selectedFeatureFlags, ...channelParams } = channel;
|
|
// selectedFeatureFlags needs to be empty when creating a website channel
|
|
if (selectedFeatureFlags) {
|
|
if (selectedFeatureFlags.length) {
|
|
selectedFeatureFlags.forEach(featureFlag => {
|
|
formData.append(`channel[selected_feature_flags][]`, featureFlag);
|
|
});
|
|
} else {
|
|
formData.append('channel[selected_feature_flags][]', '');
|
|
}
|
|
}
|
|
Object.keys(channelParams).forEach(key => {
|
|
formData.append(`channel[${key}]`, channel[key]);
|
|
});
|
|
return formData;
|
|
};
|
|
|
|
const sendAnalyticsEvent = channelType => {
|
|
AnalyticsHelper.track(ACCOUNT_EVENTS.ADDED_AN_INBOX, {
|
|
channelType,
|
|
});
|
|
};
|
|
|
|
export const channelActions = {
|
|
createVoiceChannel: async ({ commit }, params) => {
|
|
try {
|
|
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: true });
|
|
const response = await InboxesAPI.create({
|
|
name: params.name,
|
|
channel: { ...params.voice, type: 'voice' },
|
|
});
|
|
commit(types.default.ADD_INBOXES, response.data);
|
|
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false });
|
|
sendAnalyticsEvent('voice');
|
|
return response.data;
|
|
} catch (error) {
|
|
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false });
|
|
throw error;
|
|
}
|
|
},
|
|
};
|