Skip to content

Commit

Permalink
Merge pull request #390 from COS301-SE-2024/hotfix/fetch_issues
Browse files Browse the repository at this point in the history
(PR) Fixing Fetching Issues Error
  • Loading branch information
hlokomani authored Oct 18, 2024
2 parents 07b4eb5 + 52d07f5 commit 89ebc5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
7 changes: 4 additions & 3 deletions backend/src/modules/issues/repositories/issueRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export default class IssueRepository {
.ilike("location.district", `%${location.district}%`);
}

let category_id = 0;
if (category) {
const categoryId = await this.categoryRepository.getCategoryId(category);
query = query.eq("category_id", categoryId);
category_id = await this.categoryRepository.getCategoryId(category);
query = query.eq("category_id", category_id);
}

const { data, error } = await query;
Expand Down Expand Up @@ -127,7 +128,7 @@ export default class IssueRepository {
: null;

const days =
forecastData && !forecastError ? formatTime(forecastData) : "6 days";
forecastData && !forecastError ? formatTime(forecastData) : `${(category_id % 2) + 6} days`;
const information = !issue.resolved_at
? `This issue may take around ${days} to be resolved based on similar issues in this area.`
: "This issue has already been resolved.";
Expand Down
24 changes: 16 additions & 8 deletions frontend/components/Feed/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ const Feed: React.FC<UserContextType> = ({ user }) => {
"Content-Type": "application/json",
};

if (user) {
headers.Authorization = `Bearer ${user.access_token}`;
}
// if (user) {
// headers.Authorization = `Bearer ${user.access_token}`;
// }

const requestBody: RequestBody = {
from,
Expand Down Expand Up @@ -168,13 +168,21 @@ const Feed: React.FC<UserContextType> = ({ user }) => {

const EmptyIndicator = () => (
<ErrorPage
message="No reports available in this area."
error="It looks like there are no recent reports for your selected location. Feel free to submit a report if you’re experiencing any issues, or check back later for updates."
showReloadButton={true}
message="No reports available in this area."
error="It looks like there are no recent reports for your selected location. Feel free to submit a report if you’re experiencing any issues, or check back later for updates."
showReloadButton={true}
/>
);

const FailedIndicator = () => (
// const FailedIndicator = () => (
// <ErrorPage
// message="Failed to fetch issues."
// error="It seems there are no issues to display. Please refresh the page or try login."
// showReloadButton={true}
// />
// );

const FailedLazyIndicator = () => (
<div className="flex justify-center items-center h-32">
<h3 className="text-muted-foreground">Failed to fetch issues</h3>
</div>
Expand Down Expand Up @@ -264,7 +272,7 @@ const Feed: React.FC<UserContextType> = ({ user }) => {
onResolveIssue={handleResolveIssue}
/>
)}
Failed={FailedIndicator}
Failed={FailedLazyIndicator}
Loading={LoadingIndicator}
Empty={EmptyIndicator}
parentId={scrollId}
Expand Down

0 comments on commit 89ebc5e

Please sign in to comment.