import { type , AppContext , StatusType } from "../api" ; import { LOAD_USER , SET_STATUS } from "../events" ; import { status } from "./status" ; param ctx export function userProfile ( ctx ) { const id = ctx . views . route . deref ( ) ! . params . id ; ctx . bus . dispatch ( ctx . views . users . deref ( ) ! [ id ] ? [ SET_STATUS , [ StatusType . SUCCESS , "loaded from cache" , true ] ] : [ LOAD_USER , id ] ) ; return [ "div" , [ status ] , [ userCard , id ] ] ; } function userCard ( ctx , id ) { const user = ctx . views . users . deref ( ) ! [ id ] ; const ui = ctx . ui . card ; return user ? [ "div" , ui . container , [ "img" , { ... ui . thumb , src : user . img } ] , [ "h3" , ui . title , user . name ] , user . job , [ "hr" , ui . sep ] , [ "p" , ui . body , user . desc ] , ] : undefined ; }