Small fixes

This commit is contained in:
Reckless_Satoshi 2022-10-30 10:46:05 -07:00
parent d64adfc2bf
commit a5b63aed93
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
8 changed files with 83 additions and 46 deletions

View File

@ -632,20 +632,22 @@ class UserView(APIView):
context = {"bad_request": "Invalid serializer"}
return Response(context, status=status.HTTP_400_BAD_REQUEST)
# Deprecated
#
# If an existing user opens the main page by mistake, we do not want it to create a new nickname/profile for him
if request.user.is_authenticated:
context = {"nickname": request.user.username}
not_participant, _, order = Logics.validate_already_maker_or_taker(
request.user
)
# if request.user.is_authenticated:
# context = {"nickname": request.user.username}
# not_participant, _, order = Logics.validate_already_maker_or_taker(
# request.user
# )
# Does not allow this 'mistake' if an active order
if not not_participant:
context["active_order_id"] = order.id
context[
"bad_request"
] = f"You are already logged in as {request.user} and have an active order"
return Response(context, status.HTTP_400_BAD_REQUEST)
# # Does not allow this 'mistake' if an active order
# if not not_participant:
# context["active_order_id"] = order.id
# context[
# "bad_request"
# ] = f"You are already logged in as {request.user} and have an active order"
# return Response(context, status.HTTP_400_BAD_REQUEST)
# The new way. The token is never sent. Only its SHA256
token_sha256 = serializer.data.get("token_sha256")

View File

