Fixes the copy on new sessions, some additional styling work

This commit is contained in:
2025-06-28 17:48:56 -07:00
parent c00eb1d965
commit 6ce462a77d
20 changed files with 268 additions and 91 deletions

View File

@@ -42,12 +42,9 @@ function RouteComponent() {
// Check for a previous session
const prevSession = await pb
.collection("documents")
.getFirstListItem(
`campaign = "${campaign.id}" && json_extract(data, '$.session') != null`,
{
sort: "-created",
},
);
.getFirstListItem(`campaign = "${campaign.id}" && type = 'session'`, {
sort: "-created",
});
console.log("Previous session: ", {
id: prevSession.id,
@@ -62,9 +59,7 @@ function RouteComponent() {
},
});
queryClient.invalidateQueries({ queryKey: ["campaign"] });
// If any, then copy things over
// If any relations, then copy things over
if (prevSession) {
const prevRelations = await pb
.collection<Relationship>("relationships")
@@ -81,7 +76,7 @@ function RouteComponent() {
await pb.collection("relationships").create({
primary: newSession.id,
type: relation.type,
seciondary: relation.secondary,
secondary: relation.secondary,
});
}
}

View File

@@ -38,14 +38,17 @@ function RouteComponent() {
<TabGroup>
<TabList className="flex flex-row flex-wrap gap-1 mt-2">
{relationshipList.map((relationshipType) => (
<Tab className="px-3 py-2 rounded bg-slate-800 text-slate-100 border border-slate-700 focus:outline-none focus:ring-2 focus:ring-violet-500 data-selected:bg-violet-900 data-selected:border-violet-700">
<Tab
key={relationshipType}
className="px-3 py-2 rounded bg-slate-800 text-slate-100 border border-slate-700 focus:outline-none focus:ring-2 focus:ring-violet-500 data-selected:bg-violet-900 data-selected:border-violet-700"
>
{displayName(relationshipType)}
</Tab>
))}
</TabList>
<TabPanels>
{relationshipList.map((relationshipType) => (
<TabPanel>
<TabPanel key={relationshipType}>
<RelationshipList
key={relationshipType}
root={document}