feat(notes): allowing frontend to save
This commit is contained in:
@ -110,7 +110,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = agents.NewLocationEventAgent(locationModel, eventModel, contactModel)
|
locationAgent, err := agents.NewLocationEventAgent(locationModel, eventModel, contactModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -134,9 +134,11 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.Println("Calling locationAgent!")
|
// TODO: this can very much be parallel
|
||||||
// err = locationAgent.GetLocations(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
|
|
||||||
// log.Println(err)
|
log.Println("Calling locationAgent!")
|
||||||
|
err = locationAgent.GetLocations(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
|
||||||
|
log.Println(err)
|
||||||
|
|
||||||
log.Println("Calling noteAgent!")
|
log.Println("Calling noteAgent!")
|
||||||
err = noteAgent.GetNotes(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
|
err = noteAgent.GetNotes(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image)
|
||||||
@ -230,6 +232,13 @@ func main() {
|
|||||||
Data: event,
|
Data: event,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, note := range image.Notes {
|
||||||
|
dataTypes = append(dataTypes, DataType{
|
||||||
|
Type: "note",
|
||||||
|
Data: note,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonImages, err := json.Marshal(dataTypes)
|
jsonImages, err := json.Marshal(dataTypes)
|
||||||
|
@ -37,6 +37,8 @@ type ImageWithProperties struct {
|
|||||||
Location *model.Locations
|
Location *model.Locations
|
||||||
Organizer *model.Contacts
|
Organizer *model.Contacts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notes []model.Notes
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserIdFromImage(ctx context.Context, dbPool *sql.DB, imageId uuid.UUID) (uuid.UUID, error) {
|
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,
|
Events.AllColumns,
|
||||||
ImageContacts.AllColumns,
|
ImageContacts.AllColumns,
|
||||||
Contacts.AllColumns,
|
Contacts.AllColumns,
|
||||||
|
ImageNotes.AllColumns,
|
||||||
|
Notes.AllColumns,
|
||||||
).
|
).
|
||||||
FROM(
|
FROM(
|
||||||
UserImages.INNER_JOIN(Image, Image.ID.EQ(UserImages.ImageID)).
|
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(ImageEvents, ImageEvents.ImageID.EQ(UserImages.ImageID)).
|
||||||
LEFT_JOIN(Events, Events.ID.EQ(ImageEvents.EventID)).
|
LEFT_JOIN(Events, Events.ID.EQ(ImageEvents.EventID)).
|
||||||
LEFT_JOIN(ImageContacts, ImageContacts.ImageID.EQ(UserImages.ImageID)).
|
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)))
|
WHERE(UserImages.UserID.EQ(UUID(userId)))
|
||||||
|
|
||||||
fmt.Println(listWithPropertiesStmt.DebugSql())
|
fmt.Println(listWithPropertiesStmt.DebugSql())
|
||||||
|
@ -6,6 +6,7 @@ import { SearchCardEvent } from "./components/search-card/SearchCardEvent";
|
|||||||
import { SearchCardLocation } from "./components/search-card/SearchCardLocation";
|
import { SearchCardLocation } from "./components/search-card/SearchCardLocation";
|
||||||
import { UserImage, getUserImages } from "./network";
|
import { UserImage, getUserImages } from "./network";
|
||||||
import { getCardSize } from "./utils/getCardSize";
|
import { getCardSize } from "./utils/getCardSize";
|
||||||
|
import { SearchCardNote } from "./components/search-card/SearchCardNote";
|
||||||
|
|
||||||
const getCardComponent = (item: UserImage) => {
|
const getCardComponent = (item: UserImage) => {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
@ -13,6 +14,8 @@ const getCardComponent = (item: UserImage) => {
|
|||||||
return <SearchCardLocation item={item} />;
|
return <SearchCardLocation item={item} />;
|
||||||
case "event":
|
case "event":
|
||||||
return <SearchCardEvent item={item} />;
|
return <SearchCardEvent item={item} />;
|
||||||
|
case "note":
|
||||||
|
return <SearchCardNote item={item} />;
|
||||||
// case "Contact":
|
// case "Contact":
|
||||||
// return <SearchCardContact item={item} />;
|
// return <SearchCardContact item={item} />;
|
||||||
// case "Website":
|
// case "Website":
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { Separator } from "@kobalte/core/separator";
|
import { Separator } from "@kobalte/core/separator";
|
||||||
|
|
||||||
import { IconNote } from "@tabler/icons-solidjs";
|
import { IconNote } from "@tabler/icons-solidjs";
|
||||||
import type { Note } from "../../network/types";
|
import type { UserImage } from "../../network";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
item: Note;
|
item: Extract<UserImage, { type: "note" }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SearchCardNote = ({ item }: Props) => {
|
export const SearchCardNote = ({ item }: Props) => {
|
||||||
@ -13,13 +13,13 @@ export const SearchCardNote = ({ item }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div class="absolute inset-0 p-3 bg-green-50">
|
<div class="absolute inset-0 p-3 bg-green-50">
|
||||||
<div class="grid grid-cols-[auto_20px] gap-1 mb-1">
|
<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" />
|
<IconNote size={20} class="text-neutral-500 mt-1" />
|
||||||
</div>
|
</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" />
|
<Separator class="my-2" />
|
||||||
<p class="text-xs text-neutral-500 line-clamp-2 overflow-hidden">
|
<p class="text-xs text-neutral-500 line-clamp-2 overflow-hidden">
|
||||||
{data.content}
|
{data.Content}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -75,6 +75,13 @@ const eventValidator = strictObject({
|
|||||||
Organizer: nullable(contactValidator),
|
Organizer: nullable(contactValidator),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const noteValidator = strictObject({
|
||||||
|
ID: pipe(string(), uuid()),
|
||||||
|
Name: string(),
|
||||||
|
Description: nullable(string()),
|
||||||
|
Content: string(),
|
||||||
|
});
|
||||||
|
|
||||||
const locationDataType = strictObject({
|
const locationDataType = strictObject({
|
||||||
type: literal("location"),
|
type: literal("location"),
|
||||||
data: locationValidator,
|
data: locationValidator,
|
||||||
@ -85,7 +92,16 @@ const eventDataType = strictObject({
|
|||||||
data: eventValidator,
|
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);
|
const getUserImagesResponseValidator = array(dataTypeValidator);
|
||||||
|
|
||||||
export type UserImage = InferOutput<typeof dataTypeValidator>;
|
export type UserImage = InferOutput<typeof dataTypeValidator>;
|
||||||
|
Reference in New Issue
Block a user