repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { createSlice, PayloadAction } from '@reduxjs/toolkit'; |
| #2 | |
| #3 | interface ProfileState { |
| #4 | userId: string; |
| #5 | totalMemories: number; |
| #6 | totalApps: number; |
| #7 | status: 'idle' | 'loading' | 'succeeded' | 'failed'; |
| #8 | error: string | null; |
| #9 | apps: any[]; |
| #10 | } |
| #11 | |
| #12 | const initialState: ProfileState = { |
| #13 | userId: process.env.NEXT_PUBLIC_USER_ID || 'user', |
| #14 | totalMemories: 0, |
| #15 | totalApps: 0, |
| #16 | status: 'idle', |
| #17 | error: null, |
| #18 | apps: [], |
| #19 | }; |
| #20 | |
| #21 | const profileSlice = createSlice({ |
| #22 | name: 'profile', |
| #23 | initialState, |
| #24 | reducers: { |
| #25 | setUserId: (state, action: PayloadAction<string>) => { |
| #26 | state.userId = action.payload; |
| #27 | }, |
| #28 | setProfileLoading: (state) => { |
| #29 | state.status = 'loading'; |
| #30 | state.error = null; |
| #31 | }, |
| #32 | setProfileError: (state, action: PayloadAction<string>) => { |
| #33 | state.status = 'failed'; |
| #34 | state.error = action.payload; |
| #35 | }, |
| #36 | resetProfileState: (state) => { |
| #37 | state.status = 'idle'; |
| #38 | state.error = null; |
| #39 | state.userId = process.env.NEXT_PUBLIC_USER_ID || 'user'; |
| #40 | }, |
| #41 | setTotalMemories: (state, action: PayloadAction<number>) => { |
| #42 | state.totalMemories = action.payload; |
| #43 | }, |
| #44 | setTotalApps: (state, action: PayloadAction<number>) => { |
| #45 | state.totalApps = action.payload; |
| #46 | }, |
| #47 | setApps: (state, action: PayloadAction<any[]>) => { |
| #48 | state.apps = action.payload; |
| #49 | } |
| #50 | }, |
| #51 | }); |
| #52 | |
| #53 | export const { |
| #54 | setUserId, |
| #55 | setProfileLoading, |
| #56 | setProfileError, |
| #57 | resetProfileState, |
| #58 | setTotalMemories, |
| #59 | setTotalApps, |
| #60 | setApps |
| #61 | } = profileSlice.actions; |
| #62 | |
| #63 | export default profileSlice.reducer; |