-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(user/profile): update user location on profile
- infer type from zod's user schema - use `GeoPoint` when handling location
- Loading branch information
Showing
4 changed files
with
54 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
import { z } from "zod"; | ||
|
||
export const userSchema = z.object({ | ||
body: z.object({ | ||
name: z.string().min(3, "Name must be at least 3 characters").optional(), | ||
phoneNum: z | ||
.string() | ||
.min(10, "Phone number must be at least 10 characters") | ||
.optional(), | ||
// TODO: | ||
// city | ||
// interests | ||
// learningStyle | ||
id: z.string(), | ||
name: z.string().min(3, "Name must be at least 3 characters"), | ||
phoneNum: z | ||
.string() | ||
.min(10, "Phone number must be at least 10 characters") | ||
.optional(), | ||
location: z | ||
.object({ | ||
latitude: z.number({ message: "Latitude must be a number" }), | ||
longitude: z.number({ message: "Longitude must be a number" }), | ||
}) | ||
.optional(), | ||
createdAt: z.date(), | ||
updatedAt: z.date(), | ||
lastSeen: z.date().optional(), | ||
interests: z.array(z.string()).optional(), | ||
learningStyle: z | ||
.enum(["visual", "auditory", "reading/writing", "kinesthetic"]) | ||
.optional(), | ||
}); | ||
|
||
export const updateProfileSchema = z.object({ | ||
body: userSchema.omit({ | ||
id: true, | ||
createdAt: true, | ||
updatedAt: true, | ||
lastSeen: true, | ||
interests: true, | ||
learningStyle: true, | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters