fix: remove OAuth login, fix JSX structure and sendPrompt/useMemo merge from ui-redo
This commit is contained in:
+14
-38
@@ -123,21 +123,7 @@ import {
|
|||||||
wholeNumber,
|
wholeNumber,
|
||||||
} from "./lib/metrics";
|
} from "./lib/metrics";
|
||||||
import { exportPayload, parseImport } from "./lib/storage";
|
import { exportPayload, parseImport } from "./lib/storage";
|
||||||
import type { DateFilter, EntryDraft, Filters, Flavour, ImportPreview, RedBullEntry } from "./types";
|
import type { CoachChat, CoachMessage, DateFilter, EntryDraft, Filters, Flavour, ImportPreview, RedBullEntry } from "./types";
|
||||||
|
|
||||||
type CoachMessage = {
|
|
||||||
role: "user" | "assistant" | "system";
|
|
||||||
content: string;
|
|
||||||
thinking?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CoachChat = {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
messages: CoachMessage[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type AppView = "overview" | "logbook" | "trends" | "settings";
|
type AppView = "overview" | "logbook" | "trends" | "settings";
|
||||||
type AuthMode = "login" | "signup";
|
type AuthMode = "login" | "signup";
|
||||||
@@ -972,18 +958,7 @@ function AuthView({
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-2 sm:grid-cols-2">
|
|
||||||
<button className="secondary-button justify-center" type="button" disabled={busy} onClick={() => onOAuth("github")}>
|
|
||||||
<Github size={17} aria-hidden="true" />
|
|
||||||
GitHub
|
|
||||||
</button>
|
|
||||||
<button className="secondary-button justify-center" type="button" disabled={busy} onClick={() => onOAuth("google")}>
|
|
||||||
<User size={17} aria-hidden="true" />
|
|
||||||
Google
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -1713,6 +1688,7 @@ function SpendForecastCard({
|
|||||||
return Math.max(1, Math.ceil(diffTime / (1000 * 60 * 60 * 24)));
|
return Math.max(1, Math.ceil(diffTime / (1000 * 60 * 60 * 24)));
|
||||||
}, [firstEntryDate, now]);
|
}, [firstEntryDate, now]);
|
||||||
|
|
||||||
|
async function unlockChatStorage(passphrase: string) {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError("");
|
setError("");
|
||||||
setChatStorageStatus("opening encrypted appwrite chats...");
|
setChatStorageStatus("opening encrypted appwrite chats...");
|
||||||
@@ -1762,13 +1738,12 @@ function SpendForecastCard({
|
|||||||
const assistantMessage: CoachMessage = { id: assistantId, role: "assistant", content: "", thinking: "", pending: true };
|
const assistantMessage: CoachMessage = { id: assistantId, role: "assistant", content: "", thinking: "", pending: true };
|
||||||
const conversation = [...currentChat.messages, userMessage];
|
const conversation = [...currentChat.messages, userMessage];
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
const draftChat: CoachChat = {
|
setChats((current) =>
|
||||||
...currentChat,
|
current.map((c) => (c.id === currentChat.id ? draftChat : c))
|
||||||
title: titleForChat(currentChat.title, trimmed),
|
);
|
||||||
messages: [...conversation, assistantMessage],
|
setChatStorageStatus("");
|
||||||
updatedAt: now,
|
setInput("");
|
||||||
};
|
}
|
||||||
}, [entries, activePeriodDays, now]);
|
|
||||||
|
|
||||||
const projectionData = useMemo<ForecastPoint[]>(() => {
|
const projectionData = useMemo<ForecastPoint[]>(() => {
|
||||||
return Array.from({ length: projectionDays }).map((_, index) => {
|
return Array.from({ length: projectionDays }).map((_, index) => {
|
||||||
@@ -1781,6 +1756,9 @@ function SpendForecastCard({
|
|||||||
if (userLimits.dailySpendLimit != null) {
|
if (userLimits.dailySpendLimit != null) {
|
||||||
dataPoint.limit = Number((day * userLimits.dailySpendLimit).toFixed(2));
|
dataPoint.limit = Number((day * userLimits.dailySpendLimit).toFixed(2));
|
||||||
}
|
}
|
||||||
|
return dataPoint;
|
||||||
|
});
|
||||||
|
}, [projectionDays, stats.avgDailySpend, userLimits?.dailySpendLimit]);
|
||||||
|
|
||||||
if (!stats.hasData) {
|
if (!stats.hasData) {
|
||||||
return (
|
return (
|
||||||
@@ -1862,7 +1840,6 @@ function SpendForecastCard({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
|
||||||
|
|
||||||
<div className="forecast-chart-wrap relative">
|
<div className="forecast-chart-wrap relative">
|
||||||
<ResponsiveContainer width="100%" height={260}>
|
<ResponsiveContainer width="100%" height={260}>
|
||||||
@@ -1912,7 +1889,6 @@ function SpendForecastCard({
|
|||||||
</AreaChart>
|
</AreaChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</AppCard>
|
</AppCard>
|
||||||
);
|
);
|
||||||
@@ -2474,8 +2450,7 @@ function EntryModal({
|
|||||||
sizePreset === "custom" && caffeineOverride.trim() ? Number(caffeineOverride) : undefined,
|
sizePreset === "custom" && caffeineOverride.trim() ? Number(caffeineOverride) : undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
function submit(event: FormEvent<HTMLFormElement>) {
|
const draftPreview = useMemo(() => {
|
||||||
event.preventDefault();
|
|
||||||
const numericCans = Math.max(0.25, Number(cans) || 1);
|
const numericCans = Math.max(0.25, Number(cans) || 1);
|
||||||
const numericPrice = Math.max(0, Number(pricePerCan) || 0);
|
const numericPrice = Math.max(0, Number(pricePerCan) || 0);
|
||||||
const finalFlavour = isOther ? customFlavour.trim() || "Other" : selectedFlavour;
|
const finalFlavour = isOther ? customFlavour.trim() || "Other" : selectedFlavour;
|
||||||
@@ -2485,7 +2460,7 @@ function EntryModal({
|
|||||||
? Math.max(0, Number(caffeineOverride) || 0)
|
? Math.max(0, Number(caffeineOverride) || 0)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
onSave({
|
return {
|
||||||
cans: numericCans,
|
cans: numericCans,
|
||||||
flavour: finalFlavour,
|
flavour: finalFlavour,
|
||||||
flavourAccent: isOther ? customAccent || accentForCustomFlavour(finalFlavour) : meta.accent,
|
flavourAccent: isOther ? customAccent || accentForCustomFlavour(finalFlavour) : meta.accent,
|
||||||
@@ -3065,4 +3040,5 @@ function actionLabel(value: string) {
|
|||||||
.replace(/-/g, " ");
|
.replace(/-/g, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
export default App;
|
export default App;
|
||||||
|
|||||||
Reference in New Issue
Block a user