Skip to content

Commit

Permalink
fix: update API endpoints to use production URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutepraya committed Dec 22, 2024
1 parent 0e0b4cc commit 43463a7
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/authentication/screens/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class _LoginPageState extends State<LoginPage> {
String password = _passwordController.text;

final response = await request
.login("http://127.0.0.1:8000/auth/login/", {
.login("http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/auth/login/", {
'username': username,
'password': password,
});
Expand Down
2 changes: 1 addition & 1 deletion lib/authentication/screens/register.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class _RegisterPageState extends State<RegisterPage> {
// Untuk menyambungkan Android emulator dengan Django pada localhost,
// gunakan URL http://127.0.0.1/
final response = await request.postJson(
"http://127.0.0.1:8000/auth/register/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/auth/register/",
jsonEncode({
"username": username,
"password1": password1,
Expand Down
4 changes: 2 additions & 2 deletions lib/favorite/screens/favorite_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _FavoriteListPageState extends State<FavoriteListPage> {
Future<void> fetchFavorites(CookieRequest request) async {
try {
final response =
await request.get('http://127.0.0.1:8000/api/user/favorites/');
await request.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/favorites/');
if (response != null && response is List) {
setState(() {
allRestaurants = response; // Simpan semua data
Expand All @@ -56,7 +56,7 @@ class _FavoriteListPageState extends State<FavoriteListPage> {
Future<void> deleteFavorite(CookieRequest request, int rumahMakanId) async {
try {
final response = await request.post(
'http://127.0.0.1:8000/api/user/favorites/$rumahMakanId/delete/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/favorites/$rumahMakanId/delete/',
{}, // Data kosong karena parameter dikirim di URL
);
if (response['message'] == 'Favorite deleted successfully') {
Expand Down
2 changes: 1 addition & 1 deletion lib/forum/add_forum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _AddForumFormState extends State<AddForumForm> {
onPressed: () async {
if (_formKey.currentState!.validate()) {
final response = await request.postJson(
"http://127.0.0.1:8000/create-forum-flutter/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/create-forum-flutter/",
jsonEncode(<String, String>{
'title': _title,
'content': _content,
Expand Down
12 changes: 6 additions & 6 deletions lib/forum/discussion_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _DiscussionPageState extends State<DiscussionPage> {
/// 1. Mendapatkan user.id dari endpoint Django /api/current-user/
Future<void> _fetchCurrentUserId() async {
final request = context.read<CookieRequest>();
const url = 'http://127.0.0.1:8000/api/current-user/';
const url = 'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/current-user/';
try {
final response = await request.get(url);
if (response['status'] == 'success') {
Expand All @@ -54,7 +54,7 @@ class _DiscussionPageState extends State<DiscussionPage> {
/// 2. Fungsi GET komentar dari API
Future<List<Comment>> fetchComments(String forumId) async {
final response = await http.get(
Uri.parse('http://127.0.0.1:8000/api/discussion/$forumId/comments/'),
Uri.parse('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/discussion/$forumId/comments/'),
);
if (response.statusCode == 200) {
return commentFromJson(response.body);
Expand All @@ -67,7 +67,7 @@ class _DiscussionPageState extends State<DiscussionPage> {
Future<void> addComment(String content) async {
final request = context.read<CookieRequest>();
final url = Uri.parse(
'http://127.0.0.1:8000/api/discussion/${currentForum.pk}/add_comment/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/discussion/${currentForum.pk}/add_comment/',
);

final response = await request.post(url.toString(), {
Expand Down Expand Up @@ -98,7 +98,7 @@ class _DiscussionPageState extends State<DiscussionPage> {
Future<void> likeComment(String commentId) async {
final request = context.read<CookieRequest>();
final url = Uri.parse(
'http://127.0.0.1:8000/api/discussion/comments/$commentId/like/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/discussion/comments/$commentId/like/',
);

final response = await request.post(url.toString(), {});
Expand All @@ -122,7 +122,7 @@ class _DiscussionPageState extends State<DiscussionPage> {
Future<void> deleteComment(String commentId) async {
final request = context.read<CookieRequest>();
final url = Uri.parse(
'http://127.0.0.1:8000/api/discussion/comments/$commentId/delete/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/discussion/comments/$commentId/delete/',
);

final response = await request.post(url.toString(), {});
Expand Down Expand Up @@ -151,7 +151,7 @@ class _DiscussionPageState extends State<DiscussionPage> {
Future<void> forumDelete(CookieRequest request) async {
try {
final response = await request.post(
'http://127.0.0.1:8000/delete-forum-flutter/${currentForum.pk}/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/delete-forum-flutter/${currentForum.pk}/',
{},
);

Expand Down
2 changes: 1 addition & 1 deletion lib/forum/edit_forum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _EditForumPageState extends State<EditForumPage> {

try {
final response = await request.postJson(
"http://127.0.0.1:8000/edit-forum-flutter/${widget.forum.pk}/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/edit-forum-flutter/${widget.forum.pk}/",
jsonEncode(<String, String>{
'title': _title,
'content': _content,
Expand Down
4 changes: 2 additions & 2 deletions lib/forum/forum_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _ForumScreenState extends State<ForumScreen>
try {
// Replace with your actual API endpoint
final response = await http.get(Uri.parse(
'http://127.0.0.1:8000/api/forum'));
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/forum'));

if (response.statusCode == 200) {
// Parse the JSON data
Expand Down Expand Up @@ -100,7 +100,7 @@ class _ForumScreenState extends State<ForumScreen>
try {
// Replace with your actual search API endpoint if available
final response = await http.get(Uri.parse(
'http://127.0.0.1:8000/api/search-forum/?q=$query')); // Update with your IP or use 10.0.2.2 for Android emulator
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/search-forum/?q=$query')); // Update with your IP or use 10.0.2.2 for Android emulator

if (response.statusCode == 200) {
List<Forum> forums = forumFromJson(response.body);
Expand Down
4 changes: 2 additions & 2 deletions lib/landing/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class _HomeScreenState extends State<HomeScreen> {
bool _isSuperuser = false;

Future<List<Makanan>> fetchMakanan(CookieRequest request) async {
final response = await request.get('http://127.0.0.1:8000/makanan-json/');
final response = await request.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/makanan-json/');

List<Makanan> listMakanan = [];
for (var d in response) {
Expand Down Expand Up @@ -59,7 +59,7 @@ class _HomeScreenState extends State<HomeScreen> {
final request = context.read<CookieRequest>();
try {
final response = await request
.post('http://127.0.0.1:8000/delete-makanan-flutter/$id/', {
.post('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/delete-makanan-flutter/$id/', {
'id': id.toString(),
});

Expand Down
2 changes: 1 addition & 1 deletion lib/landing/widgets/logout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class _LogoutButtonState extends State<LogoutButton> {

void _logout(BuildContext context) async {
final req = context.read<CookieRequest>();
final response = await req.logout("http://127.0.0.1:8000/auth/logout/");
final response = await req.logout("http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/auth/logout/");
String message = response["message"];
if (context.mounted) {
if (response['status']) {
Expand Down
2 changes: 1 addition & 1 deletion lib/poll/screens/create_poll.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _CreatePollScreenState extends State<CreatePollScreen> {
return;
}

const url = 'http://127.0.0.1:8000/polling-makanan/create/';
const url = 'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/create/';

Map<String, dynamic> pollData = {
'question': _questionController.text,
Expand Down
2 changes: 1 addition & 1 deletion lib/poll/screens/polls_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _PollsScreenState extends State<PollsScreen> {
Future<List<Poll>> fetchPolls(CookieRequest request) async {
try {
final response =
await request.get('http://127.0.0.1:8000/polling-makanan/polls/');
await request.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/polls/');

List<dynamic> data = response is String ? jsonDecode(response) : response;

Expand Down
2 changes: 1 addition & 1 deletion lib/poll/screens/result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PollResultScreen extends StatelessWidget {
Future<Poll> fetchPollResults(CookieRequest request, String pollId) async {
try {
final response = await request.get(
'http://127.0.0.1:8000/polling-makanan/polls/$pollId/results/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/polls/$pollId/results/',
);

// Check if response is a String or Map and handle accordingly
Expand Down
4 changes: 2 additions & 2 deletions lib/poll/screens/vote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _VoteScreenState extends State<VoteScreen> {

Future<void> fetchPollData(CookieRequest request) async {
final response = await request.get(
'http://127.0.0.1:8000/polling-makanan/vote/${widget.pollId}/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/vote/${widget.pollId}/',
);

if (response['status'] == 'success') {
Expand All @@ -44,7 +44,7 @@ class _VoteScreenState extends State<VoteScreen> {

Future<void> submitVote(CookieRequest request, String choiceId) async {
final response = await request.post(
'http://127.0.0.1:8000/polling-makanan/vote/${widget.pollId}/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/vote/${widget.pollId}/',
jsonEncode({ // Encode the data as JSON
'choice': choiceId
}),
Expand Down
4 changes: 2 additions & 2 deletions lib/poll/widgets/poll_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class _PollCardState extends State<PollCard> {

try {
final response = await request.post(
'http://127.0.0.1:8000/polling-makanan/delete/${widget.pk}/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/delete/${widget.pk}/',
data,
);

Expand Down Expand Up @@ -75,7 +75,7 @@ class _PollCardState extends State<PollCard> {
Future<void> _togglePollStatus(CookieRequest request, BuildContext context) async {
try {
final response = await request.post(
'http://127.0.0.1:8000/polling-makanan/update/${widget.pk}/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/polling-makanan/update/${widget.pk}/',
{},
);

Expand Down
2 changes: 1 addition & 1 deletion lib/rating/screens/rating_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _RatingFormState extends State<RatingForm> {
onPressed: () async {
if (_rating > 0 && _reviewController.text.isNotEmpty) {
final response = await request.postJson(
"http://127.0.0.1:8000/api/rating-toko/add-flutter/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/rating-toko/add-flutter/",
jsonEncode(<String, dynamic>{
'rating': _rating,
'review': _reviewController.text,
Expand Down
2 changes: 1 addition & 1 deletion lib/rating/screens/rating_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _RatingUpdateState extends State<RatingUpdate> {
onPressed: () async {
if (_rating > 0 && _reviewController.text.isNotEmpty) {
final response = await request.postJson(
"http://127.0.0.1:8000/api/rating-toko/update-flutter/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/rating-toko/update-flutter/",
jsonEncode(<String, dynamic>{
'rating': _rating,
'review': _reviewController.text,
Expand Down
6 changes: 3 additions & 3 deletions lib/rating/screens/rating_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _RatingPageState extends State<RatingPage> {

Future<RumahMakan> _fetchRumahMakan(int id) async {
final resp =
await http.get(Uri.parse('http://127.0.0.1:8000/api/toko/$id/'));
await http.get(Uri.parse('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/toko/$id/'));
if (resp.statusCode == 200) {
final List data = jsonDecode(resp.body);
return RumahMakan.fromJson(data[0]);
Expand All @@ -50,7 +50,7 @@ class _RatingPageState extends State<RatingPage> {
Future<List<RatingWithUser>> _fetchRatingsWithUsers(int id) async {
// 1. Fetch all ratings for this Rumah Makan
final resp =
await http.get(Uri.parse('http://127.0.0.1:8000/api/rating-toko/$id/'));
await http.get(Uri.parse('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/rating-toko/$id/'));
if (resp.statusCode != 200) {
throw Exception('Failed to load Ratings');
}
Expand All @@ -60,7 +60,7 @@ class _RatingPageState extends State<RatingPage> {
final List<RatingWithUser> combined = [];
for (final rating in ratingsList) {
final userRes = await http.get(
Uri.parse('http://127.0.0.1:8000/api/user/${rating.fields.user}/'));
Uri.parse('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/${rating.fields.user}/'));
if (userRes.statusCode == 200) {
final List userData = jsonDecode(userRes.body);
final userName = userData[0]["fields"]["username"] ?? "Unknown";
Expand Down
2 changes: 1 addition & 1 deletion lib/rating/screens/rumahmakan_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _TokoPageState extends State<TokoPage> {

// Function to fetch data from the API
Future<List<RumahMakan>> fetchRumahMakanData() async {
final url = Uri.parse('http://127.0.0.1:8000/api/toko/');
final url = Uri.parse('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/toko/');
final response = await http.get(url);

if (response.statusCode == 200) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rating/widgets/rating_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class RatingCard extends StatelessWidget {

if (shouldDelete == true) {
final response = await request.postJson(
"http://127.0.0.1:8000/api/rating-toko/delete-flutter/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/rating-toko/delete-flutter/",
jsonEncode({
'id_rating': idRating,
'id_rumah_makan': idRumahMakan,
Expand Down
14 changes: 7 additions & 7 deletions lib/store/screens/detail_makanan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
}

Future<Map<String, dynamic>> fetchDetail(CookieRequest req, int id) async {
final response = await req.get('http://127.0.0.1:8000/detail-json/$id/');
final response = await req.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/detail-json/$id/');

return response;
}
Expand All @@ -50,7 +50,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
final request = context.read<CookieRequest>();
try {
final response = await request
.post('http://127.0.0.1:8000/delete-rumahmakan-flutter/$id/', {
.post('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/delete-rumahmakan-flutter/$id/', {
'id': id.toString(),
});

Expand Down Expand Up @@ -332,7 +332,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
} else {
// Tambah ke favorit
final response = await request.post(
'http://127.0.0.1:8000/api/user/favorites/add/$rumahMakanId/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/favorites/add/$rumahMakanId/',
{},
);
if (response['status'] == 'success') {
Expand Down Expand Up @@ -464,7 +464,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
Future<void> checkIfFavorite(CookieRequest request, int rumahMakanId) async {
try {
final response =
await request.get('http://127.0.0.1:8000/api/user/favorites/');
await request.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/favorites/');
if (response != null && response is List) {
setState(() {
// Cek apakah rumah_makan.id ada di daftar favorit
Expand All @@ -487,7 +487,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
Future<void> toggleFavorite(CookieRequest request, int id) async {
try {
final response = await request.post(
'http://127.0.0.1:8000/api/user/favorites/add/$id/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/favorites/add/$id/',
{},
);
if (response['status'] == 'success') {
Expand Down Expand Up @@ -524,7 +524,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
Future<void> deleteFavorite(CookieRequest request, int favoriteId) async {
try {
final response = await request.post(
'http://127.0.0.1:8000/api/user/favorites/$favoriteId/delete/',
'http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/api/user/favorites/$favoriteId/delete/',
{}, // Body kosong karena parameter dikirim di URL
);
if (response['message'] == 'Favorite deleted successfully') {
Expand Down Expand Up @@ -553,7 +553,7 @@ class _DetailRumahMakanState extends State<DetailRumahMakanPage> {
Future<void> fetchDetailAndCheckFavorite(CookieRequest request) async {
try {
final response =
await request.get('http://127.0.0.1:8000/detail-json/${widget.id}/');
await request.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/detail-json/${widget.id}/');
final rumahMakanId = response['rumah_makan']
['id']; // Ambil rumah_makan.id dari respons detail

Expand Down
6 changes: 3 additions & 3 deletions lib/store/screens/edit_makanan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class _EditMakananPageState extends State<EditMakananPage> {

Future<void> _loadMakananDetail(CookieRequest req, int id) async {
try {
final response = await req.get('http://127.0.0.1:8000/get-detail-makanan/$id/');
final response = await req.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/get-detail-makanan/$id/');
setState(() {
_namaController.text = response['name'];
_hargaController.text = response['price'].toString();
Expand All @@ -58,7 +58,7 @@ class _EditMakananPageState extends State<EditMakananPage> {

Future<List<dynamic>> fetchListRumahMakan(CookieRequest req) async {
try {
final response = await req.get('http://127.0.0.1:8000/list-rumahmakan/');
final response = await req.get('http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/list-rumahmakan/');
return response as List<dynamic>;
} catch (e) {
throw Exception("Error fetching rumah makan: $e");
Expand Down Expand Up @@ -207,7 +207,7 @@ class _EditMakananPageState extends State<EditMakananPage> {
return;
}
final response = await request.postJson(
"http://127.0.0.1:8000/edit-detail-makanan/${widget.id}/",
"http://daffa-abhipraya-ngandung.pbp.cs.ui.ac.id/edit-detail-makanan/${widget.id}/",
jsonEncode(<String, dynamic>{
"name": _namaController.text,
"price": int.parse(_hargaController.text),
Expand Down
Loading

0 comments on commit 43463a7

Please sign in to comment.