This commit is contained in:
2025-03-02 20:05:35 +02:00
committed by Nicola Benaglia
parent b1b7114972
commit 680f9fbd3e
6 changed files with 60 additions and 20 deletions

View File

@@ -1443,7 +1443,7 @@ function App() {
</>
) : (
<>
<MainAvatar myName={userInfo?.name} />
<MainAvatar setOpenSnack={setOpenSnack} setInfoSnack={setInfoSnack} myName={userInfo?.name} balance={balance} />
<Spacer height="32px" />
<TextP
sx={{
@@ -3294,7 +3294,7 @@ function App() {
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{"Warning"}</DialogTitle>
<DialogTitle id="alert-dialog-title">{"LOGOUT"}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
{messageUnsavedChanges.message}
@@ -3336,7 +3336,6 @@ function App() {
flexDirection: "column",
alignItems: "center",
justifyContent: "flex-start",
minHeight: "400px",
maxHeight: "90vh",
overflow: "auto",
}}

View File

@@ -941,7 +941,7 @@ export async function getBalanceInfo() {
const validApi = await getBaseApi();
const response = await fetch(validApi + "/addresses/balance/" + address);
if (!response?.ok) throw new Error("Cannot fetch balance");
if (!response?.ok) throw new Error("0 QORT in your balance");
const data = await response.json();
return data;
}
@@ -1101,7 +1101,7 @@ export const getLastRef = async () => {
const response = await fetch(
validApi + "/addresses/lastreference/" + address
);
if (!response?.ok) throw new Error("Cannot fetch balance");
if (!response?.ok) throw new Error("0 QORT in your balance");
const data = await response.text();
return data;
};

View File

@@ -809,6 +809,7 @@ export const ListOfGroupPromotions = () => {
value={selectedGroup}
label="Groups where you are an admin"
onChange={(e) => setSelectedGroup(e.target.value)}
variant="outlined"
>
{myGroupsWhereIAmAdmin?.map((group) => {
return (

View File

@@ -7,8 +7,9 @@ import ImageUploader from "../common/ImageUploader";
import { getFee } from "../background";
import { fileToBase64 } from "../utils/fileReading";
import { LoadingButton } from "@mui/lab";
import ErrorIcon from '@mui/icons-material/Error';
export const MainAvatar = ({ myName }) => {
export const MainAvatar = ({ myName, balance, setOpenSnack, setInfoSnack }) => {
const [hasAvatar, setHasAvatar] = useState(false);
const [avatarFile, setAvatarFile] = useState(null);
const [tempAvatar, setTempAvatar] = useState(null)
@@ -52,10 +53,11 @@ const [isLoading, setIsLoading] = useState(false)
checkIfAvatarExists();
}, [myName]);
const publishAvatar = async ()=> {
try {
const fee = await getFee('ARBITRARY')
if(+balance < +fee.fee) throw new Error(`Publishing an Avatar requires ${fee.fee}`)
await show({
message: "Would you like to publish an avatar?" ,
publishFee: fee.fee + ' QORT'
@@ -84,7 +86,13 @@ const [isLoading, setIsLoading] = useState(false)
setTempAvatar(`data:image/webp;base64,${avatarBase64}`)
handleClose()
} catch (error) {
if (error?.message) {
setOpenSnack(true)
setInfoSnack({
type: "error",
message: error?.message,
});
}
} finally {
setIsLoading(false);
}
@@ -113,7 +121,7 @@ const [isLoading, setIsLoading] = useState(false)
change avatar
</Typography>
</ButtonBase>
<PopoverComp avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
<PopoverComp myName={myName} avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
</>
);
}
@@ -141,7 +149,7 @@ const [isLoading, setIsLoading] = useState(false)
change avatar
</Typography>
</ButtonBase>
<PopoverComp avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
<PopoverComp myName={myName} avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
</>
);
}
@@ -159,13 +167,13 @@ const [isLoading, setIsLoading] = useState(false)
set avatar
</Typography>
</ButtonBase>
<PopoverComp avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
<PopoverComp myName={myName} avatarFile={avatarFile} setAvatarFile={setAvatarFile} id={id} open={open} anchorEl={anchorEl} handleClose={handleClose} publishAvatar={publishAvatar} isLoading={isLoading} />
</>
);
};
const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose, publishAvatar, isLoading}) => {
const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose, publishAvatar, isLoading, myName}) => {
return (
<Popover
id={id}
@@ -194,8 +202,21 @@ const PopoverComp = ({avatarFile, setAvatarFile, id, open, anchorEl, handleClose
</ImageUploader>
{avatarFile?.name}
<Spacer height="25px" />
<LoadingButton loading={isLoading} disabled={!avatarFile} onClick={publishAvatar} variant="contained">
{!myName && (
<Box sx={{
display: 'flex',
gap: '5px',
alignItems: 'center'
}}>
<ErrorIcon sx={{
color: 'white'
}} />
<Typography>A registered name is required to set an avatar</Typography>
</Box>
)}
<Spacer height="25px" />
<LoadingButton loading={isLoading} disabled={!avatarFile || !myName} onClick={publishAvatar} variant="contained">
Publish avatar
</LoadingButton>
</Box>

View File

@@ -44,6 +44,24 @@ const theme = createTheme({
color: '#b0b0b0', // Lighter text for body2, often used for secondary text
},
},
components: {
MuiOutlinedInput: {
styleOverrides: {
root: {
".MuiOutlinedInput-notchedOutline": {
borderColor: "white", // ⚪ Default outline color
},
},
},
},
MuiSelect: {
styleOverrides: {
icon: {
color: "white", // ✅ Caret (dropdown arrow) color
},
},
},
},
});
export default theme;