Skip to content

Commit

Permalink
Merge pull request #767 from bounswe/small-adjustments-in-pending-pol…
Browse files Browse the repository at this point in the history
…ls-page

change endpoint, improve visual
  • Loading branch information
simarahmtkhy authored Dec 25, 2023
2 parents fc86f53 + 17078f2 commit 1984cd1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/mobile/lib/models/pollInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class PollInfo {
tags: tags.map((e) => e['name'] as String).toList(),
tagIds: tags.map((e) => e['id'] as String).toList(),
tagColors: tagColorList,
voteCount: json['voteCount'],
voteCount: json['voteCount'] ?? 0,
options: options.map((e) => e['answer'] as String).toList(),
optionIds: options.map((e) => e['id'] as String).toList(),
// TODO vote_count field'i kontrol edilecek
Expand Down
1 change: 1 addition & 0 deletions app/mobile/lib/services/pollRequestService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PollRequestService {
// Prepare the data to send to the API
final Map<String, dynamic> data = {
'question': pollData.question,
'description': pollData.question,
'options': pollData.options,
'image_urls': imageUrlsString,
'tags': pollData.tags,
Expand Down
7 changes: 3 additions & 4 deletions app/mobile/lib/services/profilePagePollsService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ class ProfilePagePollsService {
}

static Future<List<PollInfo>> getPendingPolls(String userId) async {
String pollsEndpoint = "/poll?creatorId=$userId";
String pollsEndpoint = "/poll/my-polls/pending";
try {
// Perform the GET request with the userId as a query parameter
Response response = await ApiService.dio.get(pollsEndpoint);
// Map the response data to PollInfo objects
var polls = List.from(response.data)
.map((e) => PollInfo.fromJson(e))
.where((element) => element.isPending);
var polls = List.from(response.data).map((e) => PollInfo.fromJson(e));
// .where((element) => element.isPending);

var pollsList = polls.toList();
// TODO
Expand Down
3 changes: 3 additions & 0 deletions app/mobile/lib/view/profilePage/pendingPollView.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mobile_app/models/pollInfo.dart';
import 'package:mobile_app/view/constants.dart';
import 'package:mobile_app/view/moderatorHomePage/requestViewHome.dart';
import 'package:mobile_app/view/pollView/postOptionWidget.dart';

Expand Down Expand Up @@ -44,6 +45,8 @@ class _PendingPollViewState extends State<PendingPollView> {
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(height: 1, color: gray),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
Expand Down

0 comments on commit 1984cd1

Please sign in to comment.