Spaces:
Sleeping
Sleeping
Vanshik Waghela commited on
Commit Β·
26e3332
1
Parent(s): 408463e
fix: demo-data typecheck errors, remove unused EscalateSocialCard props
Browse files
apps/web/src/app/[locale]/missions/[id]/page.tsx
CHANGED
|
@@ -795,8 +795,6 @@ export default function MissionRoom({
|
|
| 795 |
: undefined
|
| 796 |
}
|
| 797 |
authorityUrl={null}
|
| 798 |
-
onEscalate={() => {}}
|
| 799 |
-
loading={false}
|
| 800 |
/>
|
| 801 |
);
|
| 802 |
})}
|
|
|
|
| 795 |
: undefined
|
| 796 |
}
|
| 797 |
authorityUrl={null}
|
|
|
|
|
|
|
| 798 |
/>
|
| 799 |
);
|
| 800 |
})}
|
apps/web/src/components/mission/ActionConsole.tsx
CHANGED
|
@@ -528,8 +528,6 @@ function StepActionCard({
|
|
| 528 |
missionTitle={missionTitle}
|
| 529 |
missionBodyText={missionBodyText}
|
| 530 |
authorityUrl={(step as typeof step & { authorityUrl?: string }).authorityUrl}
|
| 531 |
-
onEscalate={() => state.preview && onConfirmExternal(state.preview.action.id)}
|
| 532 |
-
loading={state.loading}
|
| 533 |
/>
|
| 534 |
)}
|
| 535 |
</div>
|
|
@@ -628,8 +626,6 @@ interface EscalateSocialCardProps {
|
|
| 628 |
missionTitle?: string;
|
| 629 |
missionBodyText?: string;
|
| 630 |
authorityUrl?: string | null;
|
| 631 |
-
onEscalate: () => void;
|
| 632 |
-
loading: boolean;
|
| 633 |
}
|
| 634 |
|
| 635 |
export function EscalateSocialCard({
|
|
@@ -638,8 +634,6 @@ export function EscalateSocialCard({
|
|
| 638 |
missionTitle,
|
| 639 |
missionBodyText,
|
| 640 |
authorityUrl,
|
| 641 |
-
onEscalate,
|
| 642 |
-
loading,
|
| 643 |
}: EscalateSocialCardProps) {
|
| 644 |
const [copiedX, setCopiedX] = useState(false);
|
| 645 |
const [copiedThreads, setCopiedThreads] = useState(false);
|
|
|
|
| 528 |
missionTitle={missionTitle}
|
| 529 |
missionBodyText={missionBodyText}
|
| 530 |
authorityUrl={(step as typeof step & { authorityUrl?: string }).authorityUrl}
|
|
|
|
|
|
|
| 531 |
/>
|
| 532 |
)}
|
| 533 |
</div>
|
|
|
|
| 626 |
missionTitle?: string;
|
| 627 |
missionBodyText?: string;
|
| 628 |
authorityUrl?: string | null;
|
|
|
|
|
|
|
| 629 |
}
|
| 630 |
|
| 631 |
export function EscalateSocialCard({
|
|
|
|
| 634 |
missionTitle,
|
| 635 |
missionBodyText,
|
| 636 |
authorityUrl,
|
|
|
|
|
|
|
| 637 |
}: EscalateSocialCardProps) {
|
| 638 |
const [copiedX, setCopiedX] = useState(false);
|
| 639 |
const [copiedThreads, setCopiedThreads] = useState(false);
|
packages/db/src/seeds/demo-data.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { createHash } from "node:crypto";
|
|
| 11 |
import { readFileSync } from "node:fs";
|
| 12 |
import { resolve, dirname } from "node:path";
|
| 13 |
import { fileURLToPath } from "node:url";
|
| 14 |
-
import { eq,
|
| 15 |
import { randomUUID } from "node:crypto";
|
| 16 |
|
| 17 |
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -46,14 +46,9 @@ const DB = getDb();
|
|
| 46 |
|
| 47 |
// ββ Constants βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 48 |
const USER_ID = "3599b3f5-2123-4175-be72-65a56346cdbe";
|
| 49 |
-
const OTHER_USER_ID = "20bdfa04-77b6-4a38-91d7-bda7e669a731";
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
"0da8d8cf-16be-4cf7-9919-bbcb8ed6b4c6",
|
| 54 |
-
"1feac762-76fe-4375-ad6c-7169ad9ccc93",
|
| 55 |
-
"fe0811a5-baae-4110-be85-70c38b4ad2d5",
|
| 56 |
-
];
|
| 57 |
|
| 58 |
// Existing missions we will enhance with proper data
|
| 59 |
const EXISTING_FIX_MISSIONS: Array<{ id: string; title: string; domain: string; state: string }> = [
|
|
@@ -97,7 +92,7 @@ function makeSnapshot(missionId: string, state: string, overrides?: Record<strin
|
|
| 97 |
danger: false,
|
| 98 |
confidence: null,
|
| 99 |
...overrides,
|
| 100 |
-
} as
|
| 101 |
}
|
| 102 |
|
| 103 |
function state_to_headline(state: string): string {
|
|
@@ -125,7 +120,7 @@ function state_to_headline(state: string): string {
|
|
| 125 |
}
|
| 126 |
|
| 127 |
// ββ Create route plan steps ββββββββββββββββββββββββββββββββββββββ
|
| 128 |
-
function makeRouteSteps(domain: string, title: string):
|
| 129 |
const base: Array<{
|
| 130 |
stepNo: number;
|
| 131 |
actionType: string;
|
|
@@ -170,7 +165,7 @@ function makeRouteSteps(domain: string, title: string): s.NewRoutePlan["steps"]
|
|
| 170 |
return base as any;
|
| 171 |
}
|
| 172 |
|
| 173 |
-
function makeRouteCitations():
|
| 174 |
return [
|
| 175 |
{ chunkId: randomUUID(), actName: "Consumer Protection Act 2019", section: "2(9)", relevance: "Defines consumer rights" },
|
| 176 |
{ chunkId: randomUUID(), actName: "IT Act 2000", section: "66A", relevance: "Cyber fraud provisions" },
|
|
@@ -439,7 +434,7 @@ async function main() {
|
|
| 439 |
|
| 440 |
// ββ Snapshots ββ
|
| 441 |
const snapBase = { missionId, danger: false };
|
| 442 |
-
const snapshots:
|
| 443 |
makeSnapshot(missionId, "created", { ...snapBase, createdAt: new Date(createdAt) }),
|
| 444 |
];
|
| 445 |
|
|
@@ -598,11 +593,11 @@ async function main() {
|
|
| 598 |
await DB.insert(s.routePlans).values({
|
| 599 |
id: rpId, missionId,
|
| 600 |
summary: `Route plan for ${tmpl.title}`,
|
| 601 |
-
steps: makeRouteSteps(tmpl.domain, tmpl.title)
|
| 602 |
-
citations: makeRouteCitations()
|
| 603 |
-
riskNotes: [{ level: "low", note: "Standard consumer complaint process" }]
|
| 604 |
-
expectedTimeline: { minDays: 7, maxDays: 30 }
|
| 605 |
-
confidence: 0.9,
|
| 606 |
createdAt: new Date(createdAt.getTime() + 12 * 60 * 1000),
|
| 607 |
});
|
| 608 |
}
|
|
@@ -627,7 +622,6 @@ async function main() {
|
|
| 627 |
// Build action status and proofState based on how far the mission progressed
|
| 628 |
let actionStatus = "preview_ready";
|
| 629 |
let proofState: string = "draft_only";
|
| 630 |
-
let hasConsent = false;
|
| 631 |
let hasSubmission = false;
|
| 632 |
let consentGrantId: string | null = null;
|
| 633 |
|
|
@@ -637,7 +631,6 @@ async function main() {
|
|
| 637 |
"waiting_for_response", "resolver_reply_received",
|
| 638 |
"resolution_claimed", "resolved"].includes(tmpl.state)) {
|
| 639 |
actionStatus = "executed";
|
| 640 |
-
hasConsent = true;
|
| 641 |
consentGrantId = randomUUID();
|
| 642 |
if (["action_executing"].includes(tmpl.state)) {
|
| 643 |
proofState = "sent_by_email";
|
|
@@ -758,7 +751,7 @@ async function main() {
|
|
| 758 |
|
| 759 |
let entityId: string;
|
| 760 |
if (existingEntities.length > 0) {
|
| 761 |
-
entityId = existingEntities[0].id;
|
| 762 |
} else {
|
| 763 |
entityId = randomUUID();
|
| 764 |
await DB.insert(s.entities).values({
|
|
@@ -775,7 +768,7 @@ async function main() {
|
|
| 775 |
|
| 776 |
let swarmId: string;
|
| 777 |
if (existingSwarms.length > 0) {
|
| 778 |
-
swarmId = existingSwarms[0].id;
|
| 779 |
await DB.update(s.swarms)
|
| 780 |
.set({ caseCount: sql`${s.swarms.caseCount} + 1`, updatedAt: new Date() })
|
| 781 |
.where(eq(s.swarms.id, swarmId));
|
|
@@ -791,7 +784,7 @@ async function main() {
|
|
| 791 |
|
| 792 |
// ββ Takedown ββ
|
| 793 |
if (tmpl.takedown) {
|
| 794 |
-
|
| 795 |
.from(s.actions)
|
| 796 |
.where(eq(s.actions.missionId, missionId))
|
| 797 |
.limit(1);
|
|
@@ -808,7 +801,7 @@ async function main() {
|
|
| 808 |
riskLevel: "high", createdBy: "user",
|
| 809 |
} as any);
|
| 810 |
} else {
|
| 811 |
-
actionId = actionRows[0].id;
|
| 812 |
}
|
| 813 |
|
| 814 |
await DB.insert(s.takedownRequests).values({
|
|
@@ -826,7 +819,7 @@ async function main() {
|
|
| 826 |
// ββ Case Lookup ββ
|
| 827 |
if (tmpl.caseLookup) {
|
| 828 |
await DB.insert(s.caseLookups).values({
|
| 829 |
-
|
| 830 |
cnrNumber: `CNR-${tmpl.domain.toUpperCase()}-${Math.random().toString(36).slice(2, 8).toUpperCase()}`,
|
| 831 |
caseNumber: `CASE/${Math.floor(Math.random() * 10000)}/2026`,
|
| 832 |
courtName: "District Consumer Disputes Redressal Forum",
|
|
@@ -836,8 +829,8 @@ async function main() {
|
|
| 836 |
source: "eCourt",
|
| 837 |
lookupStatus: "completed",
|
| 838 |
lastOrderSummary: `Notice issued to ${tmpl.opposingParty.name as string}. Next hearing in 30 days.`,
|
| 839 |
-
nextHearingDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
|
| 840 |
-
lastOrderDate: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000),
|
| 841 |
});
|
| 842 |
}
|
| 843 |
|
|
@@ -880,11 +873,11 @@ async function main() {
|
|
| 880 |
const ledgersCount = await DB.select({ count: sql<number>`count(*)::int` }).from(s.resolutionOutcomes);
|
| 881 |
|
| 882 |
console.log("\n[demo] ββ Summary ββ");
|
| 883 |
-
console.log(` Missions: ${missionCount[0].count}`);
|
| 884 |
-
console.log(` Entities/Swarms: ${entitiesCount[0].count} entities, ${swarmsCount[0].count} swarms`);
|
| 885 |
-
console.log(` Takedown Reqs: ${takedownsCount[0].count}`);
|
| 886 |
-
console.log(` Public Pages: ${publicPagesCount[0].count}`);
|
| 887 |
-
console.log(` Resolution Outcomes: ${ledgersCount[0].count}`);
|
| 888 |
console.log("\n[demo] Done.");
|
| 889 |
|
| 890 |
await closeDb();
|
|
@@ -894,7 +887,3 @@ main().catch((err) => {
|
|
| 894 |
console.error("[demo] FATAL:", err);
|
| 895 |
process.exit(1);
|
| 896 |
});
|
| 897 |
-
|
| 898 |
-
// ββ Type helpers βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 899 |
-
type NewMissionStatusSnapshot = typeof s.missionStatusSnapshots.$inferInsert;
|
| 900 |
-
type NewRoutePlan = typeof s.routePlans.$inferInsert;
|
|
|
|
| 11 |
import { readFileSync } from "node:fs";
|
| 12 |
import { resolve, dirname } from "node:path";
|
| 13 |
import { fileURLToPath } from "node:url";
|
| 14 |
+
import { eq, and, sql } from "drizzle-orm";
|
| 15 |
import { randomUUID } from "node:crypto";
|
| 16 |
|
| 17 |
const __filename = fileURLToPath(import.meta.url);
|
|
|
|
| 46 |
|
| 47 |
// ββ Constants βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 48 |
const USER_ID = "3599b3f5-2123-4175-be72-65a56346cdbe";
|
|
|
|
| 49 |
|
| 50 |
+
type NewMissionStatusSnapshot = typeof s.missionStatusSnapshots.$inferInsert;
|
| 51 |
+
type NewRoutePlan = typeof s.routePlans.$inferInsert;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
// Existing missions we will enhance with proper data
|
| 54 |
const EXISTING_FIX_MISSIONS: Array<{ id: string; title: string; domain: string; state: string }> = [
|
|
|
|
| 92 |
danger: false,
|
| 93 |
confidence: null,
|
| 94 |
...overrides,
|
| 95 |
+
} as NewMissionStatusSnapshot;
|
| 96 |
}
|
| 97 |
|
| 98 |
function state_to_headline(state: string): string {
|
|
|
|
| 120 |
}
|
| 121 |
|
| 122 |
// ββ Create route plan steps ββββββββββββββββββββββββββββββββββββββ
|
| 123 |
+
function makeRouteSteps(domain: string, title: string): NewRoutePlan["steps"] {
|
| 124 |
const base: Array<{
|
| 125 |
stepNo: number;
|
| 126 |
actionType: string;
|
|
|
|
| 165 |
return base as any;
|
| 166 |
}
|
| 167 |
|
| 168 |
+
function makeRouteCitations(): NewRoutePlan["citations"] {
|
| 169 |
return [
|
| 170 |
{ chunkId: randomUUID(), actName: "Consumer Protection Act 2019", section: "2(9)", relevance: "Defines consumer rights" },
|
| 171 |
{ chunkId: randomUUID(), actName: "IT Act 2000", section: "66A", relevance: "Cyber fraud provisions" },
|
|
|
|
| 434 |
|
| 435 |
// ββ Snapshots ββ
|
| 436 |
const snapBase = { missionId, danger: false };
|
| 437 |
+
const snapshots: NewMissionStatusSnapshot[] = [
|
| 438 |
makeSnapshot(missionId, "created", { ...snapBase, createdAt: new Date(createdAt) }),
|
| 439 |
];
|
| 440 |
|
|
|
|
| 593 |
await DB.insert(s.routePlans).values({
|
| 594 |
id: rpId, missionId,
|
| 595 |
summary: `Route plan for ${tmpl.title}`,
|
| 596 |
+
steps: makeRouteSteps(tmpl.domain, tmpl.title),
|
| 597 |
+
citations: makeRouteCitations(),
|
| 598 |
+
riskNotes: [{ level: "low", note: "Standard consumer complaint process" }],
|
| 599 |
+
expectedTimeline: { minDays: 7, maxDays: 30 },
|
| 600 |
+
confidence: "0.9",
|
| 601 |
createdAt: new Date(createdAt.getTime() + 12 * 60 * 1000),
|
| 602 |
});
|
| 603 |
}
|
|
|
|
| 622 |
// Build action status and proofState based on how far the mission progressed
|
| 623 |
let actionStatus = "preview_ready";
|
| 624 |
let proofState: string = "draft_only";
|
|
|
|
| 625 |
let hasSubmission = false;
|
| 626 |
let consentGrantId: string | null = null;
|
| 627 |
|
|
|
|
| 631 |
"waiting_for_response", "resolver_reply_received",
|
| 632 |
"resolution_claimed", "resolved"].includes(tmpl.state)) {
|
| 633 |
actionStatus = "executed";
|
|
|
|
| 634 |
consentGrantId = randomUUID();
|
| 635 |
if (["action_executing"].includes(tmpl.state)) {
|
| 636 |
proofState = "sent_by_email";
|
|
|
|
| 751 |
|
| 752 |
let entityId: string;
|
| 753 |
if (existingEntities.length > 0) {
|
| 754 |
+
entityId = existingEntities[0]!.id;
|
| 755 |
} else {
|
| 756 |
entityId = randomUUID();
|
| 757 |
await DB.insert(s.entities).values({
|
|
|
|
| 768 |
|
| 769 |
let swarmId: string;
|
| 770 |
if (existingSwarms.length > 0) {
|
| 771 |
+
swarmId = existingSwarms[0]!.id;
|
| 772 |
await DB.update(s.swarms)
|
| 773 |
.set({ caseCount: sql`${s.swarms.caseCount} + 1`, updatedAt: new Date() })
|
| 774 |
.where(eq(s.swarms.id, swarmId));
|
|
|
|
| 784 |
|
| 785 |
// ββ Takedown ββ
|
| 786 |
if (tmpl.takedown) {
|
| 787 |
+
const actionRows = await DB.select({ id: s.actions.id })
|
| 788 |
.from(s.actions)
|
| 789 |
.where(eq(s.actions.missionId, missionId))
|
| 790 |
.limit(1);
|
|
|
|
| 801 |
riskLevel: "high", createdBy: "user",
|
| 802 |
} as any);
|
| 803 |
} else {
|
| 804 |
+
actionId = actionRows[0]!.id;
|
| 805 |
}
|
| 806 |
|
| 807 |
await DB.insert(s.takedownRequests).values({
|
|
|
|
| 819 |
// ββ Case Lookup ββ
|
| 820 |
if (tmpl.caseLookup) {
|
| 821 |
await DB.insert(s.caseLookups).values({
|
| 822 |
+
missionId,
|
| 823 |
cnrNumber: `CNR-${tmpl.domain.toUpperCase()}-${Math.random().toString(36).slice(2, 8).toUpperCase()}`,
|
| 824 |
caseNumber: `CASE/${Math.floor(Math.random() * 10000)}/2026`,
|
| 825 |
courtName: "District Consumer Disputes Redressal Forum",
|
|
|
|
| 829 |
source: "eCourt",
|
| 830 |
lookupStatus: "completed",
|
| 831 |
lastOrderSummary: `Notice issued to ${tmpl.opposingParty.name as string}. Next hearing in 30 days.`,
|
| 832 |
+
nextHearingDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split("T")[0],
|
| 833 |
+
lastOrderDate: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString().split("T")[0],
|
| 834 |
});
|
| 835 |
}
|
| 836 |
|
|
|
|
| 873 |
const ledgersCount = await DB.select({ count: sql<number>`count(*)::int` }).from(s.resolutionOutcomes);
|
| 874 |
|
| 875 |
console.log("\n[demo] ββ Summary ββ");
|
| 876 |
+
console.log(` Missions: ${missionCount[0]!.count}`);
|
| 877 |
+
console.log(` Entities/Swarms: ${entitiesCount[0]!.count} entities, ${swarmsCount[0]!.count} swarms`);
|
| 878 |
+
console.log(` Takedown Reqs: ${takedownsCount[0]!.count}`);
|
| 879 |
+
console.log(` Public Pages: ${publicPagesCount[0]!.count}`);
|
| 880 |
+
console.log(` Resolution Outcomes: ${ledgersCount[0]!.count}`);
|
| 881 |
console.log("\n[demo] Done.");
|
| 882 |
|
| 883 |
await closeDb();
|
|
|
|
| 887 |
console.error("[demo] FATAL:", err);
|
| 888 |
process.exit(1);
|
| 889 |
});
|
|
|
|
|
|
|
|
|
|
|
|