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:
@@ -1,13 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { browser } from '$app/environment';
|
||||
import { onMount } from 'svelte';
|
||||
import type { ConstructorOfATypedSvelteComponent } from 'svelte/types/runtime/component';
|
||||
import CybersecurityWizcard from '$lib/components/ti/CybersecurityWizcard.svelte';
|
||||
// Usar tipo amplo para evitar conflitos de tipagem do import dinâmico no build
|
||||
let Comp: any = null;
|
||||
onMount(async () => {
|
||||
const mod = await import('$lib/components/ti/CybersecurityWizcard.svelte');
|
||||
Comp = mod.default;
|
||||
});
|
||||
let Comp: ConstructorOfATypedSvelteComponent<typeof CybersecurityWizcard> | null = null;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
@@ -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) {
|
||||
@@ -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,
|
||||
@@ -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