Skip to content

Commit

Permalink
chore: rename React components
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomiguelino committed Dec 4, 2024
1 parent 1fb77b7 commit 0a0a6ec
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useDispatch } from 'react-redux';
import { useState } from 'react';
import { signOut } from '@/features/auth/authSlice';

export const SignedIn = () => {
export const AuthenticatedOptionsView = () => {
const dispatch = useDispatch();
const [isLoading, setIsLoading] = useState(false);

Expand Down
18 changes: 9 additions & 9 deletions src/assets/js/components/options/sign-in.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { callApi } from '@/main';
import { signIn } from '@/features/auth/authSlice';
import { TokenHelpText } from '@/components/options/token-help-text';

const SignInError = () => {
const SignInFormError = () => {
return (
<div className='alert alert-danger mt-2' role='alert'>
Unable to sign in. Check your credentials and internet connectivity,
Expand All @@ -15,9 +15,9 @@ const SignInError = () => {
);
}

export const SignIn = () => {
export const SignInForm = () => {
const [isLoading, setIsLoading] = useState(false);
const [showSignInError, setShowSignInError] = useState(false);
const [showSignInFormError, setShowSignInFormError] = useState(false);
const [token, setToken] = useState('');
const dispatch = useDispatch();

Expand All @@ -27,7 +27,7 @@ export const SignIn = () => {
return `${baseUrl}?${queryParams}`;
};

const handleSignIn = async (event) => {
const handleSignInForm = async (event) => {
event.preventDefault();
setIsLoading(true);

Expand All @@ -41,10 +41,10 @@ export const SignIn = () => {

await browser.storage.sync.set({ token: token });

setShowSignInError(false);
setShowSignInFormError(false);
dispatch(signIn());
} catch (error) {
setShowSignInError(true);
setShowSignInFormError(true);
} finally {
setIsLoading(false);
}
Expand All @@ -66,7 +66,7 @@ export const SignIn = () => {
className="btn btn-primary w-100"
id="sign-in-submit"
type="submit"
onClick={handleSignIn}
onClick={handleSignInForm}
>
{
isLoading
Expand All @@ -82,8 +82,8 @@ export const SignIn = () => {
<TokenHelpText />

{
showSignInError
? <SignInError />
showSignInFormError
? <SignInFormError />
: null
}
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/components/popup/sign-in.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export const PopupSignIn = () => {
export const SignInCallToAction = () => {
const handleSignIn = (event) => {
browser.runtime.openOptionsPage();
};
Expand Down
14 changes: 8 additions & 6 deletions src/assets/js/options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import {
import 'bootstrap/scss/bootstrap.scss';
import '@/scss/style.scss';

import { SignIn } from '@/components/options/sign-in';
import { SignedIn } from '@/components/options/signed-in';
import { SignInForm } from '@/components/options/sign-in';
import {
AuthenticatedOptionsView
} from '@/components/options/authenticated-options';

import { store } from '@/store';
import { signIn } from '@/features/auth/authSlice';

const Options = () => {
const OptionsPage = () => {
const signedIn = useSelector((state) => state.auth.signedIn);
const dispatch = useDispatch();

Expand All @@ -39,8 +41,8 @@ const Options = () => {

{
signedIn
? <SignedIn />
: <SignIn />
? <AuthenticatedOptionsView />
: <SignInForm />
}
</div>
</div>
Expand All @@ -50,6 +52,6 @@ const Options = () => {
const root = ReactDOM.createRoot(document.getElementById('app'));
root.render(
<Provider store={store}>
<Options />
<OptionsPage />
</Provider>
);
8 changes: 4 additions & 4 deletions src/assets/js/popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'bootstrap/scss/bootstrap.scss';
import '@/scss/style.scss';
import '@/scss/sweetalert-icons.scss';

import { PopupSignIn } from '@/components/popup/sign-in';
import { SignInCallToAction } from '@/components/popup/sign-in';
import { Success } from '@/components/popup/success';
import { Proposal } from '@/components/popup/proposal';

Expand All @@ -24,7 +24,7 @@ import {
setShowProposal,
} from '@/features/popup/popupSlice';

const Popup = () => {
const PopupPage = () => {
const dispatch = useDispatch();

const showSignIn = useSelector((state) => state.popup.showSignIn);
Expand All @@ -42,7 +42,7 @@ const Popup = () => {

return (
<>
{showSignIn && <PopupSignIn />}
{showSignIn && <SignInCallToAction />}
{showProposal && <Proposal />}
{showSuccess && <Success />}
</>
Expand All @@ -52,6 +52,6 @@ const Popup = () => {
const root = ReactDOM.createRoot(document.getElementById('app'));
root.render(
<Provider store={store}>
<Popup />
<PopupPage />
</Provider>
);

0 comments on commit 0a0a6ec

Please sign in to comment.