Skip to content

Sample State

HammadKhalid101 edited this page Mar 22, 2021 · 19 revisions
{
  entities: {
    users: {
      1: {
        id: 1,
        first_name: "John",
        last_name: "Doe",
        username: "iamjohndoe",
        buying_power: 100000,
      },
      2: {
        id: 2,
        first_name: "Jane",
        last_name: "Doe",
        username: "iamjanedoe",
        buying_power: 200000,
      }
    },
    stocks: {
      10: {
        id: 10,
        name: "Apple",
        tikr: "AAPL",
        last_price: 140.11,
        percent_change: 2.3,
      },
      12: {
        id: 12,
        name: "Bitcoin",
        tikr: "BTC",
        last_price: 53570.39,
        percent_change: 2.3,   
      },
      34: {
        id: 34,
        name: "Tesla",
        tikr: "TSLA",
        last_price: 700.27,
        percent_change: 2.3,       
      },
     54: {
        id: 54,
        name: "Dogecoin",
        tikr: "DOGE",
        last_price: 0.055744,
        percent_change: 2.3,      
      },
    },
    watchlist: {
      1: {
        id: 1,
        user_id: 1,
        title: "My Favorite Stocks",
        stock_ids: [10, 12, 34, 54],    
      },
      2: {
        id: 2,
        user_id: 2,
        title: "Stocks to buy",
        stock_ids: [20, 34, 65, 80],    
      }
    },
    ui: {
        loading: true/false,
        modal: {
            accountDropdown: true/false,
            seacrh: true/false,
            welcomeModal: true/false,
        },
    },
    errors: {
        login: ["Invalid credentials/wrong username or password"],
        signup: ["Username is already taken", "Password is too short"],
        trade: ["You don’t have enough buying power to place this order."],
    },
    session: { currentUserId: 1 }
}
Clone this wiki locally