From 96bf602cc77602adba5fbf8a17245ecd24c1abe0 Mon Sep 17 00:00:00 2001 From: JAugustoM Date: Thu, 12 Dec 2024 16:37:27 -0300 Subject: [PATCH] =?UTF-8?q?[UP]=20Mais=20mudan=C3=A7as=20relacionadas=20ao?= =?UTF-8?q?=20banco=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catavento/lib/bloc/demanda_bloc.dart | 10 ++++++++-- catavento/lib/services/table_import/table_import.dart | 9 ++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/catavento/lib/bloc/demanda_bloc.dart b/catavento/lib/bloc/demanda_bloc.dart index 70078f9..be0f2fa 100644 --- a/catavento/lib/bloc/demanda_bloc.dart +++ b/catavento/lib/bloc/demanda_bloc.dart @@ -78,11 +78,17 @@ class DemandaBloc extends Bloc { final dataAdicao = DateFormat(timeFormat).format(DateTime.now()); + print('Teste'); + print(event.descricao); + final demanda = { 'nome_demanda': event.nomeDemanda, - 'descricao': event.descricao, - 'status': event.status, + 'descricao': event.descricao == '' ? 'Bolo normal' : event.descricao, + 'status': 'Pendente', + 'status_cobertura': 0, + 'status_aplique': 0, 'data_adicao': dataAdicao, + 'prioridade': 'media', }; if (fotoUrl != null) { diff --git a/catavento/lib/services/table_import/table_import.dart b/catavento/lib/services/table_import/table_import.dart index 6204dec..2987a7a 100644 --- a/catavento/lib/services/table_import/table_import.dart +++ b/catavento/lib/services/table_import/table_import.dart @@ -25,6 +25,7 @@ Future importExcelToSupabase(String filePath) async { if (sheet != null) { var rowId = 0; var loja = ""; + final dataAdicao = DateFormat(timeFormat).format(DateTime.now()); for (var row in sheet.rows) { final rowData = row.map((cell) => cell?.value.toString() ?? '').toList(); @@ -33,7 +34,6 @@ Future importExcelToSupabase(String filePath) async { // Evita linhas inválidas if ((rowData[0] != "" && rowData[0] != "null") && (rowData[1] != "" && rowData[1] != "null")) { - final dataAdicao = DateFormat(timeFormat).format(DateTime.now()); final Map demanda = { 'nome_demanda': rowData[0], 'data_adicao': dataAdicao, @@ -41,10 +41,10 @@ Future importExcelToSupabase(String filePath) async { 'status': 'Pendente', }; - final codigo = rowData[1]; + final codigo = int.tryParse(rowData[1]); - if (int.tryParse(codigo) != null) { - demanda['produto_id'] = int.parse(codigo); + if (codigo != null) { + demanda['produto_id'] = codigo; } if (lojasPrioridade.containsKey(loja)) { @@ -53,7 +53,6 @@ Future importExcelToSupabase(String filePath) async { demanda['prioridade'] = 'media'; } - // Envia os dados ao Supabase await supabase.from('demandas').insert(demanda); } else if (rowData[0] != "" && rowData[0] != "null") { loja = rowData[0].toUpperCase();