feat(notes): allowing frontend to save

This commit is contained in:
2025-04-01 20:54:15 +00:00
parent f72ee73020
commit 745265773b
5 changed files with 45 additions and 11 deletions

View File

@ -110,7 +110,7 @@ func main() {
panic(err)
}
_, err = agents.NewLocationEventAgent(locationModel, eventModel, contactModel)
locationAgent, err := agents.NewLocationEventAgent(locationModel, eventModel, contactModel)
if err != nil {
panic(err)
}
@ -134,9 +134,11 @@ func main() {
return
}
// log.Println("Calling locationAgent!")
// err = locationAgent.GetLocations(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
// log.Println(err)
// TODO: this can very much be parallel
log.Println("Calling locationAgent!")
err = locationAgent.GetLocations(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
log.Println(err)
log.Println("Calling noteAgent!")
err = noteAgent.GetNotes(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
@ -230,6 +232,13 @@ func main() {
Data: event,
})
}
for _, note := range image.Notes {
dataTypes = append(dataTypes, DataType{
Type: "note",
Data: note,
})
}
}
jsonImages, err := json.Marshal(dataTypes)

View File

@ -37,6 +37,8 @@ type ImageWithProperties struct {
Location *model.Locations
Organizer *model.Contacts
}
Notes []model.Notes
}
func getUserIdFromImage(ctx context.Context, dbPool *sql.DB, imageId uuid.UUID) (uuid.UUID, error) {
@ -72,6 +74,8 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([]
Events.AllColumns,
ImageContacts.AllColumns,
Contacts.AllColumns,
ImageNotes.AllColumns,
Notes.AllColumns,
).
FROM(
UserImages.INNER_JOIN(Image, Image.ID.EQ(UserImages.ImageID)).
@ -84,7 +88,9 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([]
LEFT_JOIN(ImageEvents, ImageEvents.ImageID.EQ(UserImages.ImageID)).
LEFT_JOIN(Events, Events.ID.EQ(ImageEvents.EventID)).
LEFT_JOIN(ImageContacts, ImageContacts.ImageID.EQ(UserImages.ImageID)).
LEFT_JOIN(Contacts, Contacts.ID.EQ(ImageContacts.ContactID))).
LEFT_JOIN(Contacts, Contacts.ID.EQ(ImageContacts.ContactID)).
LEFT_JOIN(ImageNotes, ImageNotes.ImageID.EQ(UserImages.ImageID)).
LEFT_JOIN(Notes, Notes.ID.EQ(ImageNotes.NoteID))).
WHERE(UserImages.UserID.EQ(UUID(userId)))
fmt.Println(listWithPropertiesStmt.DebugSql())

View File

@ -6,6 +6,7 @@ import { SearchCardEvent } from "./components/search-card/SearchCardEvent";
import { SearchCardLocation } from "./components/search-card/SearchCardLocation";
import { UserImage, getUserImages } from "./network";
import { getCardSize } from "./utils/getCardSize";
import { SearchCardNote } from "./components/search-card/SearchCardNote";
const getCardComponent = (item: UserImage) => {
switch (item.type) {
@ -13,6 +14,8 @@ const getCardComponent = (item: UserImage) => {
return <SearchCardLocation item={item} />;
case "event":
return <SearchCardEvent item={item} />;
case "note":
return <SearchCardNote item={item} />;
// case "Contact":
// return <SearchCardContact item={item} />;
// case "Website":

View File

@ -1,10 +1,10 @@
import { Separator } from "@kobalte/core/separator";
import { IconNote } from "@tabler/icons-solidjs";
import type { Note } from "../../network/types";
import type { UserImage } from "../../network";
type Props = {
item: Note;
item: Extract<UserImage, { type: "note" }>;
};
export const SearchCardNote = ({ item }: Props) => {
@ -13,13 +13,13 @@ export const SearchCardNote = ({ item }: Props) => {
return (
<div class="absolute inset-0 p-3 bg-green-50">
<div class="grid grid-cols-[auto_20px] gap-1 mb-1">
<p class="text-sm text-neutral-900 font-bold">{data.title}</p>
<p class="text-sm text-neutral-900 font-bold">{data.Name}</p>
<IconNote size={20} class="text-neutral-500 mt-1" />
</div>
<p class="text-xs text-neutral-500">{data.keywords}</p>
<p class="text-xs text-neutral-500">Keywords TODO</p>
<Separator class="my-2" />
<p class="text-xs text-neutral-500 line-clamp-2 overflow-hidden">
{data.content}
{data.Content}
</p>
</div>
);

View File

@ -75,6 +75,13 @@ const eventValidator = strictObject({
Organizer: nullable(contactValidator),
});
const noteValidator = strictObject({
ID: pipe(string(), uuid()),
Name: string(),
Description: nullable(string()),
Content: string(),
});
const locationDataType = strictObject({
type: literal("location"),
data: locationValidator,
@ -85,7 +92,16 @@ const eventDataType = strictObject({
data: eventValidator,
});
const dataTypeValidator = variant("type", [locationDataType, eventDataType]);
const noteDataType = strictObject({
type: literal("note"),
data: noteValidator,
});
const dataTypeValidator = variant("type", [
locationDataType,
eventDataType,
noteDataType,
]);
const getUserImagesResponseValidator = array(dataTypeValidator);
export type UserImage = InferOutput<typeof dataTypeValidator>;