Refactors useLocale (#908)

* Removes unused component

* Refactors useLocale

We don't need to pass the locale prop everywhere

* Fixes syntax error

* Adds warning for missing localeProps

* Simplify i18n utils

* Update components/I18nLanguageHandler.tsx

Co-authored-by: Mihai C <34626017+mihaic195@users.noreply.github.com>

* Type fixes

Co-authored-by: Mihai C <34626017+mihaic195@users.noreply.github.com>
This commit is contained in:
Omar López
2021-10-12 13:11:33 +00:00
committed by GitHub
co-authored by Mihai C
parent 7dd6fdde7a
commit cfd70172f0
35 changed files with 366 additions and 440 deletions
+2 -3
View File
@@ -19,7 +19,6 @@ interface EnableTwoFactorModalProps {
* Called when the user enables two-factor auth
*/
onEnable: () => void;
localeProp: string;
}
enum SetupStep {
@@ -47,7 +46,7 @@ const WithStep = ({
return step === current ? children : null;
};
const EnableTwoFactorModal = ({ onEnable, onCancel, localeProp }: EnableTwoFactorModalProps) => {
const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps) => {
const [step, setStep] = useState(SetupStep.ConfirmPassword);
const [password, setPassword] = useState("");
const [totpCode, setTotpCode] = useState("");
@@ -55,7 +54,7 @@ const EnableTwoFactorModal = ({ onEnable, onCancel, localeProp }: EnableTwoFacto
const [secret, setSecret] = useState("");
const [isSubmitting, setIsSubmitting] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const { t } = useLocale({ localeProp });
const { t } = useLocale();
async function handleSetup(e: SyntheticEvent) {
e.preventDefault();