Skip to content

Commit

Permalink
Merge pull request #367 from jaivsh/second
Browse files Browse the repository at this point in the history
Adding API for sending user queries through contact us page
  • Loading branch information
avinashkranjan authored Jul 27, 2023
2 parents ab7d1d5 + d769c3d commit fac6c1d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
45 changes: 40 additions & 5 deletions lib/screens/contact_us_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';

import 'package:http/http.dart' as http;
import '../models/users.dart';
import '../services/user_info_services.dart';

Expand All @@ -12,9 +13,26 @@ class ContactUsScreen extends StatefulWidget {

class _ContactUsScreenState extends State<ContactUsScreen> {
String question = 'How can we help?';
String email = '';



@override
Widget build(BuildContext context) {
final userInfoProvider =
Provider.of<UserInfoServices>(context, listen: false);

Users? currentUser = userInfoProvider.user;
if(currentUser == null) {
email = '';
}
else {
email = currentUser.email.toString();
}




return Scaffold(
appBar: AppBar(elevation: 0,backgroundColor: Colors.transparent,

Expand Down Expand Up @@ -85,11 +103,28 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
SizedBox(height: 16.0),
ElevatedButton(
child: Text('Send'),
onPressed: () {
onPressed: () async {
DateTime now = DateTime.now();
String formattedDate = DateFormat('kk:mm:ss \n EEE d MMM').format(now);
// Send the question to your support team
// Implement your logic here
String dateinsert = DateFormat('kk:mm:ss \n EEE d MMM').format(now);

String queryString = "?query=$question&email=$email&timestamp=$dateinsert";
String finalquery = 'https://script.google.com/macros/s/AKfycbwbXfW9AeABuhhKiJAnUs_ZCQ-6x4OJECSgq7_xCTcNpbds45IUy_d6mlKrLsouzweJPQ/exec'+queryString;
var finalURI = Uri.parse(finalquery);
var response = await http.get(finalURI);
if (response.statusCode == 200) {
print('User query published successfully!');
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("User query published successfully!"),
));

}
else {
print('User query failed to be published!');
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("User query failed to be published!"),
));
}

},
),])))])]);
},
Expand Down
8 changes: 7 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ packages:
source: hosted
version: "0.12.0"
http:
dependency: transitive
dependency: "direct main"
description:
name: http
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
Expand Down Expand Up @@ -970,6 +970,11 @@ packages:
description:
name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206

url: "https://pub.dev"
source: hosted
version: "0.4.16"

url: "https://pub.dev"
source: hosted
version: "0.4.16"
Expand All @@ -981,6 +986,7 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.2"

typed_data:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ dependencies:
settings_ui:
external_app_launcher:
open_url:

http: ^0.13.6

flutter_local_notifications: ^15.1.0+1


dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit fac6c1d

Please sign in to comment.