feat(events): search through organizer
This commit is contained in:
@ -368,6 +368,11 @@ func NewLocationEventAgent(locationModel models.LocationModel, eventModel models
|
|||||||
return event, err
|
return event, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = agent.contactModel.SaveToImage(ctx, info.imageId, organizer.ID)
|
||||||
|
if err != nil {
|
||||||
|
return event, err
|
||||||
|
}
|
||||||
|
|
||||||
locationId, err := uuid.Parse(args.LocationId)
|
locationId, err := uuid.Parse(args.LocationId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return event, err
|
return event, err
|
||||||
|
@ -54,7 +54,7 @@ func (m ContactModel) Save(ctx context.Context, userId uuid.UUID, contact model.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m ContactModel) SaveToImage(ctx context.Context, imageId uuid.UUID, contactId uuid.UUID) (model.ImageContacts, error) {
|
func (m ContactModel) SaveToImage(ctx context.Context, imageId uuid.UUID, contactId uuid.UUID) (model.ImageContacts, error) {
|
||||||
insertImageContactStmt := ImageLocations.
|
insertImageContactStmt := ImageContacts.
|
||||||
INSERT(ImageContacts.ImageID, ImageContacts.ContactID).
|
INSERT(ImageContacts.ImageID, ImageContacts.ContactID).
|
||||||
VALUES(imageId, contactId).
|
VALUES(imageId, contactId).
|
||||||
RETURNING(ImageContacts.AllColumns)
|
RETURNING(ImageContacts.AllColumns)
|
||||||
|
@ -34,7 +34,8 @@ type ImageWithProperties struct {
|
|||||||
Events []struct {
|
Events []struct {
|
||||||
model.Events
|
model.Events
|
||||||
|
|
||||||
Location *model.Locations
|
Location *model.Locations
|
||||||
|
Organizer *model.Contacts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +70,8 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([]
|
|||||||
Locations.AllColumns,
|
Locations.AllColumns,
|
||||||
ImageEvents.AllColumns,
|
ImageEvents.AllColumns,
|
||||||
Events.AllColumns,
|
Events.AllColumns,
|
||||||
|
ImageContacts.AllColumns,
|
||||||
|
Contacts.AllColumns,
|
||||||
).
|
).
|
||||||
FROM(
|
FROM(
|
||||||
UserImages.INNER_JOIN(Image, Image.ID.EQ(UserImages.ImageID)).
|
UserImages.INNER_JOIN(Image, Image.ID.EQ(UserImages.ImageID)).
|
||||||
@ -79,7 +82,9 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([]
|
|||||||
LEFT_JOIN(ImageLocations, ImageLocations.ImageID.EQ(UserImages.ImageID)).
|
LEFT_JOIN(ImageLocations, ImageLocations.ImageID.EQ(UserImages.ImageID)).
|
||||||
LEFT_JOIN(Locations, Locations.ID.EQ(ImageLocations.LocationID)).
|
LEFT_JOIN(Locations, Locations.ID.EQ(ImageLocations.LocationID)).
|
||||||
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(Contacts, Contacts.ID.EQ(ImageContacts.ContactID))).
|
||||||
WHERE(UserImages.UserID.EQ(UUID(userId)))
|
WHERE(UserImages.UserID.EQ(UUID(userId)))
|
||||||
|
|
||||||
fmt.Println(listWithPropertiesStmt.DebugSql())
|
fmt.Println(listWithPropertiesStmt.DebugSql())
|
||||||
|
@ -17,7 +17,7 @@ export const SearchCardEvent = ({ item }: Props) => {
|
|||||||
<IconCalendar size={20} class="text-neutral-500 mt-1" />
|
<IconCalendar size={20} class="text-neutral-500 mt-1" />
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-neutral-500">
|
<p class="text-xs text-neutral-500">
|
||||||
Organized by TODO on{" "}
|
Organized by {data.Organizer?.Name ?? "unknown"} on{" "}
|
||||||
{new Date(data.StartDateTime).toLocaleDateString("en-US", {
|
{new Date(data.StartDateTime).toLocaleDateString("en-US", {
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
|
@ -2,17 +2,13 @@ import {
|
|||||||
type InferOutput,
|
type InferOutput,
|
||||||
array,
|
array,
|
||||||
nullable,
|
nullable,
|
||||||
object,
|
strictObject,
|
||||||
parse,
|
parse,
|
||||||
pipe,
|
pipe,
|
||||||
string,
|
string,
|
||||||
null_,
|
|
||||||
uuid,
|
uuid,
|
||||||
literal,
|
literal,
|
||||||
variant,
|
variant,
|
||||||
date,
|
|
||||||
isoDate,
|
|
||||||
isoDateTime,
|
|
||||||
} from "valibot";
|
} from "valibot";
|
||||||
|
|
||||||
type BaseRequestParams = Partial<{
|
type BaseRequestParams = Partial<{
|
||||||
@ -29,7 +25,7 @@ const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendImageResponseValidator = object({
|
const sendImageResponseValidator = strictObject({
|
||||||
ID: pipe(string(), uuid()),
|
ID: pipe(string(), uuid()),
|
||||||
ImageID: pipe(string(), uuid()),
|
ImageID: pipe(string(), uuid()),
|
||||||
UserID: pipe(string(), uuid()),
|
UserID: pipe(string(), uuid()),
|
||||||
@ -52,14 +48,22 @@ export const sendImage = async (
|
|||||||
return parse(sendImageResponseValidator, res);
|
return parse(sendImageResponseValidator, res);
|
||||||
};
|
};
|
||||||
|
|
||||||
const locationValidator = object({
|
const locationValidator = strictObject({
|
||||||
ID: pipe(string(), uuid()),
|
ID: pipe(string(), uuid()),
|
||||||
Name: string(),
|
Name: string(),
|
||||||
Address: nullable(string()),
|
Address: nullable(string()),
|
||||||
Description: nullable(string()),
|
Description: nullable(string()),
|
||||||
});
|
});
|
||||||
|
|
||||||
const eventValidator = object({
|
const contactValidator = strictObject({
|
||||||
|
ID: pipe(string(), uuid()),
|
||||||
|
Name: string(),
|
||||||
|
Description: nullable(string()),
|
||||||
|
PhoneNumber: nullable(string()),
|
||||||
|
Email: nullable(string()),
|
||||||
|
});
|
||||||
|
|
||||||
|
const eventValidator = strictObject({
|
||||||
ID: pipe(string(), uuid()),
|
ID: pipe(string(), uuid()),
|
||||||
Name: string(),
|
Name: string(),
|
||||||
StartDateTime: nullable(pipe(string())),
|
StartDateTime: nullable(pipe(string())),
|
||||||
@ -67,14 +71,16 @@ const eventValidator = object({
|
|||||||
Description: nullable(string()),
|
Description: nullable(string()),
|
||||||
LocationID: nullable(pipe(string(), uuid())),
|
LocationID: nullable(pipe(string(), uuid())),
|
||||||
Location: nullable(locationValidator),
|
Location: nullable(locationValidator),
|
||||||
|
OrganizerID: nullable(pipe(string(), uuid())),
|
||||||
|
Organizer: nullable(contactValidator),
|
||||||
});
|
});
|
||||||
|
|
||||||
const locationDataType = object({
|
const locationDataType = strictObject({
|
||||||
type: literal("location"),
|
type: literal("location"),
|
||||||
data: locationValidator,
|
data: locationValidator,
|
||||||
});
|
});
|
||||||
|
|
||||||
const eventDataType = object({
|
const eventDataType = strictObject({
|
||||||
type: literal("event"),
|
type: literal("event"),
|
||||||
data: eventValidator,
|
data: eventValidator,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user