Procházet zdrojové kódy

chore: perfect type definition (#940)

bowen před 1 rokem
rodič
revize
5e0540077a
25 změnil soubory, kde provedl 97 přidání a 70 odebrání
  1. 2 1
      web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx
  2. 1 1
      web/app/components/app/chat/answer/index.tsx
  3. 3 3
      web/app/components/app/chat/index.tsx
  4. 10 10
      web/app/components/app/configuration/config-var/input-type-icon.tsx
  5. 2 7
      web/app/components/app/configuration/dataset-config/card-item/index.tsx
  6. 5 4
      web/app/components/app/overview/appCard.tsx
  7. 6 2
      web/app/components/app/overview/settings/index.tsx
  8. 2 2
      web/app/components/app/text-generate/item/index.tsx
  9. 15 15
      web/app/components/base/portal-to-follow-elem/index.tsx
  10. 1 1
      web/app/components/base/radio/component/radio/index.tsx
  11. 2 1
      web/app/components/datasets/settings/form/index.tsx
  12. 1 1
      web/app/components/develop/secret-key/secret-key-modal.tsx
  13. 4 2
      web/app/components/explore/app-list/index.tsx
  14. 7 3
      web/app/components/explore/create-app-modal/index.tsx
  15. 2 1
      web/app/components/explore/universal-chat/config-view/detail/index.tsx
  16. 2 1
      web/app/components/explore/universal-chat/config-view/summary/index.tsx
  17. 3 2
      web/app/components/explore/universal-chat/config/index.tsx
  18. 2 1
      web/app/components/explore/universal-chat/config/plugins-config/index.tsx
  19. 2 2
      web/app/components/header/account-setting/model-page/model-item/Card.tsx
  20. 14 3
      web/app/components/header/account-setting/model-page/model-selector/index.tsx
  21. 1 1
      web/app/components/header/account-setting/plugin-page/index.tsx
  22. 1 1
      web/app/components/share/chat/index.tsx
  23. 1 1
      web/app/components/share/text-generation/result/content.tsx
  24. 1 1
      web/app/components/share/text-generation/result/index.tsx
  25. 7 3
      web/app/signin/normalForm.tsx

+ 2 - 1
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx

@@ -17,6 +17,7 @@ import type { App } from '@/types/app'
 import type { UpdateAppSiteCodeResponse } from '@/models/app'
 import { asyncRunSafe } from '@/utils'
 import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
+import type { IAppCardProps } from '@/app/components/app/overview/appCard'
 
 export type ICardViewProps = {
   appId: string
@@ -68,7 +69,7 @@ const CardView: FC<ICardViewProps> = ({ appId }) => {
     handleError(err)
   }
 
-  const onSaveSiteConfig = async (params: any) => {
+  const onSaveSiteConfig: IAppCardProps['onSaveSiteConfig'] = async (params) => {
     const [err] = await asyncRunSafe<App>(
       updateAppSiteConfig({
         url: `/apps/${appId}/site`,

+ 1 - 1
web/app/components/app/chat/answer/index.tsx

@@ -225,7 +225,7 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
                           setLoading(true)
                           const res = await onSubmitAnnotation?.(id, inputValue)
                           if (res)
-                            setAnnotation({ ...annotation, content: inputValue } as any)
+                            setAnnotation({ ...annotation, content: inputValue } as Annotation)
                           setLoading(false)
                           setShowEdit(false)
                         }}>{t('common.operation.confirm')}</Button>

+ 3 - 3
web/app/components/app/chat/index.tsx

@@ -81,7 +81,7 @@ const Chat: FC<IChatProps> = ({
   const isUseInputMethod = useRef(false)
 
   const [query, setQuery] = React.useState('')
-  const handleContentChange = (e: any) => {
+  const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
     const value = e.target.value
     setQuery(value)
   }
@@ -111,7 +111,7 @@ const Chat: FC<IChatProps> = ({
       setQuery('')
   }
 
-  const handleKeyUp = (e: any) => {
+  const handleKeyUp = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
     if (e.code === 'Enter') {
       e.preventDefault()
       // prevent send message when using input method enter
@@ -120,7 +120,7 @@ const Chat: FC<IChatProps> = ({
     }
   }
 
-  const handleKeyDown = (e: any) => {
+  const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
     isUseInputMethod.current = e.nativeEvent.isComposing
     if (e.code === 'Enter' && !e.shiftKey) {
       setQuery(query.replace(/\n$/, ''))

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 10 - 10
web/app/components/app/configuration/config-var/input-type-icon.tsx


+ 2 - 7
web/app/components/app/configuration/dataset-config/card-item/index.tsx

@@ -6,22 +6,17 @@ import { useTranslation } from 'react-i18next'
 import TypeIcon from '../type-icon'
 import RemoveIcon from '../../base/icons/remove-icon'
 import s from './style.module.css'
+import type { DataSet } from '@/models/datasets'
 import { formatNumber } from '@/utils/format'
 import Tooltip from '@/app/components/base/tooltip'
 
 export type ICardItemProps = {
   className?: string
-  config: any
+  config: DataSet
   onRemove: (id: string) => void
   readonly?: boolean
 }
 
-// const RemoveIcon = ({ className, onClick }: { className: string, onClick: () => void }) => (
-//   <svg className={className} onClick={onClick} width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
-//     <path d="M10 6H14M6 8H18M16.6667 8L16.1991 15.0129C16.129 16.065 16.0939 16.5911 15.8667 16.99C15.6666 17.3412 15.3648 17.6235 15.0011 17.7998C14.588 18 14.0607 18 13.0062 18H10.9938C9.93927 18 9.41202 18 8.99889 17.7998C8.63517 17.6235 8.33339 17.3412 8.13332 16.99C7.90607 16.5911 7.871 16.065 7.80086 15.0129L7.33333 8M10.6667 11V14.3333M13.3333 11V14.3333" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
-//   </svg>
-// )
-
 const CardItem: FC<ICardItemProps> = ({
   className,
   config,

+ 5 - 4
web/app/components/app/overview/appCard.tsx

@@ -13,6 +13,7 @@ import SettingsModal from './settings'
 import EmbeddedModal from './embedded'
 import CustomizeModal from './customize'
 import style from './style.module.css'
+import type { ConfigParams } from './settings'
 import Tooltip from '@/app/components/base/tooltip'
 import AppBasic from '@/app/components/app-sidebar/basic'
 import { asyncRunSafe, randomString } from '@/utils'
@@ -31,9 +32,9 @@ export type IAppCardProps = {
   appInfo: AppDetailResponse
   cardType?: 'api' | 'webapp'
   customBgColor?: string
-  onChangeStatus: (val: boolean) => Promise<any>
-  onSaveSiteConfig?: (params: any) => Promise<any>
-  onGenerateCode?: () => Promise<any>
+  onChangeStatus: (val: boolean) => Promise<void>
+  onSaveSiteConfig?: (params: ConfigParams) => Promise<void>
+  onGenerateCode?: () => Promise<void>
 }
 
 const EmbedIcon: FC<{ className?: string }> = ({ className = '' }) => {
@@ -193,7 +194,7 @@ function AppCard({
         </div>
         <div className={'pt-2 flex flex-row items-center'}>
           {!isApp && <SecretKeyButton className='flex-shrink-0 !h-8 bg-white mr-2' textCls='!text-gray-700 font-medium' iconCls='stroke-[1.2px]' appId={appInfo.id} />}
-          {OPERATIONS_MAP[cardType].map((op: any) => {
+          {OPERATIONS_MAP[cardType].map((op) => {
             const disabled
               = op.opName === t('appOverview.overview.appInfo.settings.entry')
                 ? false

+ 6 - 2
web/app/components/app/overview/settings/index.tsx

@@ -18,7 +18,7 @@ export type ISettingsModalProps = {
   isShow: boolean
   defaultValue?: string
   onClose: () => void
-  onSave?: (params: ConfigParams) => Promise<any>
+  onSave?: (params: ConfigParams) => Promise<void>
 }
 
 export type ConfigParams = {
@@ -26,6 +26,10 @@ export type ConfigParams = {
   description: string
   default_language: string
   prompt_public: boolean
+  copyright: string
+  privacy_policy: string
+  icon: string
+  icon_background: string
 }
 
 const LANGUAGE_MAP: Record<Language, string> = {
@@ -82,7 +86,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
   }
 
   const onChange = (field: string) => {
-    return (e: any) => {
+    return (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
       setInputInfo(item => ({ ...item, [field]: e.target.value }))
     }
   }

+ 2 - 2
web/app/components/app/text-generate/item/index.tsx

@@ -10,7 +10,7 @@ import { HashtagIcon } from '@heroicons/react/24/solid'
 import { Markdown } from '@/app/components/base/markdown'
 import Loading from '@/app/components/base/loading'
 import Toast from '@/app/components/base/toast'
-import type { Feedbacktype } from '@/app/components/app/chat'
+import type { Feedbacktype } from '@/app/components/app/chat/type'
 import { fetchMoreLikeThis, updateFeedback } from '@/service/share'
 
 const MAX_DEPTH = 3
@@ -136,7 +136,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
   }
 
   const mainStyle = (() => {
-    const res: any = !isTop
+    const res: React.CSSProperties = !isTop
       ? {
         background: depth % 2 === 0 ? 'linear-gradient(90.07deg, #F9FAFB 0.05%, rgba(249, 250, 251, 0) 99.93%)' : '#fff',
       }

+ 15 - 15
web/app/components/base/portal-to-follow-elem/index.tsx

@@ -1,9 +1,10 @@
 'use client'
 import { useBoolean } from 'ahooks'
-import React, { FC, useEffect, useState, useRef } from 'react'
+import React, { useEffect, useRef, useState } from 'react'
+import type { FC } from 'react'
 import { createRoot } from 'react-dom/client'
 
-export interface IPortalToFollowElementProps {
+type IPortalToFollowElementProps = {
   portalElem: React.ReactNode
   children: React.ReactNode
   controlShow?: number
@@ -14,44 +15,42 @@ const PortalToFollowElement: FC<IPortalToFollowElementProps> = ({
   portalElem,
   children,
   controlShow,
-  controlHide
+  controlHide,
 }) => {
   const [isShowContent, { setTrue: showContent, setFalse: hideContent, toggle: toggleContent }] = useBoolean(false)
   const [wrapElem, setWrapElem] = useState<HTMLDivElement | null>(null)
 
   useEffect(() => {
-    if (controlShow) {
+    if (controlShow)
       showContent()
-    }
   }, [controlShow])
 
   useEffect(() => {
-    if (controlHide) {
+    if (controlHide)
       hideContent()
-    }
   }, [controlHide])
 
   // todo use click outside hidden
-  const triggerElemRef = useRef<HTMLElement>(null)
+  const triggerElemRef = useRef<HTMLDivElement>(null)
 
   const calLoc = () => {
     const triggerElem = triggerElemRef.current
     if (!triggerElem) {
       return {
-        display: 'none'
+        display: 'none',
       }
     }
     const {
       left: triggerLeft,
       top: triggerTop,
-      height
-    } = triggerElem.getBoundingClientRect();
+      height,
+    } = triggerElem.getBoundingClientRect()
 
     return {
       position: 'fixed',
       left: triggerLeft,
       top: triggerTop + height,
-      zIndex: 999
+      zIndex: 999,
     }
   }
 
@@ -63,19 +62,20 @@ const PortalToFollowElement: FC<IPortalToFollowElementProps> = ({
       root.render(
         <div style={style as React.CSSProperties}>
           {portalElem}
-        </div>
+        </div>,
       )
       document.body.appendChild(holder)
       setWrapElem(holder)
       console.log(holder)
-    } else {
+    }
+    else {
       wrapElem?.remove?.()
       setWrapElem(null)
     }
   }, [isShowContent])
 
   return (
-    <div ref={triggerElemRef as any} onClick={toggleContent}>
+    <div ref={triggerElemRef as React.RefObject<HTMLDivElement>} onClick={toggleContent}>
       {children}
     </div>
   )

+ 1 - 1
web/app/components/base/radio/component/radio/index.tsx

@@ -26,7 +26,7 @@ export default function Radio({
 }: IRadioProps): JSX.Element {
   const groupContext = useContext(RadioGroupContext)
   const labelId = useId()
-  const handleChange = (e: any) => {
+  const handleChange = (e: IRadioProps['value']) => {
     if (disabled)
       return
 

+ 2 - 1
web/app/components/datasets/settings/form/index.tsx

@@ -1,5 +1,6 @@
 'use client'
 import { useEffect, useState } from 'react'
+import type { Dispatch } from 'react'
 import useSWR from 'swr'
 import { useContext } from 'use-context-selector'
 import { BookOpenIcon } from '@heroicons/react/24/outline'
@@ -24,7 +25,7 @@ const labelClass = `
 const inputClass = `
   w-[480px] px-3 bg-gray-100 text-sm text-gray-800 rounded-lg outline-none appearance-none
 `
-const useInitialValue = (depend: any, dispatch: any) => {
+const useInitialValue: <T>(depend: T, dispatch: Dispatch<T>) => void = (depend, dispatch) => {
   useEffect(() => {
     dispatch(depend)
   }, [depend])

+ 1 - 1
web/app/components/develop/secret-key/secret-key-modal.tsx

@@ -79,7 +79,7 @@ const SecretKeyModal = ({
     return `${token.slice(0, 3)}...${token.slice(-20)}`
   }
 
-  const formatDate = (timestamp: any) => {
+  const formatDate = (timestamp: string) => {
     if (locale === 'en')
       return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format((+timestamp) * 1000)
     else

+ 4 - 2
web/app/components/explore/app-list/index.tsx

@@ -13,8 +13,10 @@ import AppCard from '@/app/components/explore/app-card'
 import { fetchAppDetail, fetchAppList, installApp } from '@/service/explore'
 import { createApp } from '@/service/apps'
 import CreateAppModal from '@/app/components/explore/create-app-modal'
+import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
 import Loading from '@/app/components/base/loading'
 import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
+import { type AppMode } from '@/types/app'
 
 const Apps: FC = () => {
   const { t } = useTranslation()
@@ -50,7 +52,7 @@ const Apps: FC = () => {
 
   const [currApp, setCurrApp] = React.useState<App | null>(null)
   const [isShowCreateModal, setIsShowCreateModal] = React.useState(false)
-  const onCreate = async ({ name, icon, icon_background }: any) => {
+  const onCreate: CreateAppModalProps['onConfirm'] = async ({ name, icon, icon_background }) => {
     const { app_model_config: model_config } = await fetchAppDetail(currApp?.app.id as string)
 
     try {
@@ -58,7 +60,7 @@ const Apps: FC = () => {
         name,
         icon,
         icon_background,
-        mode: currApp?.app.mode as any,
+        mode: currApp?.app.mode as AppMode,
         config: model_config,
       })
       setIsShowCreateModal(false)

+ 7 - 3
web/app/components/explore/create-app-modal/index.tsx

@@ -9,10 +9,14 @@ import Toast from '@/app/components/base/toast'
 import AppIcon from '@/app/components/base/app-icon'
 import EmojiPicker from '@/app/components/base/emoji-picker'
 
-type IProps = {
+export type CreateAppModalProps = {
   appName: string
   show: boolean
-  onConfirm: (info: any) => void
+  onConfirm: (info: {
+    name: string
+    icon: string
+    icon_background: string
+  }) => Promise<void>
   onHide: () => void
 }
 
@@ -21,7 +25,7 @@ const CreateAppModal = ({
   show = false,
   onConfirm,
   onHide,
-}: IProps) => {
+}: CreateAppModalProps) => {
   const { t } = useTranslation()
 
   const [name, setName] = React.useState('')

+ 2 - 1
web/app/components/explore/universal-chat/config-view/detail/index.tsx

@@ -6,12 +6,13 @@ import { useTranslation } from 'react-i18next'
 import s from './style.module.css'
 import Config from '@/app/components/explore/universal-chat/config'
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
+import type { DataSet } from '@/models/datasets'
 
 type Props = {
   modelId: string
   providerName: ProviderEnum
   plugins: Record<string, boolean>
-  dataSets: any[]
+  dataSets: DataSet[]
 }
 const ConfigViewPanel: FC<Props> = ({
   modelId,

+ 2 - 1
web/app/components/explore/universal-chat/config-view/summary/index.tsx

@@ -10,12 +10,13 @@ import ConfigDetail from '@/app/components/explore/universal-chat/config-view/de
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
 import ModelName from '@/app/components/app/configuration/config-model/model-name'
 import { useProviderContext } from '@/context/provider-context'
+import type { DataSet } from '@/models/datasets'
 
 export type ISummaryProps = {
   modelId: string
   providerName: ProviderEnum
   plugins: Record<string, boolean>
-  dataSets: any[]
+  dataSets: DataSet[]
 }
 
 const getColorInfo = (modelId: string) => {

+ 3 - 2
web/app/components/explore/universal-chat/config/index.tsx

@@ -5,6 +5,7 @@ import ModelConfig from './model-config'
 import DataConfig from './data-config'
 import PluginConfig from './plugins-config'
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
+import type { DataSet } from '@/models/datasets'
 
 export type IConfigProps = {
   className?: string
@@ -14,8 +15,8 @@ export type IConfigProps = {
   onModelChange?: (modelId: string, providerName: ProviderEnum) => void
   plugins: Record<string, boolean>
   onPluginChange?: (key: string, value: boolean) => void
-  dataSets: any[]
-  onDataSetsChange?: (contexts: any[]) => void
+  dataSets: DataSet[]
+  onDataSetsChange?: (contexts: DataSet[]) => void
 }
 
 const Config: FC<IConfigProps> = ({

+ 2 - 1
web/app/components/explore/universal-chat/config/plugins-config/index.tsx

@@ -19,7 +19,8 @@ const plugins = [
   { key: 'google_search', icon: <Google /> },
   { key: 'web_reader', icon: <WebReader /> },
   { key: 'wikipedia', icon: <Wikipedia /> },
-]
+] as const
+
 const Plugins: FC<IPluginsProps> = ({
   readonly,
   config,

+ 2 - 2
web/app/components/header/account-setting/model-page/model-item/Card.tsx

@@ -8,7 +8,7 @@ import Button from '@/app/components/base/button'
 
 type CardProps = {
   providerType: ProviderEnum
-  models: any[]
+  models: Model[]
   onOpenModal: (v: any) => void
   onOperate: (v: Record<string, any>) => void
 }
@@ -33,7 +33,7 @@ const Card: FC<CardProps> = ({
   return (
     <div className='px-3 pb-3'>
       {
-        models.map((model: Model) => (
+        models.map(model => (
           <div key={`${model.model_name}-${model.model_type}`} className='flex mb-1 px-3 py-2 bg-white rounded-lg shadow-xs last:mb-0'>
             <div className='grow'>
               <div className='flex items-center mb-0.5 h-[18px] text-[13px] font-medium text-gray-700'>

+ 14 - 3
web/app/components/header/account-setting/model-page/model-selector/index.tsx

@@ -15,6 +15,7 @@ import ModelIcon from '@/app/components/app/configuration/config-model/model-ico
 import ModelName, { supportI18nModelName } from '@/app/components/app/configuration/config-model/model-name'
 import ProviderName from '@/app/components/app/configuration/config-model/provider-name'
 import { useProviderContext } from '@/context/provider-context'
+
 type Props = {
   value: {
     providerName: ProviderEnum
@@ -28,6 +29,16 @@ type Props = {
   triggerIconSmall?: boolean
 }
 
+type ModelOption = {
+  type: 'model'
+  value: string
+  providerName: ProviderEnum
+  modelDisplayName: string
+} | {
+  type: 'provider'
+  value: ProviderEnum
+}
+
 const ModelSelector: FC<Props> = ({
   value,
   modelType,
@@ -69,9 +80,9 @@ const ModelSelector: FC<Props> = ({
 
   const hasRemoved = value && !modelList.find(({ model_name }) => model_name === value.modelName)
 
-  const modelOptions: any[] = (() => {
+  const modelOptions: ModelOption[] = (() => {
     const providers = _.uniq(filteredModelList.map(item => item.model_provider.provider_name))
-    const res: any[] = []
+    const res: ModelOption[] = []
     providers.forEach((providerName) => {
       res.push({
         type: 'provider',
@@ -162,7 +173,7 @@ const ModelSelector: FC<Props> = ({
                 </div>
               </div>
               {
-                modelOptions.map((model: any) => {
+                modelOptions.map((model) => {
                   if (model.type === 'provider') {
                     return (
                       <div

+ 1 - 1
web/app/components/header/account-setting/plugin-page/index.tsx

@@ -10,7 +10,7 @@ const PluginPage = () => {
   const { t } = useTranslation()
   const { data: plugins, mutate } = useSWR('/workspaces/current/tool-providers', fetchPluginProviders)
 
-  const Plugin_MAP: Record<string, any> = {
+  const Plugin_MAP: Record<string, (plugin: PluginProvider) => JSX.Element> = {
     serpapi: (plugin: PluginProvider) => <SerpapiPlugin key='serpapi' plugin={plugin} onUpdate={() => mutate()} />,
   }
 

+ 1 - 1
web/app/components/share/chat/index.tsx

@@ -30,7 +30,7 @@ import {
 } from '@/service/share'
 import type { ConversationItem, SiteInfo } from '@/models/share'
 import type { PromptConfig, SuggestedQuestionsAfterAnswerConfig } from '@/models/debug'
-import type { Feedbacktype, IChatItem } from '@/app/components/app/chat'
+import type { Feedbacktype, IChatItem } from '@/app/components/app/chat/type'
 import Chat from '@/app/components/app/chat'
 import { changeLanguage } from '@/i18n/i18next-config'
 import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'

+ 1 - 1
web/app/components/share/text-generation/result/content.tsx

@@ -1,7 +1,7 @@
 import type { FC } from 'react'
 import React from 'react'
 import Header from './header'
-import type { Feedbacktype } from '@/app/components/app/chat'
+import type { Feedbacktype } from '@/app/components/app/chat/type'
 import { format } from '@/service/base'
 
 export type IResultProps = {

+ 1 - 1
web/app/components/share/text-generation/result/index.tsx

@@ -8,7 +8,7 @@ import TextGenerationRes from '@/app/components/app/text-generate/item'
 import NoData from '@/app/components/share/text-generation/no-data'
 import Toast from '@/app/components/base/toast'
 import { sendCompletionMessage, updateFeedback } from '@/service/share'
-import type { Feedbacktype } from '@/app/components/app/chat'
+import type { Feedbacktype } from '@/app/components/app/chat/type'
 import Loading from '@/app/components/base/loading'
 import type { PromptConfig } from '@/models/debug'
 import type { InstalledApp } from '@/models/explore'

+ 7 - 3
web/app/signin/normalForm.tsx

@@ -22,7 +22,11 @@ type IState = {
   google: boolean
 }
 
-function reducer(state: IState, action: { type: string; payload: any }) {
+type IAction = {
+  type: 'login' | 'login_failed' | 'github_login' | 'github_login_failed' | 'google_login' | 'google_login_failed'
+}
+
+function reducer(state: IState, action: IAction) {
   switch (action.type) {
     case 'login':
       return {
@@ -120,14 +124,14 @@ const NormalForm = () => {
 
   useEffect(() => {
     if (github_error !== undefined)
-      dispatch({ type: 'github_login_failed', payload: null })
+      dispatch({ type: 'github_login_failed' })
     if (github)
       window.location.href = github.redirect_url
   }, [github, github_error])
 
   useEffect(() => {
     if (google_error !== undefined)
-      dispatch({ type: 'google_login_failed', payload: null })
+      dispatch({ type: 'google_login_failed' })
     if (google)
       window.location.href = google.redirect_url
   }, [google, google])