-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: contribute emails feature, fix: loading fix for provider
- Loading branch information
1 parent
5bfd141
commit b87eb31
Showing
19 changed files
with
383 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ENCRYPTION_KEY = | ||
DB_USERNAME = postgres | ||
DB_PASSWORD = | ||
DB_HOST = localhost | ||
DB_DATABASE = postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[ | ||
{ | ||
"email_id": "00001", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00002", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00003", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00004", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00005", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00006", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00007", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00008", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00009", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
}, | ||
{ | ||
"email_id": "00010", | ||
"email_address": "[email protected]", | ||
"added_by": "admin" | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
const String baseUrl = "https://painful-nicolette-muzammildafedaar-245f8a4f.koyeb.app/api"; | ||
const String baseUrl = "http://localhost:3000/api"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// hr_email.dart | ||
class HrEmail { | ||
final String emailAddress; | ||
final String companyName; | ||
final String website; | ||
final String addedBy; | ||
|
||
HrEmail({ | ||
required this.emailAddress, | ||
required this.companyName, | ||
required this.website, | ||
required this.addedBy, | ||
}); | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'email_address': emailAddress, | ||
'company_name': companyName, | ||
'website': website, | ||
'added_by': addedBy, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:udayah/data/constants.dart'; | ||
import 'dart:convert'; | ||
|
||
import 'package:udayah/models/hr_emails.dart'; | ||
|
||
class HrEmailProvider with ChangeNotifier { | ||
bool _isLoading = false; | ||
|
||
bool get isLoading => _isLoading; | ||
|
||
Future<String> addHrEmail(HrEmail hrEmail) async { | ||
_isLoading = true; | ||
notifyListeners(); | ||
|
||
try { | ||
final response = await http.post( | ||
Uri.parse('${baseUrl}/add-hr-email'), | ||
headers: {'Content-Type': 'application/json'}, | ||
body: json.encode(hrEmail.toJson()), | ||
); | ||
|
||
if (response.statusCode == 201) { | ||
// Handle success | ||
final responseData = jsonDecode(response.body); | ||
return responseData['success']; | ||
} else { | ||
// Handle failure | ||
final responseData = jsonDecode(response.body); | ||
String errorMessage = responseData['error']; | ||
throw Exception('Failed: ${errorMessage}'); | ||
} | ||
} catch (error) { | ||
rethrow; | ||
} finally { | ||
_isLoading = false; | ||
notifyListeners(); | ||
} | ||
} | ||
} |
Oops, something went wrong.