Skip to content

Pinia Task 13 - account-team #6942

@n-lark

Description

@n-lark

Task 13 — account-team (PR 14)

Gate: Task 12 merged.
State: team, teamMembership, teams, teamBlueprints, pendingTeamChange, notifications, invitations
Actions: setTeam, refreshTeam, refreshTeams, refreshTeamMembership, getTeamBlueprints, getNotifications, getInvitations, clearOtherStores
Consumers: ~40 files (team context, notifications)

13.1 — Create account-team.js

Port team state and actions. setTeam calls product.setTeam(team) (PostHog tracking) — carry this over. clearOtherStores calls useProductTablesStore().clearState() — keep as-is.

13.2 — Update Vuex checkState to delegate team parts to Pinia

// Before
commit('setTeam', team)
commit('setTeamMembership', membership)
commit('setTeams', teams.teams)

// After
useAccountTeamStore().setTeam(team)
useAccountTeamStore().teamMembership = membership
useAccountTeamStore().teams = teams.teams

Remove the team-related mutations from Vuex (setTeam, setTeamMembership, setTeams, setTeamBlueprints, setNotifications, setTeamInvitations, setPendingTeamChange, clearPendingTeamChange).

13.3 — Update Vuex logout

useAccountAuthStore().$reset()
useAccountTeamStore().$reset()        // ← add
dispatch('$resetState', null, { root: true })

13.4 — Add persistence

persist: [
    { pick: ['team', 'teamMembership'], storage: sessionStorage }
]

13.5 — Update _account_bridge.js

import { useAccountTeamStore } from './account-team.js'

export function useAccountBridge () {
    return {
        user: useAccountAuthStore().user,
        team: useAccountTeamStore().team,
        // featuresCheck still from Vuex until Task 14
        featuresCheck: store.getters['account/featuresCheck']
    }
}

13.6 — Update ~40 consumers

Same pattern as Task 12 — migrate directly to Pinia, no proxy Vuex getters. Components that used mapState('account', ['team', 'teamMembership']) switch to mapState(useAccountTeamStore, ['team', 'teamMembership']). Alias Vuex helpers when both are still needed in the same file.

Note: after Task 13, many components will have a mix of mapState(useAccountAuthStore, [...]), mapState(useAccountTeamStore, [...]), and mapVuexState('account', ['settings', 'features']) — that's expected and correct until Task 14 cleans up the remaining Vuex state.

grep -rl "mapState.*account.*team\|mapVuexState.*account.*team" frontend/src/

13.7 — Export from stores index

export { useAccountTeamStore } from './account-team.js'

13.8 — Write tests

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions