Skip to content

Commit

Permalink
fix: error handling passphrase
Browse files Browse the repository at this point in the history
  • Loading branch information
Saelmala committed Nov 15, 2024
1 parent cd22b61 commit 3a2158f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/modal/addSrtModal/AddSrtModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function AddSrtModal({
const [latency, setLatency] = useState<number>(120);
const [name, setName] = useState<string>('My SRT source');
const [passphrase, setPassphrase] = useState<string>();
const [isPassphraseError, setIsPassphraseError] = useState<boolean>(false);
const [isNameError, setIsNameError] = useState<boolean>(false);
const [isIngestNameError, setIsIngestNameError] = useState<boolean>(false);
const [isLocalPortError, setIsLocalPortError] = useState<boolean>(false);
Expand Down Expand Up @@ -221,6 +222,15 @@ export function AddSrtModal({
hasError = true;
}

if (
passphrase &&
passphrase !== '' &&
(passphrase.length < 10 || passphrase.length > 79)
) {
setIsPassphraseError(true);
hasError = true;
}

if (hasError) {
return;
}
Expand Down Expand Up @@ -455,6 +465,11 @@ export function AddSrtModal({
value={passphrase}
onChange={handleInputChange(setPassphrase)}
/>
{isPassphraseError && (
<p className="text-xs text-button-delete mt-2">
{t('inventory_list.passphrase_error')}
</p>
)}
</span>
</span>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ export const en = {
no_remote_port: 'You need to enter a remote port',
port_already_in_use_error:
'There is already a SRT source with this port. Choose a different port.',
passphrase_error: 'The passphrase needs to be between 10 and 79 characters',
cancel: 'Cancel'
},
clear: 'Clear',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ export const sv = {
no_remote_port: 'Du behöver fylla i en remote port',
port_already_in_use_error:
'Den här porten används redan av en annan SRT källa. Välj en annan port.',
passphrase_error: 'Lösenordet måste vara mellan 10 och 79 tecken',
cancel: 'Avbryt'
},
clear: 'Rensa',
Expand Down

0 comments on commit 3a2158f

Please sign in to comment.