feat: add avatar field to user profile schema and update related mutations and queries
- Introduced an optional avatar field in the user profile schema to store the URL of the generated avatar. - Updated the atualizarPerfil mutation to handle the new avatar field. - Modified the obterPerfil and listarParaChat queries to include the avatar field in the returned user data.
This commit is contained in:
@@ -537,6 +537,7 @@ export default defineSchema({
|
||||
// Campos de Chat e Perfil
|
||||
|
||||
fotoPerfil: v.optional(v.id("_storage")),
|
||||
avatar: v.optional(v.string()), // URL do avatar gerado (ex: DiceBear)
|
||||
setor: v.optional(v.string()),
|
||||
statusMensagem: v.optional(v.string()), // max 100 chars
|
||||
statusPresenca: v.optional(
|
||||
|
||||
@@ -481,6 +481,7 @@ export const alterarRole = mutation({
|
||||
export const atualizarPerfil = mutation({
|
||||
args: {
|
||||
fotoPerfil: v.optional(v.id('_storage')),
|
||||
avatar: v.optional(v.string()), // URL do avatar gerado (ex: DiceBear)
|
||||
setor: v.optional(v.string()),
|
||||
statusMensagem: v.optional(v.string()),
|
||||
statusPresenca: v.optional(
|
||||
@@ -511,6 +512,7 @@ export const atualizarPerfil = mutation({
|
||||
};
|
||||
|
||||
if (args.fotoPerfil !== undefined) updates.fotoPerfil = args.fotoPerfil;
|
||||
if (args.avatar !== undefined) updates.avatar = args.avatar;
|
||||
if (args.setor !== undefined) updates.setor = args.setor;
|
||||
if (args.statusMensagem !== undefined) updates.statusMensagem = args.statusMensagem;
|
||||
if (args.statusPresenca !== undefined) {
|
||||
@@ -532,7 +534,7 @@ export const atualizarPerfil = mutation({
|
||||
*/
|
||||
export const obterPerfil = query({
|
||||
args: {},
|
||||
returns: v.union(
|
||||
returns: v.union(
|
||||
v.object({
|
||||
_id: v.id('usuarios'),
|
||||
nome: v.string(),
|
||||
@@ -541,6 +543,7 @@ export const obterPerfil = query({
|
||||
funcionarioId: v.optional(v.id('funcionarios')),
|
||||
fotoPerfil: v.optional(v.id('_storage')),
|
||||
fotoPerfilUrl: v.union(v.string(), v.null()),
|
||||
avatar: v.optional(v.string()), // URL do avatar gerado (ex: DiceBear)
|
||||
setor: v.optional(v.string()),
|
||||
statusMensagem: v.optional(v.string()),
|
||||
statusPresenca: v.optional(
|
||||
@@ -581,6 +584,7 @@ export const obterPerfil = query({
|
||||
funcionarioId: usuarioAtual.funcionarioId,
|
||||
fotoPerfil: usuarioAtual.fotoPerfil,
|
||||
fotoPerfilUrl,
|
||||
avatar: usuarioAtual.avatar,
|
||||
setor: usuarioAtual.setor,
|
||||
statusMensagem: usuarioAtual.statusMensagem,
|
||||
statusPresenca: usuarioAtual.statusPresenca,
|
||||
@@ -595,7 +599,7 @@ export const obterPerfil = query({
|
||||
*/
|
||||
export const listarParaChat = query({
|
||||
args: {},
|
||||
returns: v.array(
|
||||
returns: v.array(
|
||||
v.object({
|
||||
_id: v.id('usuarios'),
|
||||
nome: v.string(),
|
||||
@@ -603,6 +607,7 @@ export const listarParaChat = query({
|
||||
matricula: v.optional(v.string()),
|
||||
fotoPerfil: v.optional(v.id('_storage')),
|
||||
fotoPerfilUrl: v.union(v.string(), v.null()),
|
||||
avatar: v.optional(v.string()), // URL do avatar gerado (ex: DiceBear)
|
||||
statusPresenca: v.optional(
|
||||
v.union(
|
||||
v.literal('online'),
|
||||
|
||||
Reference in New Issue
Block a user