Skip to content

Commit

Permalink
feat: add user mode type (lite / pro) to ui store
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Dec 1, 2023
1 parent 4377985 commit b4104a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/marginfi-v2-ui/src/store/uiStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { create, StateCreator } from "zustand";

import { LendingModes, PoolTypes, SortType, sortDirection, SortAssetOption } from "~/types";
import { LendingModes, PoolTypes, SortType, sortDirection, SortAssetOption, UserMode } from "~/types";

const SORT_OPTIONS_MAP: { [key in SortType]: SortAssetOption } = {
APY_DESC: {
Expand Down Expand Up @@ -42,6 +42,7 @@ interface UiState {
lendingMode: LendingModes;
poolFilter: PoolTypes;
sortOption: SortAssetOption;
userMode: UserMode;

// Actions
setIsMenuDrawerOpen: (isOpen: boolean) => void;
Expand All @@ -53,6 +54,7 @@ interface UiState {
setLendingMode: (lendingMode: LendingModes) => void;
setPoolFilter: (poolType: PoolTypes) => void;
setSortOption: (sortOption: SortAssetOption) => void;
setUserMode: (userMode: UserMode) => void;
}

function createUiStore() {
Expand All @@ -70,6 +72,7 @@ const stateCreator: StateCreator<UiState, [], []> = (set, get) => ({
lendingMode: LendingModes.LEND,
poolFilter: PoolTypes.ALL,
sortOption: SORT_OPTIONS_MAP[SortType.TVL_DESC],
userMode: UserMode.LITE,

// Actions
setIsMenuDrawerOpen: (isOpen: boolean) => set({ isMenuDrawerOpen: isOpen }),
Expand All @@ -82,6 +85,7 @@ const stateCreator: StateCreator<UiState, [], []> = (set, get) => ({
setLendingMode: (lendingMode: LendingModes) => set({ lendingMode: lendingMode }),
setPoolFilter: (poolType: PoolTypes) => set({ poolFilter: poolType }),
setSortOption: (sortOption: SortAssetOption) => set({ sortOption: sortOption }),
setUserMode: (userMode: UserMode) => set({ userMode: userMode }),
});

export { createUiStore, SORT_OPTIONS_MAP };
Expand Down
5 changes: 5 additions & 0 deletions apps/marginfi-v2-ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ export enum SortType {
TVL_ASC = "TVL_ASC",
TVL_DESC = "TVL_DESC",
}

export enum UserMode {
LITE = "lite",
PRO = "pro",
}

0 comments on commit b4104a4

Please sign in to comment.