Skip to content

Commit

Permalink
Corrigindo erro de imagem vazia
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor-oss committed Dec 12, 2023
1 parent 7c2e8a5 commit 299ea78
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions backend/prisma/migrations/20231211235124_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Drill" ALTER COLUMN "image" SET DEFAULT 'abc';
2 changes: 2 additions & 0 deletions backend/prisma/migrations/20231211235631_/migration.sql

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/src/controllers/drillController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default class drillController {
image,
},
})
console.log("Foi")
res.status(204).json(updatedDrill)
} catch (err) {
res.status(500).json({ error: "Internal Server Error" })
Expand Down
1 change: 0 additions & 1 deletion backend/src/zodSchemas/drill.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const drillSchema = z.object({
.string()
.max(500, "Observações deve ter no máximo 500 caracteres"),
classPlanId: z.string().uuid("Id do plano de aula inválido"),
image: z.string(),
})

export { drillSchema }
15 changes: 5 additions & 10 deletions frontend/src/pages/Drill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,11 @@ const Drill = () => {

async function saveDrillState() {
updateImagen();
// let data = {
// id: selectedDrill.id,
// title: titleAux,
// image: imagemBase64,
// description: selectedDrill.description,
// observations: selectedDrill.observations,
// classPlanId: selectedDrill.classPlanId,
// };
// console.log(data)
// await drill.updateById(id as string, data);
let data = {
image: imagemBase64
};
console.log(data.image)
await drill.updateImage(selectedDrill.id, data);
for (const [idNewItem, indexNewItem] of newItems) {
try {
const element = document.getElementById(idNewItem);
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/pages/ViewPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const ViewPlan = () => {
title: titleDrill,
description: '',
observations: '',
image: '',
classPlanId: selectedClassPlan.id,
};
let newDrillData = await drill.save(data);
Expand Down Expand Up @@ -282,8 +281,7 @@ const ViewPlan = () => {

// Configurar as opções do html2pdf
const options = {

filename: 'plano_de_aula_com_drills.pdf',
filename: `${title}.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/service/drillService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class DrillService extends Apiservice {
});
}

async updateImage(id: string, data: any) {
return this.put('/image/' + id, data, {
headers: { Authorization: `Bearer ${this.token}` },
});
}

async deleteById(id: string) {
return this.delete('/' + id, {
headers: { Authorization: `Bearer ${this.token}` },
Expand Down

0 comments on commit 299ea78

Please sign in to comment.