Inner Contradictions error display as snackbar
This commit is contained in:
@@ -1,3 +1,2 @@
|
|||||||
GEMINI_API_KEY="AIzaSyDke9H2NhiG6rBwxT0qrdYgnNoNZm_0j58"
|
GEMINI_API_KEY="AIzaSyDke9H2NhiG6rBwxT0qrdYgnNoNZm_0j58"
|
||||||
ENCRYPTION_KEY=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2
|
ENCRYPTION_KEY=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2
|
||||||
AUTH_PASSPHRASE="HonorableHumansPrivilegeIsToBeAllowedHere"
|
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { TextField, Button, Box, Typography, Snackbar, Alert } from '@mui/material';
|
import { TextField, Button, Box, Typography, Snackbar, Alert } from '@mui/material';
|
||||||
|
|
||||||
interface DesireFormProps {
|
interface DesireFormProps {
|
||||||
onSubmit: (desires: { wants: string[], accepts: string[], noGoes: string[], afraidToAsk: string }) => void;
|
onSubmit: (desires: { wants: string[], accepts: string[], noGoes: string[], afraidToAsk: string }) => void;
|
||||||
|
externalError?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DesireForm: React.FC<DesireFormProps> = ({ onSubmit }) => {
|
const DesireForm: React.FC<DesireFormProps> = ({ onSubmit, externalError }) => {
|
||||||
const [wants, setWants] = useState('');
|
const [wants, setWants] = useState('');
|
||||||
const [accepts, setAccepts] = useState('');
|
const [accepts, setAccepts] = useState('');
|
||||||
const [noGoes, setNoGoes] = useState('');
|
const [noGoes, setNoGoes] = useState('');
|
||||||
@@ -14,6 +15,15 @@ const DesireForm: React.FC<DesireFormProps> = ({ onSubmit }) => {
|
|||||||
const [alertMessage, setAlertMessage] = useState('');
|
const [alertMessage, setAlertMessage] = useState('');
|
||||||
const [alertSeverity, setAlertSeverity] = useState<'error' | 'warning' | 'info' | 'success'>('error');
|
const [alertSeverity, setAlertSeverity] = useState<'error' | 'warning' | 'info' | 'success'>('error');
|
||||||
|
|
||||||
|
// Effect to handle external errors
|
||||||
|
useEffect(() => {
|
||||||
|
if (externalError) {
|
||||||
|
setAlertMessage(externalError);
|
||||||
|
setAlertSeverity('error');
|
||||||
|
setAlertOpen(true);
|
||||||
|
}
|
||||||
|
}, [externalError]);
|
||||||
|
|
||||||
const handleCloseAlert = (event?: React.SyntheticEvent | Event, reason?: string) => {
|
const handleCloseAlert = (event?: React.SyntheticEvent | Event, reason?: string) => {
|
||||||
if (reason === 'clickaway') {
|
if (reason === 'clickaway') {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const PassphraseInput: React.FC<PassphraseInputProps> = ({ onSubmit, isLoading,
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box component="form" onSubmit={handleSubmit} sx={{ mt: 1 }}>
|
<Box component="form" onSubmit={handleSubmit} sx={{ mt: 1, display: 'flex', flexDirection: 'column' }}>
|
||||||
<TextField
|
<TextField
|
||||||
margin="normal"
|
margin="normal"
|
||||||
required
|
required
|
||||||
@@ -34,9 +34,8 @@ const PassphraseInput: React.FC<PassphraseInputProps> = ({ onSubmit, isLoading,
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
fullWidth
|
|
||||||
variant="contained"
|
variant="contained"
|
||||||
sx={{ mt: 3, mb: 2 }}
|
sx={{ mt: 3, mb: 2, textTransform: 'none', alignSelf: 'flex-start' }}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
>
|
>
|
||||||
{isLoading ? 'Submitting...' : 'Enter'}
|
{isLoading ? 'Submitting...' : 'Enter'}
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ const LoginPage: React.FC = () => {
|
|||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'flex-start',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography component="h1" variant="h5">
|
<Typography component="h1" variant="h5" sx={{ textAlign: 'left', width: '100%' }}>
|
||||||
Enter Passphrase
|
Enter Passphrase
|
||||||
</Typography>
|
</Typography>
|
||||||
{error && (
|
{error && (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import CopyLinkButton from '../components/CopyLinkButton'; // Import CopyLinkBut
|
|||||||
|
|
||||||
const SessionPage = () => {
|
const SessionPage = () => {
|
||||||
const { sessionId } = useParams<{ sessionId: string }>();
|
const { sessionId } = useParams<{ sessionId: string }>();
|
||||||
const [session, , sendMessage, clientId, ] = useSession(sessionId || '');
|
const [session, , sendMessage, clientId, wsError] = useSession(sessionId || '');
|
||||||
const [expectedResponses, setExpectedResponses] = useState(2);
|
const [expectedResponses, setExpectedResponses] = useState(2);
|
||||||
const [expectedResponsesError, setExpectedResponsesError] = useState(false);
|
const [expectedResponsesError, setExpectedResponsesError] = useState(false);
|
||||||
const [topic, setTopic] = useState('');
|
const [topic, setTopic] = useState('');
|
||||||
@@ -140,7 +140,7 @@ const SessionPage = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{session.state === SessionState.GATHERING && !hasSubmittedCurrentParticipant && (
|
{session.state === SessionState.GATHERING && !hasSubmittedCurrentParticipant && (
|
||||||
<DesireForm onSubmit={handleSubmitDesires} />
|
<DesireForm onSubmit={handleSubmitDesires} externalError={wsError} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{session.state === SessionState.GATHERING && hasSubmittedCurrentParticipant && (
|
{session.state === SessionState.GATHERING && hasSubmittedCurrentParticipant && (
|
||||||
|
|||||||
Reference in New Issue
Block a user