diff --git a/src/assets/js/components/popup/settings.jsx b/src/assets/js/components/popup/settings.jsx index 82d9640..eda325b 100644 --- a/src/assets/js/components/popup/settings.jsx +++ b/src/assets/js/components/popup/settings.jsx @@ -1,21 +1,41 @@ import React from 'react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; import classNames from 'classnames'; import { signOut } from '@/features/popup/popupSlice'; +import { getCompany, getUser } from '@/main' +import { PopupSpinner } from '@/components/popup/popup-spinner'; export const Settings = () => { const dispatch = useDispatch(); - const [isLoading, setIsLoading] = useState(false); + const [isButtonLoading, setIsButtonLoading] = useState(false); + const [companyName, setCompanyName] = useState(''); + const [isViewLoading, setIsViewLoading] = useState(false); + + const getCompanyData = async () => { + setIsViewLoading(true); + const user = await getUser(); + const company = await getCompany(user); + setCompanyName(company); + setIsViewLoading(false); + }; + + useEffect(() => { + getCompanyData(); + }, [companyName]); const handleSignOut = async (event) => { event.preventDefault(); - setIsLoading(true); + setIsButtonLoading(true); dispatch(signOut()); - setIsLoading(false); + setIsButtonLoading(false); }; + if (isViewLoading) { + return ; + } + return (
@@ -34,6 +54,14 @@ export const Settings = () => {
signed in + + { + companyName && ( +

+ You are signed in as a member of {companyName}. +

+ ) + }
@@ -42,7 +70,7 @@ export const Settings = () => { onClick={handleSignOut} > { - isLoading + isButtonLoading ? (