Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Apr 8, 2024
1 parent 5b3e04d commit 07693fa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
8 changes: 3 additions & 5 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ export interface FetchError {
}

export interface UseApiData {
<Type>(apiPath: string): [
Type | undefined,
() => void,
FetchError | undefined
];
<Type>(
apiPath: string,
): [Type | undefined, () => void, FetchError | undefined];
}

/** API related interfaces */
Expand Down
52 changes: 26 additions & 26 deletions src/containers/internal/views/speech-services/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
const [initialSttCheck, setInitialSttCheck] = useState(false);
const [sttCheck, setSttCheck] = useState(false);
const [vendor, setVendor] = useState<Lowercase<Vendor>>(
"" as Lowercase<Vendor>
"" as Lowercase<Vendor>,
);
const [region, setRegion] = useState("");
const [apiKey, setApiKey] = useState("");
Expand Down Expand Up @@ -223,13 +223,13 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
speech_credential_sid: credential.data?.speech_credential_sid,
});
}
})
}),
)
.then(() => {
toastSuccess("Speech credential updated successfully");
credential.refetch();
navigate(
`${ROUTE_INTERNAL_SPEECH}/${credential?.data?.speech_credential_sid}/edit`
`${ROUTE_INTERNAL_SPEECH}/${credential?.data?.speech_credential_sid}/edit`,
);
})
.catch((error) => {
Expand All @@ -241,13 +241,13 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
if (v.google_custom_voice_sid) {
return deleteGoogleCustomVoice(v.google_custom_voice_sid);
}
})
}),
)
.then(() => {
toastSuccess("Speech credential updated successfully");
credential.refetch();
navigate(
`${ROUTE_INTERNAL_SPEECH}/${credential?.data?.speech_credential_sid}/edit`
`${ROUTE_INTERNAL_SPEECH}/${credential?.data?.speech_credential_sid}/edit`,
);
})
.catch((error) => {
Expand All @@ -257,7 +257,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
toastSuccess("Speech credential updated successfully");
credential.refetch();
navigate(
`${ROUTE_INTERNAL_SPEECH}/${credential.data.speech_credential_sid}/edit`
`${ROUTE_INTERNAL_SPEECH}/${credential.data.speech_credential_sid}/edit`,
);
}
};
Expand All @@ -267,7 +267,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {

if (isUserAccountScope(accountSid, user)) {
toastError(
"You do not have permissions to make changes to these Speech Credentials"
"You do not have permissions to make changes to these Speech Credentials",
);
return;
}
Expand Down Expand Up @@ -343,7 +343,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
putSpeechService(
currentServiceProvider.service_provider_sid,
credential.data.speech_credential_sid,
payload
payload,
)
.then(() => {
if (credential && credential.data) {
Expand All @@ -353,7 +353,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
toastSuccess("Speech credential updated successfully");
credential.refetch();
navigate(
`${ROUTE_INTERNAL_SPEECH}/${credential.data.speech_credential_sid}/edit`
`${ROUTE_INTERNAL_SPEECH}/${credential.data.speech_credential_sid}/edit`,
);
}
}
Expand Down Expand Up @@ -394,8 +394,8 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
postGoogleCustomVoice({
...v,
speech_credential_sid: json.sid,
})
)
}),
),
).then(() => {
toastSuccess("Speech credential created successfully");
navigate(ROUTE_INTERNAL_SPEECH);
Expand Down Expand Up @@ -423,7 +423,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
getSpeechSupportedLanguagesAndVoices(
currentServiceProvider?.service_provider_sid,
vendor,
""
"",
).then(({ json }) => {
if (json.models) {
setTtsModels(json.models);
Expand Down Expand Up @@ -562,13 +562,13 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
setInitialCheckCustomStt(isNotBlank(credential.data.custom_stt_endpoint));
setInitialCheckOnpremAzureService(
isNotBlank(credential.data.custom_tts_endpoint_url) ||
isNotBlank(credential.data.custom_stt_endpoint_url)
isNotBlank(credential.data.custom_stt_endpoint_url),
);

setCustomVendorName(
credential.data.vendor.startsWith(VENDOR_CUSTOM)
? credential.data.vendor.substring(VENDOR_CUSTOM.length + 1)
: credential.data.vendor
: credential.data.vendor,
);
setCustomVendorAuthToken(credential.data.auth_token || "");
setCustomVendorSttUrl(credential.data.custom_stt_url || "");
Expand Down Expand Up @@ -603,7 +603,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
}
if (credential?.data?.deepgram_stt_use_tls) {
setDeepgramSttUseTls(
credential?.data?.deepgram_stt_use_tls > 0 ? true : false
credential?.data?.deepgram_stt_use_tls > 0 ? true : false,
);
}
setInitialDeepgramOnpremCheck(hasValue(credential?.data?.deepgram_stt_uri));
Expand All @@ -621,7 +621,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
const updateCustomVoices = (
index: number,
key: string,
value: typeof customVoices[number][keyof GoogleCustomVoice]
value: (typeof customVoices)[number][keyof GoogleCustomVoice],
) => {
setCustomVoices((prev) =>
prev.map((g, i) =>
Expand All @@ -630,8 +630,8 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
...g,
[key]: value,
}
: g
)
: g,
),
);
};

Expand Down Expand Up @@ -668,7 +668,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
]
.concat(vendors)
.filter(
(v) => !DISABLE_CUSTOM_SPEECH || v.value !== VENDOR_CUSTOM
(v) => !DISABLE_CUSTOM_SPEECH || v.value !== VENDOR_CUSTOM,
)}
onChange={(e) => {
setVendor(e.target.value as Lowercase<Vendor>);
Expand Down Expand Up @@ -879,7 +879,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
{JSON.stringify(
getObscuredGoogleServiceKey(googleServiceKey),
null,
2
2,
)}
</code>
</pre>
Expand Down Expand Up @@ -954,7 +954,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
updateCustomVoices(
i,
"reported_usage",
e.target.value
e.target.value,
);
}}
/>
Expand All @@ -981,7 +981,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
updateCustomVoices(
i,
"model",
e.target.value
e.target.value,
);
}}
/>
Expand All @@ -996,19 +996,19 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
setCustomVoicesMessage("");
if (customVoices.length === 1) {
setCustomVoicesMessage(
"You must provide at least one custom voice."
"You must provide at least one custom voice.",
);
return;
}
if (v.google_custom_voice_sid) {
deleteGoogleCustomVoice(
v.google_custom_voice_sid
v.google_custom_voice_sid,
).finally(() => {
credential?.refetch();
});
}
setCustomVoices((prev) =>
prev.filter((_, idx) => idx !== i)
prev.filter((_, idx) => idx !== i),
);
}}
>
Expand Down Expand Up @@ -1282,7 +1282,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
setOptions(
tmpOptions
? tmpOptions
: JSON.stringify(getDefaultVendorOptions(), null, 2)
: JSON.stringify(getDefaultVendorOptions(), null, 2),
);
}
if (!e.target.checked) {
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const useRegionVendors = () => {
ibm: ibmRegions,
});
}
}
},
);

return function cleanup() {
Expand Down

0 comments on commit 07693fa

Please sign in to comment.