Revert education feature from main
This commit is contained in:
+2
-567
@@ -162,23 +162,6 @@ type AdminRescueWorkspace = {
|
||||
memberCount: number;
|
||||
};
|
||||
|
||||
type DailyEducationQuestion = {
|
||||
id: string;
|
||||
prompt: string;
|
||||
options: string[];
|
||||
correctAnswerIndex: number;
|
||||
explanation: string | null;
|
||||
};
|
||||
|
||||
type DailyEducation = {
|
||||
id: string;
|
||||
publishDate: string;
|
||||
fact: string;
|
||||
quizQuestions: DailyEducationQuestion[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
type IntegrationTokenSummary = {
|
||||
id: string;
|
||||
userId: string;
|
||||
@@ -311,18 +294,6 @@ type BillingNotice = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
type DailyEducationQuestionFormState = {
|
||||
prompt: string;
|
||||
options: [string, string, string, string];
|
||||
correctAnswerIndex: number;
|
||||
explanation: string;
|
||||
};
|
||||
|
||||
type DailyEducationFormState = {
|
||||
publishDate: string;
|
||||
fact: string;
|
||||
};
|
||||
|
||||
type BulkWeightRowState = {
|
||||
weightGrams: string;
|
||||
};
|
||||
@@ -690,18 +661,6 @@ const emptyIntegrationTokenForm: IntegrationTokenFormState = {
|
||||
expiresInDays: '',
|
||||
};
|
||||
|
||||
const emptyDailyEducationQuestion = (): DailyEducationQuestionFormState => ({
|
||||
prompt: '',
|
||||
options: ['', '', '', ''],
|
||||
correctAnswerIndex: 0,
|
||||
explanation: '',
|
||||
});
|
||||
|
||||
const emptyDailyEducationForm = (): DailyEducationFormState => ({
|
||||
publishDate: new Date().toISOString().slice(0, 10),
|
||||
fact: '',
|
||||
});
|
||||
|
||||
const defaultAuthProviders: AuthProvider[] = [
|
||||
{ providerKey: 'google', displayName: 'Google', enabled: false },
|
||||
{ providerKey: 'microsoft', displayName: 'Microsoft', enabled: false },
|
||||
@@ -1471,20 +1430,6 @@ function App() {
|
||||
const [integrationTokens, setIntegrationTokens] = useState<IntegrationTokenSummary[]>([]);
|
||||
const [adminSummary, setAdminSummary] = useState<AdminSummary | null>(null);
|
||||
const [adminRescueWorkspaces, setAdminRescueWorkspaces] = useState<AdminRescueWorkspace[]>([]);
|
||||
const [adminDailyEducation, setAdminDailyEducation] = useState<DailyEducation[]>([]);
|
||||
const [adminEducationQuestions, setAdminEducationQuestions] = useState<DailyEducationQuestion[]>([]);
|
||||
const [dailyEducationForm, setDailyEducationForm] = useState<DailyEducationFormState>(emptyDailyEducationForm);
|
||||
const [educationQuestionForm, setEducationQuestionForm] = useState<DailyEducationQuestionFormState>(emptyDailyEducationQuestion);
|
||||
const [editingEducationQuestionId, setEditingEducationQuestionId] = useState('');
|
||||
const [savingDailyEducation, setSavingDailyEducation] = useState(false);
|
||||
const [savingEducationQuestion, setSavingEducationQuestion] = useState(false);
|
||||
const [deletingDailyEducationId, setDeletingDailyEducationId] = useState('');
|
||||
const [deletingEducationQuestionId, setDeletingEducationQuestionId] = useState('');
|
||||
const [todayEducation, setTodayEducation] = useState<DailyEducation | null>(null);
|
||||
const [educationOptOut, setEducationOptOut] = useState(false);
|
||||
const [savingEducationPreference, setSavingEducationPreference] = useState(false);
|
||||
const [educationAnswers, setEducationAnswers] = useState<Record<number, number>>({});
|
||||
const [dailyEducationOpen, setDailyEducationOpen] = useState(false);
|
||||
const [birds, setBirds] = useState<Bird[]>([]);
|
||||
const [memorializedBirds, setMemorializedBirds] = useState<Bird[]>([]);
|
||||
const [selectedBirdId, setSelectedBirdId] = useState<string>('');
|
||||
@@ -2027,15 +1972,6 @@ function App() {
|
||||
setIntegrationTokens([]);
|
||||
setAdminSummary(null);
|
||||
setAdminRescueWorkspaces([]);
|
||||
setAdminDailyEducation([]);
|
||||
setAdminEducationQuestions([]);
|
||||
setDailyEducationForm(emptyDailyEducationForm());
|
||||
setEducationQuestionForm(emptyDailyEducationQuestion());
|
||||
setEditingEducationQuestionId('');
|
||||
setTodayEducation(null);
|
||||
setEducationOptOut(false);
|
||||
setEducationAnswers({});
|
||||
setDailyEducationOpen(false);
|
||||
setBirds([]);
|
||||
setMemorializedBirds([]);
|
||||
setWeights([]);
|
||||
@@ -2274,27 +2210,20 @@ function App() {
|
||||
|
||||
const loadAdminDashboard = async () => {
|
||||
try {
|
||||
const [summaryResponse, rescuesResponse, educationResponse, educationQuestionsResponse] = await Promise.all([
|
||||
const [summaryResponse, rescuesResponse] = await Promise.all([
|
||||
apiFetch('/admin/summary', authToken),
|
||||
apiFetch('/admin/rescue-workspaces', authToken),
|
||||
apiFetch('/admin/daily-education', authToken),
|
||||
apiFetch('/admin/education-questions', authToken),
|
||||
]);
|
||||
|
||||
if (!summaryResponse.ok || !rescuesResponse.ok || !educationResponse.ok || !educationQuestionsResponse.ok) {
|
||||
if (!summaryResponse.ok || !rescuesResponse.ok) {
|
||||
throw new Error('Unable to load admin dashboard.');
|
||||
}
|
||||
|
||||
const summaryData = (await readJsonSafely<{ summary?: AdminSummary }>(summaryResponse)) ?? {};
|
||||
const rescuesData = (await readJsonSafely<{ rescueWorkspaces?: AdminRescueWorkspace[] }>(rescuesResponse)) ?? {};
|
||||
const educationData = (await readJsonSafely<{ education?: DailyEducation[] }>(educationResponse)) ?? {};
|
||||
const educationQuestionsData =
|
||||
(await readJsonSafely<{ questions?: DailyEducationQuestion[] }>(educationQuestionsResponse)) ?? {};
|
||||
|
||||
setAdminSummary(summaryData.summary ?? null);
|
||||
setAdminRescueWorkspaces(rescuesData.rescueWorkspaces ?? []);
|
||||
setAdminDailyEducation(educationData.education ?? []);
|
||||
setAdminEducationQuestions(educationQuestionsData.questions ?? []);
|
||||
} catch (adminError) {
|
||||
setError(adminError instanceof Error ? adminError.message : 'Unable to load admin dashboard.');
|
||||
}
|
||||
@@ -2303,34 +2232,6 @@ function App() {
|
||||
void loadAdminDashboard();
|
||||
}, [activePage, authSession?.isAdmin, authToken]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!authToken || !authSession) {
|
||||
return;
|
||||
}
|
||||
|
||||
const loadTodayEducation = async () => {
|
||||
try {
|
||||
const response = await apiFetch('/education/today', authToken);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(await readErrorMessage(response, 'Unable to load daily education.'));
|
||||
}
|
||||
|
||||
const data =
|
||||
(await readJsonSafely<{ education?: DailyEducation | null; educationOptOut?: boolean }>(response)) ?? {};
|
||||
|
||||
setEducationOptOut(Boolean(data.educationOptOut));
|
||||
setTodayEducation(data.education ?? null);
|
||||
setEducationAnswers({});
|
||||
setDailyEducationOpen(false);
|
||||
} catch (educationError) {
|
||||
setError(educationError instanceof Error ? educationError.message : 'Unable to load daily education.');
|
||||
}
|
||||
};
|
||||
|
||||
void loadTodayEducation();
|
||||
}, [authSession, authToken]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedBird?.id) {
|
||||
setWeights([]);
|
||||
@@ -2749,221 +2650,6 @@ function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const loadDailyEducationIntoForm = (education: DailyEducation) => {
|
||||
setDailyEducationForm({
|
||||
publishDate: education.publishDate,
|
||||
fact: education.fact,
|
||||
});
|
||||
};
|
||||
|
||||
const loadEducationQuestionIntoForm = (question: DailyEducationQuestion) => {
|
||||
setEditingEducationQuestionId(question.id);
|
||||
setEducationQuestionForm({
|
||||
prompt: question.prompt,
|
||||
options: [
|
||||
question.options[0] ?? '',
|
||||
question.options[1] ?? '',
|
||||
question.options[2] ?? '',
|
||||
question.options[3] ?? '',
|
||||
],
|
||||
correctAnswerIndex: question.correctAnswerIndex,
|
||||
explanation: question.explanation ?? '',
|
||||
});
|
||||
};
|
||||
|
||||
const resetEducationQuestionForm = () => {
|
||||
setEditingEducationQuestionId('');
|
||||
setEducationQuestionForm(emptyDailyEducationQuestion());
|
||||
};
|
||||
|
||||
const handleDailyEducationSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
|
||||
if (!authToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
setError('');
|
||||
setSavingDailyEducation(true);
|
||||
|
||||
try {
|
||||
const response = await apiFetch('/admin/daily-education', authToken, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
publishDate: dailyEducationForm.publishDate,
|
||||
fact: dailyEducationForm.fact.trim(),
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(await readErrorMessage(response, 'Unable to save daily education.'));
|
||||
}
|
||||
|
||||
const data = (await readJsonSafely<{ education?: DailyEducation }>(response)) ?? {};
|
||||
|
||||
if (!data.education) {
|
||||
throw new Error('Unable to save daily education.');
|
||||
}
|
||||
|
||||
setAdminDailyEducation((current) =>
|
||||
[data.education!, ...current.filter((education) => education.id !== data.education!.id && education.publishDate !== data.education!.publishDate)]
|
||||
.sort((left, right) => right.publishDate.localeCompare(left.publishDate)),
|
||||
);
|
||||
if (data.education.publishDate === new Date().toISOString().slice(0, 10) && !educationOptOut) {
|
||||
const todayResponse = await apiFetch('/education/today', authToken);
|
||||
const todayData = todayResponse.ok
|
||||
? await readJsonSafely<{ education?: DailyEducation | null }>(todayResponse)
|
||||
: null;
|
||||
setTodayEducation(todayData?.education ?? null);
|
||||
setEducationAnswers({});
|
||||
}
|
||||
setDailyEducationForm(emptyDailyEducationForm());
|
||||
} catch (educationError) {
|
||||
setError(educationError instanceof Error ? educationError.message : 'Unable to save daily education.');
|
||||
} finally {
|
||||
setSavingDailyEducation(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEducationQuestionSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
|
||||
if (!authToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
setError('');
|
||||
setSavingEducationQuestion(true);
|
||||
|
||||
try {
|
||||
const response = await apiFetch(
|
||||
editingEducationQuestionId ? `/admin/education-questions/${editingEducationQuestionId}` : '/admin/education-questions',
|
||||
authToken,
|
||||
{
|
||||
method: editingEducationQuestionId ? 'PUT' : 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
prompt: educationQuestionForm.prompt.trim(),
|
||||
options: educationQuestionForm.options.map((option) => option.trim()),
|
||||
correctAnswerIndex: educationQuestionForm.correctAnswerIndex,
|
||||
explanation: educationQuestionForm.explanation.trim(),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(await readErrorMessage(response, 'Unable to save education question.'));
|
||||
}
|
||||
|
||||
const data = (await readJsonSafely<{ question?: DailyEducationQuestion }>(response)) ?? {};
|
||||
|
||||
if (!data.question) {
|
||||
throw new Error('Unable to save education question.');
|
||||
}
|
||||
|
||||
setAdminEducationQuestions((current) => [
|
||||
data.question!,
|
||||
...current.filter((question) => question.id !== data.question!.id),
|
||||
]);
|
||||
resetEducationQuestionForm();
|
||||
} catch (educationError) {
|
||||
setError(educationError instanceof Error ? educationError.message : 'Unable to save education question.');
|
||||
} finally {
|
||||
setSavingEducationQuestion(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteEducationQuestion = async (questionId: string) => {
|
||||
if (!authToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
setError('');
|
||||
setDeletingEducationQuestionId(questionId);
|
||||
|
||||
try {
|
||||
const response = await apiFetch(`/admin/education-questions/${questionId}`, authToken, { method: 'DELETE' });
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(await readErrorMessage(response, 'Unable to delete education question.'));
|
||||
}
|
||||
|
||||
setAdminEducationQuestions((current) => current.filter((question) => question.id !== questionId));
|
||||
if (editingEducationQuestionId === questionId) {
|
||||
resetEducationQuestionForm();
|
||||
}
|
||||
} catch (educationError) {
|
||||
setError(educationError instanceof Error ? educationError.message : 'Unable to delete education question.');
|
||||
} finally {
|
||||
setDeletingEducationQuestionId('');
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteDailyEducation = async (educationId: string) => {
|
||||
if (!authToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
setError('');
|
||||
setDeletingDailyEducationId(educationId);
|
||||
|
||||
try {
|
||||
const response = await apiFetch(`/admin/daily-education/${educationId}`, authToken, { method: 'DELETE' });
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(await readErrorMessage(response, 'Unable to delete daily education.'));
|
||||
}
|
||||
|
||||
setAdminDailyEducation((current) => current.filter((education) => education.id !== educationId));
|
||||
if (todayEducation?.id === educationId) {
|
||||
setTodayEducation(null);
|
||||
}
|
||||
} catch (educationError) {
|
||||
setError(educationError instanceof Error ? educationError.message : 'Unable to delete daily education.');
|
||||
} finally {
|
||||
setDeletingDailyEducationId('');
|
||||
}
|
||||
};
|
||||
|
||||
const handleEducationPreferenceChange = async (nextEducationOptOut: boolean) => {
|
||||
if (!authToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
setError('');
|
||||
setSavingEducationPreference(true);
|
||||
|
||||
try {
|
||||
const response = await apiFetch('/education/preferences', authToken, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ educationOptOut: nextEducationOptOut }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(await readErrorMessage(response, 'Unable to save education preference.'));
|
||||
}
|
||||
|
||||
setEducationOptOut(nextEducationOptOut);
|
||||
if (nextEducationOptOut) {
|
||||
setTodayEducation(null);
|
||||
setDailyEducationOpen(false);
|
||||
} else {
|
||||
const todayResponse = await apiFetch('/education/today', authToken);
|
||||
const data = todayResponse.ok
|
||||
? await readJsonSafely<{ education?: DailyEducation | null }>(todayResponse)
|
||||
: null;
|
||||
setTodayEducation(data?.education ?? null);
|
||||
}
|
||||
setEducationAnswers({});
|
||||
} catch (educationError) {
|
||||
setError(educationError instanceof Error ? educationError.message : 'Unable to save education preference.');
|
||||
} finally {
|
||||
setSavingEducationPreference(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateWorkspace = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -4826,74 +4512,6 @@ function App() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{todayEducation ? (
|
||||
<article className={dailyEducationOpen ? 'panel daily-education-panel open' : 'panel daily-education-panel condensed'}>
|
||||
<div className="panel-header">
|
||||
<div>
|
||||
<p className="eyebrow">Fid fact of the day</p>
|
||||
<h2>{dailyEducationOpen ? formatDate(todayEducation.publishDate) : 'Daily learning'}</h2>
|
||||
</div>
|
||||
<button className="secondary-button" onClick={() => setDailyEducationOpen((current) => !current)} type="button">
|
||||
{dailyEducationOpen ? 'Close' : 'Open'}
|
||||
</button>
|
||||
</div>
|
||||
{dailyEducationOpen ? (
|
||||
<>
|
||||
<p className="daily-fact">{todayEducation.fact}</p>
|
||||
<section className="daily-quiz" aria-label="Daily education quiz">
|
||||
{todayEducation.quizQuestions.map((question, questionIndex) => {
|
||||
const selectedAnswer = educationAnswers[questionIndex];
|
||||
const hasAnswer = selectedAnswer !== undefined;
|
||||
|
||||
return (
|
||||
<fieldset key={`${todayEducation.id}-${question.id}`} className="quiz-question">
|
||||
<legend>{question.prompt}</legend>
|
||||
<div className="quiz-options">
|
||||
{question.options.map((option, optionIndex) => (
|
||||
<label
|
||||
key={`${question.id}-${optionIndex}`}
|
||||
className={
|
||||
hasAnswer && optionIndex === question.correctAnswerIndex
|
||||
? 'quiz-option correct'
|
||||
: hasAnswer && optionIndex === selectedAnswer
|
||||
? 'quiz-option incorrect'
|
||||
: 'quiz-option'
|
||||
}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name={`daily-question-${question.id}`}
|
||||
checked={selectedAnswer === optionIndex}
|
||||
onChange={() =>
|
||||
setEducationAnswers((current) => ({
|
||||
...current,
|
||||
[questionIndex]: optionIndex,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<span>{option}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
{hasAnswer ? (
|
||||
<p className={selectedAnswer === question.correctAnswerIndex ? 'quiz-feedback correct' : 'quiz-feedback'}>
|
||||
{selectedAnswer === question.correctAnswerIndex ? 'Correct.' : 'Correct answer shown.'}{' '}
|
||||
{question.explanation}
|
||||
</p>
|
||||
) : null}
|
||||
</fieldset>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
</>
|
||||
) : (
|
||||
<p className="muted daily-education-teaser">
|
||||
Open today's fact and {todayEducation.quizQuestions.length || 'the'} quiz questions.
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
) : null}
|
||||
|
||||
<section className="forms-grid">
|
||||
<article className="panel form-panel pulse-panel">
|
||||
<div className="panel-header">
|
||||
@@ -5044,168 +4662,6 @@ function App() {
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article className="panel admin-education-panel">
|
||||
<div className="panel-header">
|
||||
<div>
|
||||
<p className="eyebrow">Education</p>
|
||||
<h2>Fid facts</h2>
|
||||
</div>
|
||||
<button className="secondary-button" onClick={() => setDailyEducationForm(emptyDailyEducationForm())} type="button">
|
||||
New date
|
||||
</button>
|
||||
</div>
|
||||
<form className="form-panel" onSubmit={handleDailyEducationSubmit}>
|
||||
<div className="education-admin-basics">
|
||||
<label>
|
||||
Publish date
|
||||
<input
|
||||
type="date"
|
||||
value={dailyEducationForm.publishDate}
|
||||
onChange={(event) => setDailyEducationForm({ ...dailyEducationForm, publishDate: event.target.value })}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Fid fact
|
||||
<textarea
|
||||
value={dailyEducationForm.fact}
|
||||
onChange={(event) => setDailyEducationForm({ ...dailyEducationForm, fact: event.target.value })}
|
||||
rows={3}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<button className="primary-button" type="submit" disabled={savingDailyEducation}>
|
||||
{savingDailyEducation ? 'Saving...' : 'Save fact'}
|
||||
</button>
|
||||
</form>
|
||||
<div className="recent-list education-admin-list">
|
||||
{adminDailyEducation.length ? (
|
||||
adminDailyEducation.map((education) => (
|
||||
<article key={education.id} className="vet-visit-card">
|
||||
<strong>{formatDate(education.publishDate)}</strong>
|
||||
<span>{education.fact}</span>
|
||||
<div className="button-row">
|
||||
<button className="secondary-button" type="button" onClick={() => loadDailyEducationIntoForm(education)}>
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
className="secondary-button"
|
||||
type="button"
|
||||
onClick={() => handleDeleteDailyEducation(education.id)}
|
||||
disabled={deletingDailyEducationId === education.id}
|
||||
>
|
||||
{deletingDailyEducationId === education.id ? 'Deleting...' : 'Delete'}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))
|
||||
) : (
|
||||
<article className="vet-visit-card empty-card">
|
||||
<strong>No scheduled facts yet</strong>
|
||||
<small>Add a dated Fid fact for the overview page.</small>
|
||||
</article>
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article className="panel admin-education-panel">
|
||||
<div className="panel-header">
|
||||
<div>
|
||||
<p className="eyebrow">Education</p>
|
||||
<h2>Quiz question bank</h2>
|
||||
</div>
|
||||
<button className="secondary-button" onClick={resetEducationQuestionForm} type="button">
|
||||
New question
|
||||
</button>
|
||||
</div>
|
||||
<p className="muted">Each day the quiz uses a stable random selection of four saved questions.</p>
|
||||
<form className="form-panel" onSubmit={handleEducationQuestionSubmit}>
|
||||
<fieldset className="settings-nested-card quiz-editor-question">
|
||||
<legend>{editingEducationQuestionId ? 'Edit question' : 'Add question'}</legend>
|
||||
<label>
|
||||
Prompt
|
||||
<input
|
||||
value={educationQuestionForm.prompt}
|
||||
onChange={(event) => setEducationQuestionForm({ ...educationQuestionForm, prompt: event.target.value })}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<div className="quiz-editor-options">
|
||||
{educationQuestionForm.options.map((option, optionIndex) => (
|
||||
<label key={`bank-option-${optionIndex}`}>
|
||||
Option {optionIndex + 1}
|
||||
<input
|
||||
value={option}
|
||||
onChange={(event) => {
|
||||
const options = [...educationQuestionForm.options] as DailyEducationQuestionFormState['options'];
|
||||
options[optionIndex] = event.target.value;
|
||||
setEducationQuestionForm({ ...educationQuestionForm, options });
|
||||
}}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<label>
|
||||
Correct option
|
||||
<select
|
||||
value={educationQuestionForm.correctAnswerIndex}
|
||||
onChange={(event) =>
|
||||
setEducationQuestionForm({ ...educationQuestionForm, correctAnswerIndex: Number(event.target.value) })
|
||||
}
|
||||
>
|
||||
{educationQuestionForm.options.map((_, optionIndex) => (
|
||||
<option key={`bank-correct-${optionIndex}`} value={optionIndex}>
|
||||
Option {optionIndex + 1}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Explanation
|
||||
<textarea
|
||||
value={educationQuestionForm.explanation}
|
||||
onChange={(event) => setEducationQuestionForm({ ...educationQuestionForm, explanation: event.target.value })}
|
||||
rows={2}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<button className="primary-button" type="submit" disabled={savingEducationQuestion}>
|
||||
{savingEducationQuestion ? 'Saving...' : editingEducationQuestionId ? 'Save question changes' : 'Add question'}
|
||||
</button>
|
||||
</form>
|
||||
<div className="recent-list education-admin-list">
|
||||
{adminEducationQuestions.length ? (
|
||||
adminEducationQuestions.map((question) => (
|
||||
<article key={question.id} className="vet-visit-card">
|
||||
<strong>{question.prompt}</strong>
|
||||
<span>Answer: {question.options[question.correctAnswerIndex]}</span>
|
||||
<small>{question.options.length} options</small>
|
||||
<div className="button-row">
|
||||
<button className="secondary-button" type="button" onClick={() => loadEducationQuestionIntoForm(question)}>
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
className="secondary-button"
|
||||
type="button"
|
||||
onClick={() => handleDeleteEducationQuestion(question.id)}
|
||||
disabled={deletingEducationQuestionId === question.id}
|
||||
>
|
||||
{deletingEducationQuestionId === question.id ? 'Deleting...' : 'Delete'}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))
|
||||
) : (
|
||||
<article className="vet-visit-card empty-card">
|
||||
<strong>No quiz questions yet</strong>
|
||||
<small>Add at least four questions before the daily quiz can use a full set.</small>
|
||||
</article>
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
@@ -6701,27 +6157,6 @@ function App() {
|
||||
|
||||
</div>
|
||||
<div className="settings-column settings-column-right">
|
||||
<article className="panel form-panel">
|
||||
<div className="panel-header">
|
||||
<div>
|
||||
<p className="eyebrow">Education</p>
|
||||
<h2>Daily learning</h2>
|
||||
</div>
|
||||
</div>
|
||||
<label className="toggle-card">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={!educationOptOut}
|
||||
onChange={(event) => handleEducationPreferenceChange(!event.target.checked)}
|
||||
disabled={savingEducationPreference}
|
||||
/>
|
||||
<span>
|
||||
<strong>Show daily education</strong>
|
||||
<small>Display the Fid fact of the day and four-question quiz on Overview.</small>
|
||||
</span>
|
||||
</label>
|
||||
</article>
|
||||
|
||||
<article className="panel form-panel settings-card-collaborators">
|
||||
<div className="panel-header">
|
||||
<div>
|
||||
|
||||
@@ -745,123 +745,6 @@ textarea {
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.daily-education-panel,
|
||||
.daily-quiz,
|
||||
.quiz-options,
|
||||
.education-question-editor {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.daily-education-panel.condensed {
|
||||
gap: 0.35rem;
|
||||
padding-block: 1rem;
|
||||
}
|
||||
|
||||
.daily-education-panel.condensed .panel-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.daily-education-teaser {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.daily-fact {
|
||||
margin: 0;
|
||||
padding: 1rem;
|
||||
border-left: 4px solid var(--accent-gold);
|
||||
border-radius: 0 8px 8px 0;
|
||||
background: rgba(255, 254, 250, 0.7);
|
||||
font-size: 1.08rem;
|
||||
}
|
||||
|
||||
.daily-quiz {
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
|
||||
}
|
||||
|
||||
.quiz-question,
|
||||
.quiz-editor-question {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
border: 1px solid var(--button-border);
|
||||
}
|
||||
|
||||
.quiz-question {
|
||||
display: grid;
|
||||
gap: 0.85rem;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 254, 250, 0.64);
|
||||
}
|
||||
|
||||
.quiz-question legend,
|
||||
.quiz-editor-question legend {
|
||||
padding: 0 0.35rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.quiz-option {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: start;
|
||||
gap: 0.65rem;
|
||||
min-width: 0;
|
||||
padding: 0.7rem;
|
||||
border: 1px solid rgba(39, 105, 179, 0.12);
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.58);
|
||||
}
|
||||
|
||||
.quiz-option.correct {
|
||||
border-color: rgba(35, 138, 90, 0.42);
|
||||
background: rgba(223, 247, 229, 0.82);
|
||||
}
|
||||
|
||||
.quiz-option.incorrect {
|
||||
border-color: rgba(203, 58, 53, 0.36);
|
||||
background: rgba(255, 236, 232, 0.82);
|
||||
}
|
||||
|
||||
.quiz-option input {
|
||||
width: auto;
|
||||
margin: 0.25rem 0 0;
|
||||
}
|
||||
|
||||
.quiz-feedback {
|
||||
margin: 0;
|
||||
color: var(--accent-red);
|
||||
}
|
||||
|
||||
.quiz-feedback.correct {
|
||||
color: var(--accent-green);
|
||||
}
|
||||
|
||||
.admin-education-panel,
|
||||
.education-admin-basics,
|
||||
.quiz-editor-question,
|
||||
.education-admin-list {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.education-admin-basics {
|
||||
grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.quiz-editor-question {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.quiz-editor-options {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.education-admin-list span {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.button-row {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
@@ -1966,11 +1849,6 @@ label {
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.education-admin-basics,
|
||||
.quiz-editor-options {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.app-shell,
|
||||
.auth-panel,
|
||||
.hero-card,
|
||||
|
||||
Reference in New Issue
Block a user