@@ -36,11 +36,19 @@ import { useQueryClient } from '@tanstack/react-query';
3636import CreatePoll from '@dailydotdev/shared/src/components/post/poll/CreatePoll' ;
3737import { Pill , PillSize } from '@dailydotdev/shared/src/components/Pill' ;
3838import { useMultipleSourcePost } from '@dailydotdev/shared/src/features/squads/hooks/useMultipleSourcePost' ;
39- import { webappUrl } from '@dailydotdev/shared/src/lib/constants' ;
39+ import { settingsUrl , webappUrl } from '@dailydotdev/shared/src/lib/constants' ;
4040import type { WriteForm } from '@dailydotdev/shared/src/contexts' ;
41- import { getLayout as getMainLayout } from '../../components/layouts/MainLayout' ;
42- import { defaultOpenGraph , defaultSeo } from '../../next-seo' ;
41+ import { useSettingsContext } from '@dailydotdev/shared/src/contexts/SettingsContext' ;
42+
43+ import {
44+ Button ,
45+ ButtonSize ,
46+ } from '@dailydotdev/shared/src/components/buttons/Button' ;
47+ import { SettingsIcon } from '@dailydotdev/shared/src/components/icons' ;
48+ import { LinkWithTooltip } from '@dailydotdev/shared/src/components/tooltips/LinkWithTooltip' ;
4349import { getTemplatedTitle } from '../../components/layouts/utils' ;
50+ import { defaultOpenGraph , defaultSeo } from '../../next-seo' ;
51+ import { getLayout as getMainLayout } from '../../components/layouts/MainLayout' ;
4452
4553const seo : NextSeoProps = {
4654 title : getTemplatedTitle ( 'Create post' ) ,
@@ -59,6 +67,10 @@ function CreatePost(): ReactElement {
5967 ) ;
6068 const { push, isReady : isRouteReady , query } = useRouter ( ) ;
6169 const { squads, user, isAuthReady, isFetched } = useAuthContext ( ) ;
70+ const {
71+ flags : { defaultWriteTab } ,
72+ loadedSettings,
73+ } = useSettingsContext ( ) ;
6274 const [ selectedSourceIds , setSelectedSourceIds ] = useState < string [ ] > ( [ ] ) ;
6375 const activeSquads = useMemo ( ( ) => {
6476 const collator = new Intl . Collator ( 'en' ) ;
@@ -191,6 +203,8 @@ function CreatePost(): ReactElement {
191203 setDisplay ( WriteFormTab . Share ) ;
192204 } else if ( isInitialPoll ) {
193205 setDisplay ( WriteFormTab . Poll ) ;
206+ } else if ( defaultWriteTab in WriteFormTab ) {
207+ setDisplay ( WriteFormTab [ defaultWriteTab ] ) ;
194208 }
195209
196210 const preselectedSquad =
@@ -220,6 +234,7 @@ function CreatePost(): ReactElement {
220234 activeSquads ,
221235 selectedSourceIds . length ,
222236 query ,
237+ defaultWriteTab ,
223238 ] ) ;
224239
225240 useEffect ( ( ) => {
@@ -228,7 +243,7 @@ function CreatePost(): ReactElement {
228243 }
229244 } , [ display , hasCheckedPollTab , completeAction ] ) ;
230245
231- if ( ! isFetched || ! isAuthReady || ! isRouteReady ) {
246+ if ( ! isFetched || ! isAuthReady || ! isRouteReady || ! loadedSettings ) {
232247 return < WriteFreeFormSkeleton /> ;
233248 }
234249
@@ -255,6 +270,28 @@ function CreatePost(): ReactElement {
255270 shouldMountInactive
256271 className = { { header : 'px-1' } }
257272 showHeader = { isTablet }
273+ extraHeaderContent = {
274+ ! isMobile && (
275+ < LinkWithTooltip
276+ tooltip = { {
277+ content : (
278+ < div className = "max-w-48" >
279+ You can change the default post type settings
280+ </ div >
281+ ) ,
282+ placement : 'left' ,
283+ } }
284+ href = { `${ settingsUrl } /composition` }
285+ passHref
286+ >
287+ < Button
288+ icon = { < SettingsIcon /> }
289+ size = { ButtonSize . Small }
290+ className = "ml-auto mr-3 self-center text-text-quaternary"
291+ />
292+ </ LinkWithTooltip >
293+ )
294+ }
258295 >
259296 < Tab
260297 label = { WriteFormTab . NewPost }
0 commit comments