feat: refactor document URL retrieval for atestados and licencas
- Updated the document URL fetching logic in the +page.svelte file to use a new query method, enhancing the retrieval process. - Added a new query in atestadosLicencas.ts to obtain stored document URLs, improving authentication checks and error handling. - Streamlined the user experience by ensuring URLs are fetched correctly and opened in a new tab when available.
This commit is contained in:
@@ -740,6 +740,22 @@ export const generateUploadUrl = mutation({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Obter URL de um documento armazenado
|
||||
*/
|
||||
export const obterUrlDocumento = query({
|
||||
args: {
|
||||
storageId: v.id("_storage"),
|
||||
},
|
||||
returns: v.union(v.string(), v.null()),
|
||||
handler: async (ctx, args) => {
|
||||
const usuario = await getUsuarioAutenticado(ctx);
|
||||
if (!usuario) throw new Error("Não autenticado");
|
||||
|
||||
return await ctx.storage.getUrl(args.storageId);
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Criar atestado médico
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user