mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 14:35:55 +08:00
refactor: type improvement of file oneMoreStep.tsx
(#17431)
This commit is contained in:
parent
da2113bde9
commit
95212af935
@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useEffect, useReducer } from 'react'
|
import React, { type Reducer, useEffect, useReducer } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import useSWR from 'swr'
|
import useSWR from 'swr'
|
||||||
@ -20,7 +20,14 @@ type IState = {
|
|||||||
timezone: string
|
timezone: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const reducer = (state: IState, action: any) => {
|
type IAction =
|
||||||
|
| { type: 'failed', payload: null }
|
||||||
|
| { type: 'invitation_code', value: string }
|
||||||
|
| { type: 'interface_language', value: string }
|
||||||
|
| { type: 'timezone', value: string }
|
||||||
|
| { type: 'formState', value: 'processing' }
|
||||||
|
|
||||||
|
const reducer: Reducer<IState, IAction> = (state: IState, action: IAction) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'invitation_code':
|
case 'invitation_code':
|
||||||
return { ...state, invitation_code: action.value }
|
return { ...state, invitation_code: action.value }
|
||||||
@ -120,7 +127,7 @@ const OneMoreStep = () => {
|
|||||||
defaultValue={LanguagesSupported[0]}
|
defaultValue={LanguagesSupported[0]}
|
||||||
items={languages.filter(item => item.supported)}
|
items={languages.filter(item => item.supported)}
|
||||||
onSelect={(item) => {
|
onSelect={(item) => {
|
||||||
dispatch({ type: 'interface_language', value: item.value })
|
dispatch({ type: 'interface_language', value: item.value as typeof LanguagesSupported[number] })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -134,7 +141,7 @@ const OneMoreStep = () => {
|
|||||||
defaultValue={state.timezone}
|
defaultValue={state.timezone}
|
||||||
items={timezones}
|
items={timezones}
|
||||||
onSelect={(item) => {
|
onSelect={(item) => {
|
||||||
dispatch({ type: 'timezone', value: item.value })
|
dispatch({ type: 'timezone', value: item.value as typeof state.timezone })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user