-
Notifications
You must be signed in to change notification settings - Fork 290
feat(funnels): app directory and web funnel setup #4312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bb7d759
9f62e27
30bc2c1
1072de0
138e866
1110abc
c337435
647c00c
70ccbcc
11fbe24
7b20e1f
8b10637
a2bef0e
2fb8e7c
9402d34
1a27388
aced153
e3dd2dc
b36b0eb
da69daf
1e43ab9
27bbb3f
389405a
c279170
24c5e6e
8c94256
d28d6eb
3a20140
23e435b
28e4af2
9358e22
7c91c62
8d83023
5c3a2ac
1a324d8
9a5ebf9
2736ad4
7a7b77d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import type { ReactElement } from 'react'; | ||
| import React from 'react'; | ||
| import { fromCDN } from '../../../lib'; | ||
|
|
||
| export function AppHeadMetas(): ReactElement { | ||
| return ( | ||
| <> | ||
| <meta | ||
| name="viewport" | ||
| content="initial-scale=1.0, width=device-width, viewport-fit=cover" | ||
| /> | ||
|
|
||
| <meta name="application-name" content="daily.dev" /> | ||
| <meta name="apple-mobile-web-app-capable" content="yes" /> | ||
| <meta name="apple-mobile-web-app-title" content="daily.dev" /> | ||
| <meta name="format-detection" content="telephone=no" /> | ||
| <meta name="mobile-web-app-capable" content="yes" /> | ||
| <meta name="slack-app-id" content="A07AM7XC529" /> | ||
| <meta name="apple-itunes-app" content="app-id=6740634400" /> | ||
|
Comment on lines
+8
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But non blocking since I see you reused it so we don't have to update both places, we just need to make sure we move at some point.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I can add a todo for this? |
||
|
|
||
| <link | ||
| rel="apple-touch-icon" | ||
| sizes="180x180" | ||
| href={fromCDN('/apple-touch-icon.png')} | ||
| /> | ||
| <link | ||
| rel="icon" | ||
| type="image/png" | ||
| sizes="32x32" | ||
| href={fromCDN('/favicon-32x32.png')} | ||
| /> | ||
| <link | ||
| rel="icon" | ||
| type="image/png" | ||
| sizes="16x16" | ||
| href={fromCDN('/favicon-16x16.png')} | ||
| /> | ||
| <link rel="manifest" href="/manifest.json" /> | ||
| <link | ||
| rel="sitemap" | ||
| type="text/plain" | ||
| title="Sitemap" | ||
| href="/sitemap.txt" | ||
| /> | ||
|
|
||
| <script | ||
| dangerouslySetInnerHTML={{ | ||
| __html: `window.addEventListener('load', () => { window.windowLoaded = true; }, { | ||
| once: true, | ||
| });`, | ||
| }} | ||
| /> | ||
|
|
||
| <link rel="preconnect" href="https://api.daily.dev" /> | ||
| <link rel="preconnect" href="https://sso.daily.dev" /> | ||
| <link rel="preconnect" href="https://media.daily.dev" /> | ||
| </> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { useQuery, useQueryClient } from '@tanstack/react-query'; | ||
| import type { Boot } from '../../../lib/boot'; | ||
| import type { LoggedUser, AnonymousUser } from '../../../lib/user'; | ||
| import { appBootDataQuery } from '../../../lib/boot'; | ||
| import { logout } from '../../../contexts/AuthContext'; | ||
| import { generateQueryKey, RequestKey } from '../../../lib/query'; | ||
| import { useRefreshToken } from '../../../hooks/useRefreshToken'; | ||
|
|
||
| export enum AppAuthActionsKeys { | ||
| LOGOUT = 'logout', | ||
| REFRESH = 'refresh', | ||
| UPDATE_USER = 'updateUser', | ||
| } | ||
|
|
||
| export type AppAuthActions = Record< | ||
| AppAuthActionsKeys, | ||
| (data?: unknown) => void | ||
| >; | ||
|
|
||
| interface UseAppAuthReturn { | ||
| boot: Boot; | ||
| dispatch: <Data>(action: { type: AppAuthActionsKeys; data?: Data }) => void; | ||
| isLoggedIn: boolean; | ||
| user: LoggedUser | null; | ||
| } | ||
|
|
||
| function checkIfUserIsLoggedIn(user: Boot['user']): user is LoggedUser { | ||
| return 'username' in user; | ||
| } | ||
|
|
||
| export const useAppAuth = (): UseAppAuthReturn => { | ||
| const queryClient = useQueryClient(); | ||
| const initialData = queryClient.getQueryData(appBootDataQuery.queryKey); | ||
| const { data: boot, refetch } = useQuery({ | ||
| ...appBootDataQuery, | ||
| initialData, | ||
| }); | ||
| const user = boot && checkIfUserIsLoggedIn(boot.user) ? boot.user : null; | ||
| const isLoggedIn = !!user; | ||
|
|
||
| useRefreshToken(boot?.accessToken, refetch); | ||
|
|
||
| const actions: Readonly<AppAuthActions> = { | ||
| [AppAuthActionsKeys.LOGOUT]: logout, | ||
| [AppAuthActionsKeys.REFRESH]: refetch, | ||
| [AppAuthActionsKeys.UPDATE_USER]: async ( | ||
| newUser: LoggedUser | AnonymousUser, | ||
| ) => { | ||
| await queryClient.invalidateQueries({ | ||
| queryKey: generateQueryKey(RequestKey.Profile, newUser), | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| return { | ||
| boot, | ||
| dispatch: ({ type, data }) => actions[type](data), | ||
| isLoggedIn, | ||
| user, | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { useSearchParams } from 'next/navigation'; | ||
| import { useMemo } from 'react'; | ||
|
|
||
| export const useRouterQuery = (): { | ||
| query: Record<string, string>; | ||
| } => { | ||
| const params = useSearchParams(); | ||
| return useMemo( | ||
| () => ({ | ||
| query: Object.fromEntries(params.entries()), | ||
| }), | ||
| [params], | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export interface AppPageProps { | ||
| params: Promise<Record<string, string>>; | ||
| searchParams: Promise<Record<string, string>>; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since they are used on server side code we should not mix with client-side one.