@ -101,7 +101,6 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
}
fetchBook();
fetchLimits();
fetchInfo();
return () => {
if (typeof window !== undefined) {
window.removeEventListener('resize', onResize);
@ -152,6 +151,10 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
});
};
useEffect(() => {
fetchInfo();
}, [open.stats, open.coordinator]);
const fetchRobot = function () {
const requestBody = {
token_sha256: sha256(robot.token),
@ -194,8 +197,6 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
}
}, []);
console.log(page);
return (
<Router basename={basename}>
{/* load robot avatar image, set avatarLoaded: true */}

View File

@ -53,7 +53,7 @@ const NavBar = ({
const smallBar = width < 50;
const tabSx = smallBar
? { position: 'relative', bottom: nickname ? '0.8em' : '0em', minWidth: '1em' }
? { position: 'relative', bottom: nickname ? '1em' : '0em', minWidth: '1em' }
: { position: 'relative', bottom: '1em', minWidth: '2em' };
const pagesPosition = {
robot: 1,
@ -103,12 +103,13 @@ const NavBar = ({
<Tab
sx={{ ...tabSx, minWidth: '2.5em', width: '2.5em', maxWidth: '4em' }}
value='none'
disabled={nickname === null}
onClick={() => setOpen({ ...closeAll, profile: !open.profile })}
icon={
nickname ? (
<RobotAvatar
style={{ width: '2.3em', height: '2.3em' }}
avatarClass='phoneFlippedSmallAvatar'
style={{ width: '2.3em', height: '2.3em', position: 'relative', top: '0.2em' }}
avatarClass={theme.palette.mode === 'dark' ? 'navBarAvatarDark' : 'navBarAvatar'}
nickname={nickname}
/>
) : (
@ -160,7 +161,6 @@ const NavBar = ({
label={smallBar ? undefined : t('More')}
value='none'
onClick={(e) => {
console.log(e);
open.more ? null : setOpen({ ...open, more: true });
}}
icon={

View File

@ -22,7 +22,11 @@ const SettingsPage = ({ settings, setSettings, windowSize }: SettingsPageProps):
>
<Grid container>
<Grid item>
<SettingsForm settings={settings} setSettings={setSettings} />
<SettingsForm
settings={settings}
setSettings={setSettings}
networt={window.NativeRobosats}
/>
</Grid>
</Grid>
</Paper>

View File

@ -42,7 +42,10 @@ class UserGenPage extends Component {
// Displays the existing one
if (this.props.robot.nickname != null) {
this.setState({ inputToken: this.props.robot.token });
} else if (this.props.robot.token) {
} else if (
this.props.robot.token ||
(window.NativeRobosats && systemClient.getCookie('robot_token'))
) {
this.setState({ inputToken: this.props.robot.token });
this.getGeneratedUser(this.props.robot.token);
} else {

View File

@ -4,7 +4,6 @@ import { useTheme } from '@mui/material/styles';
import { Link as LinkRouter } from 'react-router-dom';
import {
Avatar,
Badge,
Button,
CircularProgress,
@ -102,10 +101,10 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
.post('/api/reward/', {
invoice: rewardInvoice,
})
.then((data) => {
setBadInvoice(data.bad_invoice);
.then((data: any) => {
setBadInvoice(data.bad_invoice ?? '');
setShowRewardsSpinner(false);
setWithdrawn(!!data.successful_withdrawal);
setWithdrawn(data.successful_withdrawal);
setOpenClaimRewards(!data.successful_withdrawal);
setRobot({ ...robot, earnedRewards: data.successful_withdrawal ? 0 : robot.earnedRewards });
});

View File

@ -29,9 +29,15 @@ interface SettingsFormProps {
dense?: boolean;
settings: Settings;
setSettings: (state: Settings) => void;
network?: boolean;
}
const SettingsForm = ({ dense = false, settings, setSettings }: SettingsFormProps): JSX.Element => {
const SettingsForm = ({
dense = false,
settings,
setSettings,
network = false,
}: SettingsFormProps): JSX.Element => {
const theme = useTheme();
const { t } = useTranslation();
const fontSizes = [
@ -123,24 +129,27 @@ const SettingsForm = ({ dense = false, settings, setSettings }: SettingsFormProp
track={false}
/>
</ListItem>
<ListItem>
<ListItemIcon>
<Link />
</ListItemIcon>
<ToggleButtonGroup
exclusive={true}
value={settings.network}
onChange={(e, value) => setSettings({ ...settings, network: value })}
>
<ToggleButton value='mainnet' color='primary'>
{t('Mainnet')}
</ToggleButton>
<ToggleButton value='testnet' color='secondary'>
{t('Testnet')}
</ToggleButton>
</ToggleButtonGroup>
</ListItem>
{network ? (
<ListItem>
<ListItemIcon>
<Link />
</ListItemIcon>
<ToggleButtonGroup
exclusive={true}
value={settings.network}
onChange={(e, value) => setSettings({ ...settings, network: value })}
>
<ToggleButton value='mainnet' color='primary'>
{t('Mainnet')}
</ToggleButton>
<ToggleButton value='testnet' color='secondary'>
{t('Testnet')}
</ToggleButton>
</ToggleButtonGroup>
</ListItem>
) : (
<></>
)}
</List>
</Grid>
</Grid>

View File

@ -117,14 +117,14 @@ input[type='number'] {
filter: drop-shadow(0.5px 0.5px 0.5px #000000);
}
.phoneFlippedSmallAvatar img {
.navBarAvatar img {
transform: scaleX(-1);
border: 1.3px solid #1976d2;
-webkit-filter: grayscale(100%);
filter: grayscale(100%) brightness(150%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000);
}
.phoneFlippedSmallAvatar:after {
.navBarAvatar:after {
content: '';
position: absolute;
top: 0;
@ -136,6 +136,25 @@ input[type='number'] {
box-shadow: inset 0px 0px 35px rgb(255, 255, 255);
}
.navBarAvatarDark img {
transform: scaleX(-1);
border: 1.3px solid #90caf9;
-webkit-filter: grayscale(100%);
filter: grayscale(100%) brightness(100%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000);
}
.navBarAvatarDark:after {
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
border-radius: 50%;
border: 2.4px solid #90caf9;
box-shadow: inset 0px 0px 35px rgb(255, 255, 255);
}
.MuiButton-textInherit {
color: '#111111';
}