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

Function KeywordManagement

packages/webapp/components/KeywordManagement.tsx:44–191  ·  view source on GitHub ↗
({
  keyword,
  subtitle,
  onOperationCompleted,
}: KeywordManagerProps)

Source from the content-addressed store, hash-verified

42};
43
44export default function KeywordManagement({
45 keyword,
46 subtitle,
47 onOperationCompleted,
48}: KeywordManagerProps): ReactElement {
49 const { windowLoaded } = useContext(ProgressiveEnhancementContext);
50 const [currentAction, setCurrentAction] = useState<string | null>(null);
51
52 const nextKeyword = async () => {
53 if (onOperationCompleted) {
54 await onOperationCompleted();
55 }
56 setCurrentAction(null);
57 };
58
59 const { mutateAsync: allowKeyword } = useMutation({
60 mutationFn: () =>
61 gqlClient.request(ALLOW_KEYWORD_MUTATION, {
62 keyword: keyword.value,
63 }),
64
65 onSuccess: () => nextKeyword(),
66 });
67
68 const { mutateAsync: denyKeyword } = useMutation({
69 mutationFn: () =>
70 gqlClient.request(DENY_KEYWORD_MUTATION, {
71 keyword: keyword.value,
72 }),
73
74 onSuccess: () => nextKeyword(),
75 });
76
77 const posts = useInfiniteQuery<FeedData>({
78 queryKey: ['keyword_post', keyword.value],
79 queryFn: ({ pageParam }) =>
80 gqlClient.request(KEYWORD_FEED_QUERY, {
81 keyword: keyword.value,
82 first: 4,
83 after: pageParam,
84 }),
85 initialPageParam: '',
86 getNextPageParam: ({ page }) => getNextPageParam(page?.pageInfo),
87 });
88
89 const onAllow = () => {
90 setCurrentAction('allow');
91 return allowKeyword();
92 };
93
94 const onSynonym = () => setCurrentAction('synonym');
95
96 const onDeny = () => {
97 setCurrentAction('deny');
98 return denyKeyword();
99 };
100
101 const disableActions = !!currentAction;

Callers

nothing calls this directly

Calls 3

getNextPageParamFunction · 0.90
smallPostImageFunction · 0.90
nextKeywordFunction · 0.85

Tested by

no test coverage detected