({ request }: LoaderFunctionArgs)
| 6 | |
| 7 | //this loader chooses the best project to redirect you to, ideally based on the cookie |
| 8 | export const loader = async ({ request }: LoaderFunctionArgs) => { |
| 9 | const user = await requireUser(request); |
| 10 | |
| 11 | const url = new URL(request.url); |
| 12 | |
| 13 | const presenter = new SelectBestProjectPresenter(); |
| 14 | |
| 15 | try { |
| 16 | const { organization } = await presenter.call({ userId: user.id, request }); |
| 17 | //redirect them to the most appropriate project |
| 18 | return redirect(`${newProjectPath(organization)}${url.search}`); |
| 19 | } catch (e) { |
| 20 | const invites = await getUsersInvites({ email: user.email }); |
| 21 | |
| 22 | if (invites.length > 0) { |
| 23 | return redirect(invitesPath()); |
| 24 | } |
| 25 | |
| 26 | //this should only happen if the user has no projects, and no invites |
| 27 | return redirect(newOrganizationPath()); |
| 28 | } |
| 29 | }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…