From ca08188f44ba3403fbb961897c6cbd6c8234dc60 Mon Sep 17 00:00:00 2001 From: Danielle Soares Date: Sun, 8 Dec 2024 13:13:42 -0300 Subject: [PATCH 01/10] feat: widget menu sem ajustes de responsividade --- catavento/lib/screens/components/menu.dart | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 catavento/lib/screens/components/menu.dart diff --git a/catavento/lib/screens/components/menu.dart b/catavento/lib/screens/components/menu.dart new file mode 100644 index 0000000..8d97090 --- /dev/null +++ b/catavento/lib/screens/components/menu.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; + +class IconMenu extends StatefulWidget { + const IconMenu({super.key}); + + @override + State createState() { + return IconMenuState(); + } +} + +class IconMenuState extends State { + void openMenu(BuildContext context) { + showModalBottomSheet( + context: context, + builder: (context) { + return Container( + height: 300, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + color: Colors.pink[100], + padding: EdgeInsets.all(16), + child: Row( + children: [ + CircleAvatar( + backgroundColor: Colors.grey, + radius: 25, + ), + SizedBox(width: 16), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'João das Couves', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + Text( + 'Administrador', + style: TextStyle( + fontSize: 14, + color: Colors.grey[700], + ), + ), + ], + ), + ], + ), + ), + ListTile( + title: Text('Demandas'), + onTap: () { + // Ação para Demandas + }, + ), + ListTile( + title: Text('Funcionários'), + onTap: () { + // Ação para Funcionários + }, + ), + ListTile( + title: Text('Produtos'), + onTap: () { + // Ação para Produtos + }, + ), + ListTile( + title: Text('Sair da Conta'), + onTap: () { + // Ação para Sair da Conta + }, + ), + ], + ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return IconButton( + iconSize: 35, + onPressed: () => openMenu(context), + icon: Icon(Icons.menu), + color: Color(0xFF015C98), + ); + } +} From f025d5796a646acb9f7783e802deb76bb22d99dd Mon Sep 17 00:00:00 2001 From: Danielle Soares Date: Mon, 9 Dec 2024 18:45:29 -0300 Subject: [PATCH 02/10] feature: menu finalizado, janela navbar funcionando --- catavento/lib/screens/components/menu.dart | 129 ++++++--------------- catavento/lib/screens/dashboard_admin.dart | 54 ++++++++- catavento/pubspec.lock | 24 ++-- catavento/pubspec.yaml | 2 +- 4 files changed, 100 insertions(+), 109 deletions(-) diff --git a/catavento/lib/screens/components/menu.dart b/catavento/lib/screens/components/menu.dart index 8d97090..b797b67 100644 --- a/catavento/lib/screens/components/menu.dart +++ b/catavento/lib/screens/components/menu.dart @@ -1,101 +1,46 @@ import 'package:flutter/material.dart'; -class IconMenu extends StatefulWidget { - const IconMenu({super.key}); - +class Navbar extends StatelessWidget { @override - State createState() { - return IconMenuState(); - } -} - -class IconMenuState extends State { - void openMenu(BuildContext context) { - showModalBottomSheet( - context: context, - builder: (context) { - return Container( - height: 300, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(16), - topRight: Radius.circular(16), + Widget build(BuildContext context) { + return Drawer( + child: Column( + children: [ + UserAccountsDrawerHeader( + accountName: const Text( + 'João das Couves', // depois alterar aqui pra pegar o nome no banco de dados + style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)), + ), + accountEmail: const Text( + 'Administrador', // depois alterar aqui pra pegar o setor no banco de dados + style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)), + ), + currentAccountPicture: CircleAvatar( + backgroundColor: Colors.grey.shade200, + child: const Icon(Icons.person), + ), + decoration: BoxDecoration( + color: Color(0xFFF4D5D7), ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - color: Colors.pink[100], - padding: EdgeInsets.all(16), - child: Row( - children: [ - CircleAvatar( - backgroundColor: Colors.grey, - radius: 25, - ), - SizedBox(width: 16), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'João das Couves', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - Text( - 'Administrador', - style: TextStyle( - fontSize: 14, - color: Colors.grey[700], - ), - ), - ], - ), - ], - ), - ), - ListTile( - title: Text('Demandas'), - onTap: () { - // Ação para Demandas - }, - ), - ListTile( - title: Text('Funcionários'), - onTap: () { - // Ação para Funcionários - }, - ), - ListTile( - title: Text('Produtos'), - onTap: () { - // Ação para Produtos - }, - ), - ListTile( - title: Text('Sair da Conta'), - onTap: () { - // Ação para Sair da Conta - }, - ), - ], + ListTile( + title: const Text('Demandas'), + onTap: () {}, ), - ); - }, - ); - } - - @override - Widget build(BuildContext context) { - return IconButton( - iconSize: 35, - onPressed: () => openMenu(context), - icon: Icon(Icons.menu), - color: Color(0xFF015C98), + ListTile( + title: const Text('Funcionários'), + onTap: () {}, + ), + ListTile( + title: const Text('Produtos'), + onTap: () {}, + ), + ListTile( + title: const Text('Sair da Conta'), + onTap: () {}, + ), + ], + ), ); } } diff --git a/catavento/lib/screens/dashboard_admin.dart b/catavento/lib/screens/dashboard_admin.dart index 1ea20d9..aba6e27 100644 --- a/catavento/lib/screens/dashboard_admin.dart +++ b/catavento/lib/screens/dashboard_admin.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; import 'package:catavento/screens/components/stage_demand.dart'; +import 'package:catavento/screens/components/menu.dart'; import '../services/table_import/table_import.dart'; import '../services/table_import/table_picker.dart'; import 'components/confirmDialog.dart'; @@ -18,9 +19,57 @@ class DashBoardAdmin extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( + drawer: Navbar(), + appBar: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + iconTheme: const IconThemeData( + color: Color(0xFF015C98), + ), + leading: Builder( + builder: (BuildContext context) { + return Padding( + padding: const EdgeInsets.only(left: 20), // Padding aqui + child: Material( + color: Colors.transparent, // Mantém o fundo transparente + child: InkWell( + onTap: () { + Scaffold.of(context).openDrawer(); // Abre o Drawer + }, + child: const Icon( + Icons.menu, + size: 40.0, + color: Color(0xFF015C98), + ), + ), + ), + ); + }, + ), + actions: [ + Padding( + padding: const EdgeInsets.only( + right: 20), // Ajuste o valor conforme necessário + child: TextButton.icon( + icon: const Icon(Icons.history, size: 18.0), + label: const Text("Ver Histórico"), + onPressed: () {}, + style: TextButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: const Color(0xFF015C98), + padding: + const EdgeInsets.symmetric(horizontal: 15, vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ), + ), + ], + ), + extendBodyBehindAppBar: true, body: Stack( children: [ - // Tela de fundo Container( width: double.infinity, height: double.infinity, @@ -33,9 +82,6 @@ class DashBoardAdmin extends StatelessWidget { ), child: Center(child: AddDemandPageAdmin()), ), - - // Icon menu - IconMenu(), ], ), floatingActionButton: FloatingActionButton( diff --git a/catavento/pubspec.lock b/catavento/pubspec.lock index 9d9b40c..bdb3413 100644 --- a/catavento/pubspec.lock +++ b/catavento/pubspec.lock @@ -348,10 +348,10 @@ packages: dependency: "direct main" description: name: intl - sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + sha256: "00f33b908655e606b86d2ade4710a231b802eec6f11e87e4ea3783fd72077a50" url: "https://pub.dev" source: hosted - version: "0.19.0" + version: "0.20.1" jwt_decode: dependency: transitive description: @@ -468,10 +468,10 @@ packages: dependency: transitive description: name: path_provider_foundation - sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 + sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.1" path_provider_linux: dependency: transitive description: @@ -572,10 +572,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab" + sha256: "7f172d1b06de5da47b6264c2692ee2ead20bbbc246690427cdb4fc301cd0c549" url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.3.4" shared_preferences_foundation: dependency: transitive description: @@ -721,10 +721,10 @@ packages: dependency: transitive description: name: url_launcher_ios - sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e + sha256: "16a513b6c12bb419304e72ea0ae2ab4fed569920d1c7cb850263fe3acc824626" url: "https://pub.dev" source: hosted - version: "6.3.1" + version: "6.3.2" url_launcher_linux: dependency: transitive description: @@ -737,10 +737,10 @@ packages: dependency: transitive description: name: url_launcher_macos - sha256: "769549c999acdb42b8bcfa7c43d72bf79a382ca7441ab18a808e101149daf672" + sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2" url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.2.2" url_launcher_platform_interface: dependency: transitive description: @@ -809,10 +809,10 @@ packages: dependency: transitive description: name: win32 - sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2" + sha256: "8b338d4486ab3fbc0ba0db9f9b4f5239b6697fcee427939a40e720cbb9ee0a69" url: "https://pub.dev" source: hosted - version: "5.8.0" + version: "5.9.0" xdg_directories: dependency: transitive description: diff --git a/catavento/pubspec.yaml b/catavento/pubspec.yaml index 7976d89..25c2fd0 100644 --- a/catavento/pubspec.yaml +++ b/catavento/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 supabase_flutter: ^2.8.1 - intl: ^0.19.0 + intl: ^0.20.1 fl_chart: ^0.69.2 file_picker: ^8.1.4 path_provider: ^2.1.5 From 5fea0a04f834d0f3073dd3af0cf90fd86e7f9d95 Mon Sep 17 00:00:00 2001 From: Danielle Soares Date: Sun, 8 Dec 2024 13:13:42 -0300 Subject: [PATCH 03/10] feat: widget menu sem ajustes de responsividade --- catavento/lib/screens/components/menu.dart | 129 +++++++++++++++------ 1 file changed, 92 insertions(+), 37 deletions(-) diff --git a/catavento/lib/screens/components/menu.dart b/catavento/lib/screens/components/menu.dart index b797b67..8d97090 100644 --- a/catavento/lib/screens/components/menu.dart +++ b/catavento/lib/screens/components/menu.dart @@ -1,46 +1,101 @@ import 'package:flutter/material.dart'; -class Navbar extends StatelessWidget { +class IconMenu extends StatefulWidget { + const IconMenu({super.key}); + @override - Widget build(BuildContext context) { - return Drawer( - child: Column( - children: [ - UserAccountsDrawerHeader( - accountName: const Text( - 'João das Couves', // depois alterar aqui pra pegar o nome no banco de dados - style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)), - ), - accountEmail: const Text( - 'Administrador', // depois alterar aqui pra pegar o setor no banco de dados - style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)), - ), - currentAccountPicture: CircleAvatar( - backgroundColor: Colors.grey.shade200, - child: const Icon(Icons.person), - ), - decoration: BoxDecoration( - color: Color(0xFFF4D5D7), + State createState() { + return IconMenuState(); + } +} + +class IconMenuState extends State { + void openMenu(BuildContext context) { + showModalBottomSheet( + context: context, + builder: (context) { + return Container( + height: 300, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), ), ), - ListTile( - title: const Text('Demandas'), - onTap: () {}, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + color: Colors.pink[100], + padding: EdgeInsets.all(16), + child: Row( + children: [ + CircleAvatar( + backgroundColor: Colors.grey, + radius: 25, + ), + SizedBox(width: 16), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'João das Couves', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + Text( + 'Administrador', + style: TextStyle( + fontSize: 14, + color: Colors.grey[700], + ), + ), + ], + ), + ], + ), + ), + ListTile( + title: Text('Demandas'), + onTap: () { + // Ação para Demandas + }, + ), + ListTile( + title: Text('Funcionários'), + onTap: () { + // Ação para Funcionários + }, + ), + ListTile( + title: Text('Produtos'), + onTap: () { + // Ação para Produtos + }, + ), + ListTile( + title: Text('Sair da Conta'), + onTap: () { + // Ação para Sair da Conta + }, + ), + ], ), - ListTile( - title: const Text('Funcionários'), - onTap: () {}, - ), - ListTile( - title: const Text('Produtos'), - onTap: () {}, - ), - ListTile( - title: const Text('Sair da Conta'), - onTap: () {}, - ), - ], - ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return IconButton( + iconSize: 35, + onPressed: () => openMenu(context), + icon: Icon(Icons.menu), + color: Color(0xFF015C98), ); } } From 1d88d8d51cd399730d7e6533c396b71bc713ad82 Mon Sep 17 00:00:00 2001 From: Danielle Soares Date: Mon, 9 Dec 2024 18:45:29 -0300 Subject: [PATCH 04/10] feature: menu finalizado, janela navbar funcionando --- catavento/lib/screens/components/menu.dart | 129 ++++++--------------- 1 file changed, 37 insertions(+), 92 deletions(-) diff --git a/catavento/lib/screens/components/menu.dart b/catavento/lib/screens/components/menu.dart index 8d97090..b797b67 100644 --- a/catavento/lib/screens/components/menu.dart +++ b/catavento/lib/screens/components/menu.dart @@ -1,101 +1,46 @@ import 'package:flutter/material.dart'; -class IconMenu extends StatefulWidget { - const IconMenu({super.key}); - +class Navbar extends StatelessWidget { @override - State createState() { - return IconMenuState(); - } -} - -class IconMenuState extends State { - void openMenu(BuildContext context) { - showModalBottomSheet( - context: context, - builder: (context) { - return Container( - height: 300, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(16), - topRight: Radius.circular(16), + Widget build(BuildContext context) { + return Drawer( + child: Column( + children: [ + UserAccountsDrawerHeader( + accountName: const Text( + 'João das Couves', // depois alterar aqui pra pegar o nome no banco de dados + style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)), + ), + accountEmail: const Text( + 'Administrador', // depois alterar aqui pra pegar o setor no banco de dados + style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)), + ), + currentAccountPicture: CircleAvatar( + backgroundColor: Colors.grey.shade200, + child: const Icon(Icons.person), + ), + decoration: BoxDecoration( + color: Color(0xFFF4D5D7), ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - color: Colors.pink[100], - padding: EdgeInsets.all(16), - child: Row( - children: [ - CircleAvatar( - backgroundColor: Colors.grey, - radius: 25, - ), - SizedBox(width: 16), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'João das Couves', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - Text( - 'Administrador', - style: TextStyle( - fontSize: 14, - color: Colors.grey[700], - ), - ), - ], - ), - ], - ), - ), - ListTile( - title: Text('Demandas'), - onTap: () { - // Ação para Demandas - }, - ), - ListTile( - title: Text('Funcionários'), - onTap: () { - // Ação para Funcionários - }, - ), - ListTile( - title: Text('Produtos'), - onTap: () { - // Ação para Produtos - }, - ), - ListTile( - title: Text('Sair da Conta'), - onTap: () { - // Ação para Sair da Conta - }, - ), - ], + ListTile( + title: const Text('Demandas'), + onTap: () {}, ), - ); - }, - ); - } - - @override - Widget build(BuildContext context) { - return IconButton( - iconSize: 35, - onPressed: () => openMenu(context), - icon: Icon(Icons.menu), - color: Color(0xFF015C98), + ListTile( + title: const Text('Funcionários'), + onTap: () {}, + ), + ListTile( + title: const Text('Produtos'), + onTap: () {}, + ), + ListTile( + title: const Text('Sair da Conta'), + onTap: () {}, + ), + ], + ), ); } } From 46ba18b5fc9182c4d7ed78caefc18bb9c79be80d Mon Sep 17 00:00:00 2001 From: JAugustoM Date: Mon, 9 Dec 2024 19:43:05 -0300 Subject: [PATCH 05/10] =?UTF-8?q?[FIX]=20Altera=C3=A7=C3=B5es=20feitas=20p?= =?UTF-8?q?ara=20refletir=20mudan=C3=A7as=20no=20banco=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catavento/lib/bloc/demanda_bloc.dart | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/catavento/lib/bloc/demanda_bloc.dart b/catavento/lib/bloc/demanda_bloc.dart index f71b427..91e73cd 100644 --- a/catavento/lib/bloc/demanda_bloc.dart +++ b/catavento/lib/bloc/demanda_bloc.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:catavento/typedefs.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -// import 'package:image_picker/image_picker.dart'; +import 'package:intl/intl.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; part 'demanda_event.dart'; @@ -75,15 +75,17 @@ class DemandaBloc extends Bloc { } } + final dataAdicao = DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()); + final demanda = { - 'nomeDemanda': event.nomeDemanda, - 'codigo': event.codigo, + 'nome_demanda': event.nomeDemanda, 'descricao': event.descricao, 'status': event.status, + 'data_adicao': dataAdicao, }; if (fotoUrl != null) { - demanda['imagemUrl'] = fotoUrl; + demanda['image_url'] = fotoUrl; } try { @@ -121,18 +123,15 @@ class DemandaBloc extends Bloc { void _onUpdate(DemandaUpdate event, Emitter emit) async { try { final nomeDemanda = event.nomeDemanda; - final codigo = event.codigo; final descricao = event.descricao; final order = event.order; await supabase.from('demandas').update({ - 'nomeDemanda': nomeDemanda, - 'codigo': codigo, + 'nome_demanda': nomeDemanda, 'descricao': descricao, }).eq('id', event.id); - currentData[order]['nomeDemanda'] = nomeDemanda; - currentData[order]['codigo'] = codigo; + currentData[order]['nome_demanda'] = nomeDemanda; currentData[order]['descricao'] = descricao; final metaData = _countDemandas(); @@ -152,9 +151,9 @@ class DemandaBloc extends Bloc { switch (data['status']) { case '0' || 'Pendente': espera++; - case '1': + case '1' || 'Em fabricação': fabricacao++; - case '2': + case '2' || 'Finalizado': completo++; } } From 3c9058688ae1b4eb6ef45c335180eee1e4f883b2 Mon Sep 17 00:00:00 2001 From: JAugustoM Date: Tue, 10 Dec 2024 16:31:41 -0300 Subject: [PATCH 06/10] =?UTF-8?q?[UP]=20Atualizei=20a=20fun=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20importar=20planilha=20para=20refletir=20as=20mudan?= =?UTF-8?q?=C3=A7as=20do=20banco=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catavento/lib/bloc/demanda_bloc.dart | 3 +- catavento/lib/bloc/demanda_event.dart | 4 +- catavento/lib/bloc/demanda_state.dart | 50 ---------------- catavento/lib/bloc/funcionario_event.dart | 19 +++++++ catavento/lib/constants.dart | 1 + .../services/table_import/table_import.dart | 57 ++++++++++--------- 6 files changed, 54 insertions(+), 80 deletions(-) create mode 100644 catavento/lib/bloc/funcionario_event.dart diff --git a/catavento/lib/bloc/demanda_bloc.dart b/catavento/lib/bloc/demanda_bloc.dart index 91e73cd..54ca329 100644 --- a/catavento/lib/bloc/demanda_bloc.dart +++ b/catavento/lib/bloc/demanda_bloc.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:catavento/constants.dart'; import 'package:catavento/typedefs.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; @@ -75,7 +76,7 @@ class DemandaBloc extends Bloc { } } - final dataAdicao = DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()); + final dataAdicao = DateFormat(timeFormat).format(DateTime.now()); final demanda = { 'nome_demanda': event.nomeDemanda, diff --git a/catavento/lib/bloc/demanda_event.dart b/catavento/lib/bloc/demanda_event.dart index 08f35a2..850da5f 100644 --- a/catavento/lib/bloc/demanda_event.dart +++ b/catavento/lib/bloc/demanda_event.dart @@ -31,7 +31,7 @@ class DemandaDelete extends DemandaEvent { final int id; final int order; - DemandaDelete(this.id, this.order); + const DemandaDelete(this.id, this.order); } class DemandaUpdate extends DemandaEvent { @@ -41,7 +41,7 @@ class DemandaUpdate extends DemandaEvent { final String codigo; final String descricao; - DemandaUpdate( + const DemandaUpdate( this.id, this.order, this.nomeDemanda, diff --git a/catavento/lib/bloc/demanda_state.dart b/catavento/lib/bloc/demanda_state.dart index b4868fa..2a3ba87 100644 --- a/catavento/lib/bloc/demanda_state.dart +++ b/catavento/lib/bloc/demanda_state.dart @@ -26,53 +26,3 @@ class LoadingState extends DemandaState { class FilterState extends DemandaState { FilterState(super.databaseResponse, super.metaData); } - -class PhotoSelectedState extends DemandaState { - final File? fotoSelecionada; - - PhotoSelectedState( - super.databaseResponse, - super.metaData, - this.fotoSelecionada, - ); -} - -class PhotoUploadedState extends DemandaState { - final String fotoUrl; - - PhotoUploadedState( - super.databaseResponse, - super.metaData, - this.fotoUrl, - ); -} - -class PhotoSelectionErrorState extends DemandaState { - final String message; - - PhotoSelectionErrorState( - super.databaseResponse, - super.metaData, - this.message, - ); -} - -class PhotoUploadErrorState extends DemandaState { - final String error; - - PhotoUploadErrorState( - super.databaseResponse, - super.metaData, - this.error, - ); -} - -class PhotoUploadSuccessState extends DemandaState { - final String publicUrl; - - PhotoUploadSuccessState( - super.databaseResponse, - super.metaData, - this.publicUrl, - ); -} diff --git a/catavento/lib/bloc/funcionario_event.dart b/catavento/lib/bloc/funcionario_event.dart new file mode 100644 index 0000000..c88723f --- /dev/null +++ b/catavento/lib/bloc/funcionario_event.dart @@ -0,0 +1,19 @@ +sealed class FuncionarioEvent { + const FuncionarioEvent(); +} + +class FuncionarioCreate extends FuncionarioEvent { + final String nome; + final String setor; + final String email; + final String usuario; + final String senha; + + const FuncionarioCreate( + this.nome, + this.setor, + this.email, + this.usuario, + this.senha, + ); +} diff --git a/catavento/lib/constants.dart b/catavento/lib/constants.dart index d1d11bb..edb4ee6 100644 --- a/catavento/lib/constants.dart +++ b/catavento/lib/constants.dart @@ -2,3 +2,4 @@ const loginRoute = "/login/"; const homeRoute = "/home/"; const supabaseUrl = 'https://gfxmrqhwjqekfzrlurqr.supabase.co'; const supabaseKey = String.fromEnvironment('ANON_KEY'); +const timeFormat = 'yyyy-MM-dd HH:mm:ss'; diff --git a/catavento/lib/services/table_import/table_import.dart b/catavento/lib/services/table_import/table_import.dart index 35968a8..6204dec 100644 --- a/catavento/lib/services/table_import/table_import.dart +++ b/catavento/lib/services/table_import/table_import.dart @@ -1,7 +1,17 @@ import 'dart:io'; +import 'package:catavento/constants.dart'; +import 'package:intl/intl.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:excel/excel.dart'; +const lojasPrioridade = { + 'MAGALU': 'alta', + 'MERCADO LIVRE': 'baixa', + 'SITE': 'media', + 'ELO 7': 'alta', + 'SHOPEE': 'baixa', +}; + Future importExcelToSupabase(String filePath) async { final supabase = Supabase.instance.client; @@ -13,13 +23,8 @@ Future importExcelToSupabase(String filePath) async { final sheet = excel.tables[sheetName]; if (sheet != null) { - excel.link(sheetName, sheet); - - if (sheet.maxColumns == 3) { - sheet.insertColumn(3); - } - var rowId = 0; + var loja = ""; for (var row in sheet.rows) { final rowData = row.map((cell) => cell?.value.toString() ?? '').toList(); @@ -27,30 +32,31 @@ Future importExcelToSupabase(String filePath) async { try { // Evita linhas inválidas if ((rowData[0] != "" && rowData[0] != "null") && - rowData[3] != "1") { - final Map parsedData = { - 'nomeDemanda': rowData[0], - 'funcionario': rowData[1] != "null" ? rowData[1] : "0", - 'status': rowData[3].isNotEmpty == true ? rowData[3] : '0', + (rowData[1] != "" && rowData[1] != "null")) { + final dataAdicao = DateFormat(timeFormat).format(DateTime.now()); + final Map demanda = { + 'nome_demanda': rowData[0], + 'data_adicao': dataAdicao, + 'descricao': 'Bolo normal', + 'status': 'Pendente', }; - // Envia os dados ao Supabase - final response = - await supabase.from('demandas').insert(parsedData); + final codigo = rowData[1]; - if (response.error != null) { - print( - 'Erro ao inserir no Supabase: ${response.error!.message}'); + if (int.tryParse(codigo) != null) { + demanda['produto_id'] = int.parse(codigo); + } + + if (lojasPrioridade.containsKey(loja)) { + demanda['prioridade'] = lojasPrioridade[loja]; } else { - print('Linha ${rowId + 1} enviada com sucesso: $parsedData'); + demanda['prioridade'] = 'media'; } - // Marca a linha como processada - var cell = sheet.cell(CellIndex.indexByColumnRow( - columnIndex: 3, - rowIndex: rowId, - )); - cell.value = TextCellValue('X'); + // Envia os dados ao Supabase + await supabase.from('demandas').insert(demanda); + } else if (rowData[0] != "" && rowData[0] != "null") { + loja = rowData[0].toUpperCase(); } } catch (e) { print('Erro ao processar a linha ${rowId + 1}: $e'); @@ -59,9 +65,6 @@ Future importExcelToSupabase(String filePath) async { } } } - - // Salva o arquivo Excel atualizado - await file.writeAsBytes(excel.encode()!); print('Planilha importada e atualizada com sucesso!'); } catch (e) { print('Erro ao importar a planilha: $e'); From 6321c71ace8429f8ade7a3e5641ce53abb2a8695 Mon Sep 17 00:00:00 2001 From: JAugustoM Date: Wed, 11 Dec 2024 22:21:11 -0300 Subject: [PATCH 07/10] =?UTF-8?q?[FEAT]=20Eventos=20de=20funcion=C3=A1rio?= =?UTF-8?q?=20implementados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catavento/lib/bloc/demanda_bloc.dart | 14 +++++----- catavento/lib/bloc/demanda_state.dart | 20 ++++++------- catavento/lib/bloc/funcionario_event.dart | 34 ++++++++++++++++++++--- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/catavento/lib/bloc/demanda_bloc.dart b/catavento/lib/bloc/demanda_bloc.dart index 54ca329..70078f9 100644 --- a/catavento/lib/bloc/demanda_bloc.dart +++ b/catavento/lib/bloc/demanda_bloc.dart @@ -16,7 +16,7 @@ class DemandaBloc extends Bloc { DemandaEvent get initialState => DemandaLoading(); - DemandaBloc() : super(LoadingState([], {})) { + DemandaBloc() : super(DemandaLoadingState([], {})) { on(_onFilter); on(_onLoading); @@ -49,9 +49,9 @@ class DemandaBloc extends Bloc { final metaData = _countDemandas(); if (newData.isEmpty) { - emit(FilterState(currentData, metaData)); + emit(DemandaFilterState(currentData, metaData)); } else { - emit(FilterState(newData, metaData)); + emit(DemandaFilterState(newData, metaData)); } } @@ -61,7 +61,7 @@ class DemandaBloc extends Bloc { final metaData = _countDemandas(); - emit(LoadingState(currentData, metaData)); + emit(DemandaLoadingState(currentData, metaData)); } void _onCreate(DemandaCreate event, Emitter emit) async { @@ -102,7 +102,7 @@ class DemandaBloc extends Bloc { final metaData = _countDemandas(); - emit(CreateState(currentData, metaData)); + emit(DemandaCreateState(currentData, metaData)); } void _onDelete(DemandaDelete event, Emitter emit) async { @@ -118,7 +118,7 @@ class DemandaBloc extends Bloc { final metaData = _countDemandas(); - emit(DeleteState(currentData, metaData)); + emit(DemandaDeleteState(currentData, metaData)); } void _onUpdate(DemandaUpdate event, Emitter emit) async { @@ -137,7 +137,7 @@ class DemandaBloc extends Bloc { final metaData = _countDemandas(); - emit(UpdateState(currentData, metaData)); + emit(DemandaUpdateState(currentData, metaData)); } catch (e) { print("Erro ao atualizar demanda: $e"); } diff --git a/catavento/lib/bloc/demanda_state.dart b/catavento/lib/bloc/demanda_state.dart index 2a3ba87..e03a5be 100644 --- a/catavento/lib/bloc/demanda_state.dart +++ b/catavento/lib/bloc/demanda_state.dart @@ -7,22 +7,22 @@ sealed class DemandaState { const DemandaState(this.databaseResponse, this.metaData); } -class CreateState extends DemandaState { - CreateState(super.databaseResponse, super.metaData); +class DemandaCreateState extends DemandaState { + DemandaCreateState(super.databaseResponse, super.metaData); } -class DeleteState extends DemandaState { - DeleteState(super.databaseResponse, super.metaData); +class DemandaDeleteState extends DemandaState { + DemandaDeleteState(super.databaseResponse, super.metaData); } -class UpdateState extends DemandaState { - UpdateState(super.databaseResponse, super.metaData); +class DemandaUpdateState extends DemandaState { + DemandaUpdateState(super.databaseResponse, super.metaData); } -class LoadingState extends DemandaState { - LoadingState(super.databaseResponse, super.metaData); +class DemandaLoadingState extends DemandaState { + DemandaLoadingState(super.databaseResponse, super.metaData); } -class FilterState extends DemandaState { - FilterState(super.databaseResponse, super.metaData); +class DemandaFilterState extends DemandaState { + DemandaFilterState(super.databaseResponse, super.metaData); } diff --git a/catavento/lib/bloc/funcionario_event.dart b/catavento/lib/bloc/funcionario_event.dart index c88723f..ddf0149 100644 --- a/catavento/lib/bloc/funcionario_event.dart +++ b/catavento/lib/bloc/funcionario_event.dart @@ -6,14 +6,40 @@ class FuncionarioCreate extends FuncionarioEvent { final String nome; final String setor; final String email; - final String usuario; - final String senha; + final String tipo; const FuncionarioCreate( this.nome, this.setor, this.email, - this.usuario, - this.senha, + this.tipo, ); } + +class FuncionarioDelete extends FuncionarioEvent { + final int id; + final int order; + + const FuncionarioDelete( + this.id, + this.order, + ); +} + +class FuncionarioUpdate extends FuncionarioEvent { + final int id; + final String nome; + final String setor; + final String email; + final String tipo; + + const FuncionarioUpdate( + this.nome, + this.setor, + this.email, + this.tipo, + this.id, + ); +} + +class FuncionarioLoading extends FuncionarioEvent {} From ee47469e1f7bf03bc610a89e9367d080c503c476 Mon Sep 17 00:00:00 2001 From: Mariana Pereira Date: Thu, 12 Dec 2024 09:17:19 -0300 Subject: [PATCH 08/10] [FEAT] crud usuarios Co-authored-by: Gabriela Dourado Co-authored-by: Pedro Freire --- catavento/lib/bloc/usuario_bloc.dart | 122 ++++++++++++++++++ ...cionario_event.dart => usuario_event.dart} | 20 +-- catavento/lib/bloc/usuario_state.dart | 24 ++++ catavento/lib/screens/dashboard_admin.dart | 2 +- 4 files changed, 158 insertions(+), 10 deletions(-) create mode 100644 catavento/lib/bloc/usuario_bloc.dart rename catavento/lib/bloc/{funcionario_event.dart => usuario_event.dart} (54%) create mode 100644 catavento/lib/bloc/usuario_state.dart diff --git a/catavento/lib/bloc/usuario_bloc.dart b/catavento/lib/bloc/usuario_bloc.dart new file mode 100644 index 0000000..d4780b7 --- /dev/null +++ b/catavento/lib/bloc/usuario_bloc.dart @@ -0,0 +1,122 @@ +// import 'dart:io'; + +// import 'package:catavento/bloc/demanda_bloc.dart'; +// import 'package:catavento/constants.dart'; +// import 'package:catavento/bloc/demanda_bloc.dart'; +import 'package:catavento/typedefs.dart'; +// import 'package:flutter/widgets.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/widgets.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +// import 'package:http/http.dart'; +// import 'package:intl/intl.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; + +part 'usuario_event.dart'; +part 'usuario_state.dart'; + +class UsuarioBloc extends Bloc { + final supabase = Supabase.instance.client; + DatabaseResponse currentData = []; + UsuarioEvent get initialState => UsuarioLoading(); + + UsuarioBloc() : super(UsuarioLoadingState([], {})) { + on(_onLoading); + + on(_onCreate); + + on(_onDelete); + + on(_onUpdate); + } + + void _onCreate(UsuarioCreate event, Emitter emit) async { + final usuario = { + 'usuario_nome': event.nome, + 'email': event.email, + 'setor': event.setor, + 'tipo': event.tipo + }; + + try { + final response = await supabase.from('usuarios').insert(usuario).select(); + if (response.isNotEmpty) { + currentData.add(response[0]); + } else { + throw Exception("Erro ao adiciona usuario"); + } + } catch (_) { + throw Exception('Erro ao adicionar usuario'); + } + + final metaData = _countUsuarios(); + + emit(UsuarioCreateState(currentData, metaData)); + } + + void _onDelete(UsuarioDelete event, Emitter emit) async { + try { + final response = + await supabase.from('usuarios').delete().eq('id', event.id).select(); + if (response.isNotEmpty) { + currentData.removeAt(event.order); + } + } catch (e) { + print('Erro ao buscar dados: $e'); + } + + final metaData = _countUsuarios(); + + emit(UsuarioDeleteState(currentData, metaData)); + } + + void _onUpdate(UsuarioUpdate event, Emitter emit) async { + try { + final nome = event.nome; + final setor = event.setor; + final email = event.email; + final tipo = event.tipo; + final id = event.id; + + await supabase.from('usuarios').update({ + 'nome': nome, + 'setor': setor, + 'email': email, + 'tipo': tipo, + }).eq('id', event.id); + + // verificar se pode usar o id + currentData[id]['nome'] = nome; + currentData[id]['setor'] = setor; + currentData[id]['email'] = email; + currentData[id]['tipo'] = tipo; + + final metaData = _countUsuarios(); + + emit(UsuarioUpdateState(currentData, metaData)); + } catch (e) { + print("Erro ao atualizar usuario: $e"); + } + } + + void _onLoading(UsuarioLoading event, Emitter emit) async { + final response = await supabase.from('usuarios').select(); + currentData = response; + + final metaData = _countUsuarios(); + + emit(UsuarioLoadingState(currentData, metaData)); + } + + Map _countUsuarios() { + int numUsuarios = 0; + + for (var usuario in currentData) { + if (usuario["tipo"] == "funcionario") { + numUsuarios++; + } + } + final metaData = {"total": numUsuarios}; + return metaData; + } +} diff --git a/catavento/lib/bloc/funcionario_event.dart b/catavento/lib/bloc/usuario_event.dart similarity index 54% rename from catavento/lib/bloc/funcionario_event.dart rename to catavento/lib/bloc/usuario_event.dart index ddf0149..99162aa 100644 --- a/catavento/lib/bloc/funcionario_event.dart +++ b/catavento/lib/bloc/usuario_event.dart @@ -1,14 +1,16 @@ -sealed class FuncionarioEvent { - const FuncionarioEvent(); +part of 'usuario_bloc.dart'; + +sealed class UsuarioEvent { + const UsuarioEvent(); } -class FuncionarioCreate extends FuncionarioEvent { +class UsuarioCreate extends UsuarioEvent { final String nome; final String setor; final String email; final String tipo; - const FuncionarioCreate( + const UsuarioCreate( this.nome, this.setor, this.email, @@ -16,24 +18,24 @@ class FuncionarioCreate extends FuncionarioEvent { ); } -class FuncionarioDelete extends FuncionarioEvent { +class UsuarioDelete extends UsuarioEvent { final int id; final int order; - const FuncionarioDelete( + const UsuarioDelete( this.id, this.order, ); } -class FuncionarioUpdate extends FuncionarioEvent { +class UsuarioUpdate extends UsuarioEvent { final int id; final String nome; final String setor; final String email; final String tipo; - const FuncionarioUpdate( + const UsuarioUpdate( this.nome, this.setor, this.email, @@ -42,4 +44,4 @@ class FuncionarioUpdate extends FuncionarioEvent { ); } -class FuncionarioLoading extends FuncionarioEvent {} +class UsuarioLoading extends UsuarioEvent {} diff --git a/catavento/lib/bloc/usuario_state.dart b/catavento/lib/bloc/usuario_state.dart new file mode 100644 index 0000000..36f4ef6 --- /dev/null +++ b/catavento/lib/bloc/usuario_state.dart @@ -0,0 +1,24 @@ +part of 'usuario_bloc.dart'; + +sealed class UsuarioState { + final DatabaseResponse databaseResponse; + final Map metaData; + + const UsuarioState(this.databaseResponse, this.metaData); +} + +class UsuarioCreateState extends UsuarioState { + UsuarioCreateState(super.databaseResponse, super.metaData); +} + +class UsuarioDeleteState extends UsuarioState { + UsuarioDeleteState(super.databaseResponse, super.metaData); +} + +class UsuarioUpdateState extends UsuarioState { + UsuarioUpdateState(super.databaseResponse, super.metaData); +} + +class UsuarioLoadingState extends UsuarioState { + UsuarioLoadingState(super.databaseResponse, super.metaData); +} diff --git a/catavento/lib/screens/dashboard_admin.dart b/catavento/lib/screens/dashboard_admin.dart index aba6e27..dda0b5d 100644 --- a/catavento/lib/screens/dashboard_admin.dart +++ b/catavento/lib/screens/dashboard_admin.dart @@ -222,7 +222,7 @@ class QuadroGraficoState extends State { @override Widget build(BuildContext context) { return BlocBuilder( - buildWhen: (previous, current) => current is! FilterState, + buildWhen: (previous, current) => current is! DemandaFilterState, builder: (context, response) { final metaData = response.metaData; From 3edcbb572efa984595b9027b22eb68133ce01560 Mon Sep 17 00:00:00 2001 From: Danielle Soares Date: Thu, 12 Dec 2024 14:09:40 -0300 Subject: [PATCH 09/10] features: rotas do menu --- catavento/lib/constants.dart | 1 + catavento/lib/main.dart | 10 ++- .../components/confirmDialog.dart | 0 .../components/demandCard.dart | 0 .../components/graph.dart | 0 .../components/header.dart | 1 - .../{ => dashboardAdmin}/components/menu.dart | 9 +- .../components/showCustomDialog.dart | 2 +- .../components/stage_demand.dart | 0 .../{ => dashboardAdmin}/dashboard_admin.dart | 10 +-- .../dashboard_funcionarios.dart | 90 +++++++++++++++++++ 11 files changed, 111 insertions(+), 12 deletions(-) rename catavento/lib/screens/{ => dashboardAdmin}/components/confirmDialog.dart (100%) rename catavento/lib/screens/{ => dashboardAdmin}/components/demandCard.dart (100%) rename catavento/lib/screens/{ => dashboardAdmin}/components/graph.dart (100%) rename catavento/lib/screens/{ => dashboardAdmin}/components/header.dart (98%) rename catavento/lib/screens/{ => dashboardAdmin}/components/menu.dart (83%) rename catavento/lib/screens/{ => dashboardAdmin}/components/showCustomDialog.dart (98%) rename catavento/lib/screens/{ => dashboardAdmin}/components/stage_demand.dart (100%) rename catavento/lib/screens/{ => dashboardAdmin}/dashboard_admin.dart (99%) create mode 100644 catavento/lib/screens/dashboardFuncionarios/dashboard_funcionarios.dart diff --git a/catavento/lib/constants.dart b/catavento/lib/constants.dart index edb4ee6..7971c98 100644 --- a/catavento/lib/constants.dart +++ b/catavento/lib/constants.dart @@ -1,5 +1,6 @@ const loginRoute = "/login/"; const homeRoute = "/home/"; +const crudFuncionariosRoute = "/dashboard-admin-crud-funcionarios"; const supabaseUrl = 'https://gfxmrqhwjqekfzrlurqr.supabase.co'; const supabaseKey = String.fromEnvironment('ANON_KEY'); const timeFormat = 'yyyy-MM-dd HH:mm:ss'; diff --git a/catavento/lib/main.dart b/catavento/lib/main.dart index 3ec2960..1f30a43 100644 --- a/catavento/lib/main.dart +++ b/catavento/lib/main.dart @@ -1,6 +1,7 @@ import 'package:catavento/bloc/demanda_bloc.dart'; import 'package:catavento/constants.dart'; -import 'package:catavento/screens/dashboard_admin.dart'; +import 'package:catavento/screens/dashboardAdmin/dashboard_admin.dart'; +import 'package:catavento/screens/dashboardFuncionarios/dashboard_funcionarios.dart'; import 'package:catavento/views/login_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -9,7 +10,8 @@ import 'package:supabase_flutter/supabase_flutter.dart'; void main() { runApp( BlocProvider( - create: (_) => DemandaBloc()..add(DemandaLoading()), // Providing the bloc here + create: (_) => + DemandaBloc()..add(DemandaLoading()), // Providing the bloc here child: MaterialApp( title: "Gestão Catavento", theme: ThemeData( @@ -20,11 +22,13 @@ void main() { routes: { loginRoute: (context) => const LoginView(), homeRoute: (context) => const DashBoardAdmin(), + crudFuncionariosRoute: (context) => const DashBoardFuncionarios(), }, ), ), ); } + class LoadView extends StatelessWidget { const LoadView({super.key}); @@ -51,4 +55,4 @@ class LoadView extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/catavento/lib/screens/components/confirmDialog.dart b/catavento/lib/screens/dashboardAdmin/components/confirmDialog.dart similarity index 100% rename from catavento/lib/screens/components/confirmDialog.dart rename to catavento/lib/screens/dashboardAdmin/components/confirmDialog.dart diff --git a/catavento/lib/screens/components/demandCard.dart b/catavento/lib/screens/dashboardAdmin/components/demandCard.dart similarity index 100% rename from catavento/lib/screens/components/demandCard.dart rename to catavento/lib/screens/dashboardAdmin/components/demandCard.dart diff --git a/catavento/lib/screens/components/graph.dart b/catavento/lib/screens/dashboardAdmin/components/graph.dart similarity index 100% rename from catavento/lib/screens/components/graph.dart rename to catavento/lib/screens/dashboardAdmin/components/graph.dart diff --git a/catavento/lib/screens/components/header.dart b/catavento/lib/screens/dashboardAdmin/components/header.dart similarity index 98% rename from catavento/lib/screens/components/header.dart rename to catavento/lib/screens/dashboardAdmin/components/header.dart index 11bdf59..b931fb2 100644 --- a/catavento/lib/screens/components/header.dart +++ b/catavento/lib/screens/dashboardAdmin/components/header.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; class Header extends StatelessWidget { final String title; diff --git a/catavento/lib/screens/components/menu.dart b/catavento/lib/screens/dashboardAdmin/components/menu.dart similarity index 83% rename from catavento/lib/screens/components/menu.dart rename to catavento/lib/screens/dashboardAdmin/components/menu.dart index b797b67..b81755b 100644 --- a/catavento/lib/screens/components/menu.dart +++ b/catavento/lib/screens/dashboardAdmin/components/menu.dart @@ -25,11 +25,16 @@ class Navbar extends StatelessWidget { ), ListTile( title: const Text('Demandas'), - onTap: () {}, + onTap: () { + Navigator.pushReplacementNamed(context, '/home/'); + }, ), ListTile( title: const Text('Funcionários'), - onTap: () {}, + onTap: () { + Navigator.pushReplacementNamed( + context, '/dashboard-admin-crud-funcionarios'); + }, ), ListTile( title: const Text('Produtos'), diff --git a/catavento/lib/screens/components/showCustomDialog.dart b/catavento/lib/screens/dashboardAdmin/components/showCustomDialog.dart similarity index 98% rename from catavento/lib/screens/components/showCustomDialog.dart rename to catavento/lib/screens/dashboardAdmin/components/showCustomDialog.dart index 1ed3edb..06cd2e7 100644 --- a/catavento/lib/screens/components/showCustomDialog.dart +++ b/catavento/lib/screens/dashboardAdmin/components/showCustomDialog.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:catavento/screens/components/stage_demand.dart'; +import 'package:catavento/screens/dashboardAdmin/components/stage_demand.dart'; class ShowCustomDialog extends StatelessWidget { final String name; diff --git a/catavento/lib/screens/components/stage_demand.dart b/catavento/lib/screens/dashboardAdmin/components/stage_demand.dart similarity index 100% rename from catavento/lib/screens/components/stage_demand.dart rename to catavento/lib/screens/dashboardAdmin/components/stage_demand.dart diff --git a/catavento/lib/screens/dashboard_admin.dart b/catavento/lib/screens/dashboardAdmin/dashboard_admin.dart similarity index 99% rename from catavento/lib/screens/dashboard_admin.dart rename to catavento/lib/screens/dashboardAdmin/dashboard_admin.dart index dda0b5d..ae6ff47 100644 --- a/catavento/lib/screens/dashboard_admin.dart +++ b/catavento/lib/screens/dashboardAdmin/dashboard_admin.dart @@ -5,11 +5,11 @@ import 'package:catavento/bloc/demanda_controller.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; -import 'package:catavento/screens/components/stage_demand.dart'; -import 'package:catavento/screens/components/menu.dart'; -import '../services/table_import/table_import.dart'; -import '../services/table_import/table_picker.dart'; -import 'components/confirmDialog.dart'; +import 'package:catavento/screens/dashboardAdmin/components/stage_demand.dart'; +import 'package:catavento/screens/dashboardAdmin/components/menu.dart'; +import '../../services/table_import/table_import.dart'; +import '../../services/table_import/table_picker.dart'; +import '../dashboardAdmin/components/confirmDialog.dart'; import 'package:image_picker/image_picker.dart'; diff --git a/catavento/lib/screens/dashboardFuncionarios/dashboard_funcionarios.dart b/catavento/lib/screens/dashboardFuncionarios/dashboard_funcionarios.dart new file mode 100644 index 0000000..6daf9bf --- /dev/null +++ b/catavento/lib/screens/dashboardFuncionarios/dashboard_funcionarios.dart @@ -0,0 +1,90 @@ +import 'package:flutter/material.dart'; + +import 'package:catavento/screens/dashboardAdmin/components/menu.dart'; +import '../../services/table_import/table_import.dart'; +import '../../services/table_import/table_picker.dart'; + +class DashBoardFuncionarios extends StatelessWidget { + const DashBoardFuncionarios({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: Navbar(), + appBar: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + iconTheme: const IconThemeData( + color: Color(0xFF015C98), + ), + leading: Builder( + builder: (BuildContext context) { + return Padding( + padding: const EdgeInsets.only(left: 20), // Padding aqui + child: Material( + color: Colors.transparent, // Mantém o fundo transparente + child: InkWell( + onTap: () { + Scaffold.of(context).openDrawer(); // Abre o Drawer + }, + child: const Icon( + Icons.menu, + size: 40.0, + color: Color(0xFF015C98), + ), + ), + ), + ); + }, + ), + actions: [ + Padding( + padding: const EdgeInsets.only( + right: 20), // Ajuste o valor conforme necessário + child: TextButton.icon( + icon: const Icon(Icons.history, size: 18.0), + label: const Text("Ver Histórico"), + onPressed: () {}, + style: TextButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: const Color(0xFF015C98), + padding: + const EdgeInsets.symmetric(horizontal: 15, vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ), + ), + ], + ), + extendBodyBehindAppBar: true, + body: Stack( + children: [ + Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF75CDF3), Color(0xFFB2E8FF)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: Center(), + ), + ], + ), + floatingActionButton: FloatingActionButton( + backgroundColor: Color(0xFF015C98), + onPressed: () async { + final filePath = await tablePicker(); + if (filePath != null) { + await importExcelToSupabase(filePath); + } + }, + child: Icon(Icons.upload_file, color: Colors.white), + ), + ); + } +} From 96bf602cc77602adba5fbf8a17245ecd24c1abe0 Mon Sep 17 00:00:00 2001 From: JAugustoM Date: Thu, 12 Dec 2024 16:37:27 -0300 Subject: [PATCH 10/10] =?UTF-8?q?[UP]=20Mais=20mudan=C3=A7as=20relacionada?= =?UTF-8?q?s=20ao=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();