|
1 | 1 | import { TextField, Typography } from '@mui/material'
|
2 | 2 | import VisibilityOffIcon from '@mui/icons-material/VisibilityOff'
|
3 | 3 | import { useEffect } from 'react'
|
| 4 | +import { useTranslation } from 'react-i18next' |
4 | 5 |
|
5 |
| -const VisibilityOff = () => ( |
6 |
| - <div style={{ display: 'flex', alignItems: 'center' }}> |
7 |
| - <Typography variant="body1" color="textSecondary" style={{ marginRight: 8 }}> |
8 |
| - Tämä alustus on piilotettu |
9 |
| - </Typography> |
10 |
| - <VisibilityOffIcon fontSize="small" /> |
11 |
| - </div> |
12 |
| -) |
| 6 | +const VisibilityOff = () => { |
| 7 | + const { t } = useTranslation() |
| 8 | + return ( |
| 9 | + <div style={{ display: 'flex', alignItems: 'center' }}> |
| 10 | + <Typography variant="body1" color="textSecondary" style={{ marginRight: 8 }}> |
| 11 | + {t('chatV2.hiddenInstructions')} |
| 12 | + </Typography> |
| 13 | + <VisibilityOffIcon fontSize="small" /> |
| 14 | + </div> |
| 15 | + ) |
| 16 | +} |
13 | 17 |
|
14 | 18 | export default function AssistantInstructionsInput({
|
15 | 19 | label,
|
16 | 20 | disabled,
|
17 | 21 | hidden,
|
18 | 22 | instructions,
|
19 |
| - setInstructions, |
20 | 23 | instructionsInputFieldRef,
|
21 | 24 | }: {
|
22 | 25 | label: string
|
23 | 26 | disabled: boolean
|
24 | 27 | hidden: boolean
|
25 | 28 | instructions: string
|
26 |
| - setInstructions: (instructions: string) => void |
27 |
| - instructionsInputFieldRef: any |
| 29 | + instructionsInputFieldRef: React.RefObject<HTMLInputElement> |
28 | 30 | }): JSX.Element {
|
29 | 31 | useEffect(() => {
|
30 |
| - instructionsInputFieldRef.current.value = instructions //this change will be seen since the assistantInstructions is also updated |
31 |
| - }, [instructions]) |
| 32 | + if (instructionsInputFieldRef.current) { |
| 33 | + instructionsInputFieldRef.current.value = instructions |
| 34 | + } |
| 35 | + }, [instructions, instructionsInputFieldRef.current]) |
32 | 36 | return hidden ? (
|
33 | 37 | <TextField disabled={true} label={<VisibilityOff />} />
|
34 | 38 | ) : (
|
|
0 commit comments