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/
118 lines
2.8 KiB
JavaScript
118 lines
2.8 KiB
JavaScript
import SummaryReportsAPI from 'dashboard/api/summaryReports';
|
|
import camelcaseKeys from 'camelcase-keys';
|
|
|
|
const typeMap = {
|
|
inbox: {
|
|
flagKey: 'isFetchingInboxSummaryReports',
|
|
apiMethod: 'getInboxReports',
|
|
mutationKey: 'setInboxSummaryReport',
|
|
},
|
|
agent: {
|
|
flagKey: 'isFetchingAgentSummaryReports',
|
|
apiMethod: 'getAgentReports',
|
|
mutationKey: 'setAgentSummaryReport',
|
|
},
|
|
team: {
|
|
flagKey: 'isFetchingTeamSummaryReports',
|
|
apiMethod: 'getTeamReports',
|
|
mutationKey: 'setTeamSummaryReport',
|
|
},
|
|
label: {
|
|
flagKey: 'isFetchingLabelSummaryReports',
|
|
apiMethod: 'getLabelReports',
|
|
mutationKey: 'setLabelSummaryReport',
|
|
},
|
|
};
|
|
|
|
async function fetchSummaryReports(type, params, { commit }) {
|
|
const config = typeMap[type];
|
|
if (!config) return;
|
|
|
|
let error = null;
|
|
try {
|
|
commit('setUIFlags', { [config.flagKey]: true });
|
|
const response = await SummaryReportsAPI[config.apiMethod](params);
|
|
commit(config.mutationKey, camelcaseKeys(response.data, { deep: true }));
|
|
} catch (e) {
|
|
error = e;
|
|
} finally {
|
|
commit('setUIFlags', { [config.flagKey]: false });
|
|
}
|
|
if (error) throw error;
|
|
}
|
|
|
|
export const initialState = {
|
|
inboxSummaryReports: [],
|
|
agentSummaryReports: [],
|
|
teamSummaryReports: [],
|
|
labelSummaryReports: [],
|
|
uiFlags: {
|
|
isFetchingInboxSummaryReports: false,
|
|
isFetchingAgentSummaryReports: false,
|
|
isFetchingTeamSummaryReports: false,
|
|
isFetchingLabelSummaryReports: false,
|
|
},
|
|
};
|
|
|
|
export const getters = {
|
|
getInboxSummaryReports(state) {
|
|
return state.inboxSummaryReports;
|
|
},
|
|
getAgentSummaryReports(state) {
|
|
return state.agentSummaryReports;
|
|
},
|
|
getTeamSummaryReports(state) {
|
|
return state.teamSummaryReports;
|
|
},
|
|
getLabelSummaryReports(state) {
|
|
return state.labelSummaryReports;
|
|
},
|
|
getUIFlags(state) {
|
|
return state.uiFlags;
|
|
},
|
|
};
|
|
|
|
export const actions = {
|
|
fetchInboxSummaryReports({ commit }, params) {
|
|
return fetchSummaryReports('inbox', params, { commit });
|
|
},
|
|
|
|
fetchAgentSummaryReports({ commit }, params) {
|
|
return fetchSummaryReports('agent', params, { commit });
|
|
},
|
|
|
|
fetchTeamSummaryReports({ commit }, params) {
|
|
return fetchSummaryReports('team', params, { commit });
|
|
},
|
|
|
|
fetchLabelSummaryReports({ commit }, params) {
|
|
return fetchSummaryReports('label', params, { commit });
|
|
},
|
|
};
|
|
|
|
export const mutations = {
|
|
setInboxSummaryReport(state, data) {
|
|
state.inboxSummaryReports = data;
|
|
},
|
|
setAgentSummaryReport(state, data) {
|
|
state.agentSummaryReports = data;
|
|
},
|
|
setTeamSummaryReport(state, data) {
|
|
state.teamSummaryReports = data;
|
|
},
|
|
setLabelSummaryReport(state, data) {
|
|
state.labelSummaryReports = data;
|
|
},
|
|
setUIFlags(state, uiFlag) {
|
|
state.uiFlags = { ...state.uiFlags, ...uiFlag };
|
|
},
|
|
};
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: initialState,
|
|
getters,
|
|
actions,
|
|
mutations,
|
|
};
|