Skip to content

Commit

Permalink
[UP] Mais mudanças relacionadas ao banco de dados
Browse files Browse the repository at this point in the history
  • Loading branch information
JAugustoM committed Dec 12, 2024
1 parent 3edcbb5 commit 96bf602
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 8 additions & 2 deletions catavento/lib/bloc/demanda_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ class DemandaBloc extends Bloc<DemandaEvent, DemandaState> {

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) {
Expand Down
9 changes: 4 additions & 5 deletions catavento/lib/services/table_import/table_import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Future<void> 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();
Expand All @@ -33,18 +34,17 @@ Future<void> 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<String, dynamic> demanda = {
'nome_demanda': rowData[0],
'data_adicao': dataAdicao,
'descricao': 'Bolo normal',
'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)) {
Expand All @@ -53,7 +53,6 @@ Future<void> 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();
Expand Down

0 comments on commit 96bf602

Please sign in to comment.