({ request, match, user, session, isRunningLocally }: RequestHandlerParams)
| 10 | const titlePrefix = 'Dashboard'; |
| 11 | |
| 12 | async function get({ request, match, user, session, isRunningLocally }: RequestHandlerParams) { |
| 13 | if (!(await AppConfig.isAppEnabled('dashboard'))) { |
| 14 | return new Response('Redirect', { status: 303, headers: { 'Location': `/` } }); |
| 15 | } |
| 16 | |
| 17 | let userDashboard = await DashboardModel.getByUserId(user!.id); |
| 18 | |
| 19 | if (!userDashboard) { |
| 20 | userDashboard = await DashboardModel.create(user!.id); |
| 21 | } |
| 22 | |
| 23 | const htmlContent = defaultHtmlContent({ userDashboard }); |
| 24 | |
| 25 | return basicLayoutResponse(htmlContent, { |
| 26 | currentPath: match.pathname.input, |
| 27 | titlePrefix, |
| 28 | match, |
| 29 | request, |
| 30 | user, |
| 31 | session, |
| 32 | isRunningLocally, |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | function defaultHtmlContent({ userDashboard }: { userDashboard: Dashboard }) { |
| 37 | const initialNotes = userDashboard?.data?.notes || 'Jot down some notes here.'; |
nothing calls this directly
no test coverage detected