MCPcopy Create free account
hub / github.com/dailydotdev/apps / EditTag

Function EditTag

packages/shared/src/components/onboarding/EditTag.tsx:31–144  ·  view source on GitHub ↗
({
  feedSettings,
  userId,
  headline,
  requiredTags = REQUIRED_TAGS_THRESHOLD,
  hidePreview,
  featuredTags,
}: EditTagProps)

Source from the content-addressed store, hash-verified

29 featuredTags?: string[];
30}
31export const EditTag = ({
32 feedSettings,
33 userId,
34 headline,
35 requiredTags = REQUIRED_TAGS_THRESHOLD,
36 hidePreview,
37 featuredTags,
38}: EditTagProps): ReactElement => {
39 const isMobile = useViewSize(ViewSize.MobileL);
40 const [isPreviewVisible, setPreviewVisible] = useState(false);
41 const tagsCount = feedSettings?.includeTags?.length || 0;
42 const isPreviewEnabled = tagsCount >= requiredTags;
43
44 const [searchQuery, setSearchQuery] = useState<string>('');
45 const [onSearch] = useDebounceFn((value?: string) => {
46 setSearchQuery(value ?? '');
47 }, 350);
48
49 const { data: searchResult } = useTagSearch({
50 value: searchQuery,
51 origin: Origin.EditTag,
52 });
53 const searchTags = searchResult?.searchTags.tags || [];
54
55 const { value: showPersonas } = useConditionalFeature({
56 feature: featureOnboardingPersonas,
57 shouldEvaluate: !!feedSettings,
58 });
59
60 const tagsRef = useRef<HTMLDivElement>(null);
61 const hasScrolledToTagsRef = useRef(false);
62
63 useEffect(() => {
64 if (!isMobile || !showPersonas) {
65 return undefined;
66 }
67 return subscribePersonaSelection(() => {
68 if (hasScrolledToTagsRef.current) {
69 return;
70 }
71 hasScrolledToTagsRef.current = true;
72 tagsRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
73 });
74 }, [isMobile, showPersonas]);
75
76 // When the persona feature is on, override any caller-supplied headline
77 // (Freyja funnel JSON) with the persona-tuned copy.
78 // TODO: drop this override once Freyja's persona-experiment variant ships
79 // the new headline directly.
80 const resolvedHeadline = showPersonas
81 ? 'Tune your feed'
82 : headline || 'Pick tags that are relevant to you';
83
84 return (
85 <>
86 <h2 className="text-center font-bold typo-large-title">
87 {resolvedHeadline}
88 </h2>

Callers

nothing calls this directly

Calls 5

useViewSizeFunction · 0.90
useTagSearchFunction · 0.90
useConditionalFeatureFunction · 0.90
useDebounceFnFunction · 0.85

Tested by

no test coverage detected