Skip to content

Commit dc7048b

Browse files
committed
fix: redeploy + empty state checks
1 parent fcc3be1 commit dc7048b

File tree

7 files changed

+124
-22
lines changed

7 files changed

+124
-22
lines changed

cdk/OpenAPI_Swagger_Definition.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,9 +1298,9 @@ paths:
12981298
- adminAuthorizer: []
12991299
x-amazon-apigateway-integration:
13001300
uri:
1301-
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetMessagesFunction.Arn}/invocations"
1301+
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${adminFunction.Arn}/invocations"
13021302
passthroughBehavior: "when_no_match"
1303-
httpMethod: "GET"
1303+
httpMethod: "POST"
13041304
type: "aws_proxy"
13051305
/admin/get_feedback:
13061306
options:

cdk/lib/amplify-stack.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ import {
139139
});
140140

141141
amplifyApp.addBranch("main");
142-
amplifyApp.addBranch("dev");
143-
144142
amplifyAppAdmin.addBranch("main");
145-
amplifyAppAdmin.addBranch("dev");
146143
}
147144
}

cdk/lib/database-stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class DatabaseStack extends Stack {
2525
/**
2626
* Create the RDS service-linked role if it doesn't exist
2727
*/
28-
new iam.CfnServiceLinkedRole(this, 'RDSServiceLinkedRoleAWS', {
28+
new iam.CfnServiceLinkedRole(this, 'DSARDSServiceLinkedRole', {
2929
awsServiceName: 'rds.amazonaws.com',
3030
});
3131

docs/deploymentGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ cdk bootstrap aws://<YOUR_AWS_ACCOUNT_ID>/<YOUR_ACCOUNT_REGION> --profile <your-
123123
**Deploy CDK stack**
124124
You may run the following command to deploy the stacks all at once. Again, replace `<your-profile-name>` with the appropriate AWS profile used earlier.
125125
```
126-
cdk deploy --all --parameters AmplifyStack:githubRepoName=Digital-Strategy-Assistant --context VpcStackName=DigitalStrategyAssistantVpcStack --context DatabaseStackName=DigitalStrategyAssistantDatabaseStack --context ApiStackName=DigitalStrategyAssistantApiStack --context DbFlowStackName=DigitalStrategyAssistantDBFlowStack --context AmplifyStackName=DigitalStrategyAssistantAmplifyStack --context prefix="Digital-Strategy-Assistant-production" --profile <your-profile-name>
126+
cdk deploy --all --parameters DigitalStrategyAssistantAmplifyStack:githubRepoName=Digital-Strategy-Assistant --context VpcStackName=DigitalStrategyAssistantVpcStack --context DatabaseStackName=DigitalStrategyAssistantDatabaseStack --context ApiStackName=DigitalStrategyAssistantApiStack --context DbFlowStackName=DigitalStrategyAssistantDBFlowStack --context AmplifyStackName=DigitalStrategyAssistantAmplifyStack --context prefix="Digital-Strategy-Assistant-production" --profile <your-profile-name>
127127
```
128128
If you have trouble running the above command, try removing all the \ and run it in one line.
129129

frontendAdmin/src/components/feedback/Feedback.jsx

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ShieldCheck,
88
ChevronDown,
99
ChevronUp,
10+
MessageSquare,
1011
} from "lucide-react";
1112
import {
1213
Collapsible,
@@ -18,6 +19,51 @@ import LoadingScreen from "../Loading/LoadingScreen";
1819
import { fetchAuthSession } from "aws-amplify/auth";
1920
import Session from "../history/Session";
2021

22+
const EmptyFeedbackView = ({ role }) => {
23+
const getRoleIcon = (role) => {
24+
switch (role) {
25+
case "public":
26+
return <Users className="mr-2" />;
27+
case "educator":
28+
return <GraduationCap className="mr-2" />;
29+
case "admin":
30+
return <ShieldCheck className="mr-2" />;
31+
default:
32+
return null;
33+
}
34+
};
35+
36+
const getRoleLabel = (role) => {
37+
switch (role) {
38+
case "public":
39+
return "Student/General Public";
40+
case "educator":
41+
return "Educator/Educational Designer";
42+
case "admin":
43+
return "Post-Secondary Institution Admin/Leader";
44+
default:
45+
return role;
46+
}
47+
};
48+
49+
return (
50+
<div className="w-full">
51+
<div className="flex items-center space-x-4 px-4 py-3 bg-gray-50 rounded-t-lg">
52+
<div className="flex items-center">
53+
{getRoleIcon(role)}
54+
<h2 className="text-lg font-semibold capitalize">
55+
{getRoleLabel(role)} Feedback
56+
</h2>
57+
<span className="ml-2 text-gray-500">(Avg Rating: 0, Total: 0)</span>
58+
</div>
59+
</div>
60+
<div className="p-8 text-center border-b border-x rounded-b-lg bg-white">
61+
<p className="text-gray-500">No feedback available for this role yet</p>
62+
</div>
63+
</div>
64+
);
65+
};
66+
2167
const FeedbackView = ({ role, feedbackData, onFeedbackClick }) => {
2268
const [isOpen, setIsOpen] = useState(true);
2369

@@ -51,6 +97,13 @@ const FeedbackView = ({ role, feedbackData, onFeedbackClick }) => {
5197
return new Date(dateString).toLocaleString();
5298
};
5399

100+
if (
101+
!feedbackData.feedback_details ||
102+
feedbackData.feedback_details.length === 0
103+
) {
104+
return <EmptyFeedbackView role={role} />;
105+
}
106+
54107
return (
55108
<Collapsible open={isOpen} onOpenChange={setIsOpen} className="w-full">
56109
<CollapsibleTrigger asChild className="hover:cursor-pointer">
@@ -133,21 +186,15 @@ const Feedback = () => {
133186

134187
function sortFeedbackByTimestamp(data) {
135188
return data.map((roleData) => {
136-
// Create a new object to avoid mutating the original
137189
const sortedData = { ...roleData };
138-
139-
// Sort feedback_details in descending order (recent first)
140190
if (
141191
sortedData.feedback_details &&
142192
Array.isArray(sortedData.feedback_details)
143193
) {
144194
sortedData.feedback_details = sortedData.feedback_details.sort(
145-
(a, b) => {
146-
return new Date(b.feedback_time) - new Date(a.feedback_time);
147-
}
195+
(a, b) => new Date(b.feedback_time) - new Date(a.feedback_time)
148196
);
149197
}
150-
151198
return sortedData;
152199
});
153200
}
@@ -173,7 +220,6 @@ const Feedback = () => {
173220
}
174221

175222
const data = await response.json();
176-
console.log(data);
177223
const sortedData = sortFeedbackByTimestamp(data);
178224
setFeedbackData(sortedData);
179225
} catch (error) {
@@ -187,7 +233,6 @@ const Feedback = () => {
187233
}, []);
188234

189235
const handleSessionClick = (sessionId) => {
190-
// Find the session object with the matching session_id
191236
for (const roleData of feedbackData) {
192237
const session = roleData.feedback_details.find(
193238
(feedback) => feedback.session_id === sessionId
@@ -217,6 +262,21 @@ const Feedback = () => {
217262
);
218263
}
219264

265+
if (!feedbackData || feedbackData.length === 0) {
266+
return (
267+
<div className="w-full h-[50vh] flex flex-col items-center justify-center p-4 space-y-4">
268+
<MessageSquare className="w-16 h-16 text-gray-300" />
269+
<h2 className="text-xl font-semibold text-gray-600">
270+
No Feedback Available
271+
</h2>
272+
<p className="text-gray-500 text-center max-w-md">
273+
There is currently no feedback from any user roles. Feedback will
274+
appear here once users start providing it.
275+
</p>
276+
</div>
277+
);
278+
}
279+
220280
return (
221281
<div className="w-full mx-auto space-y-4 p-4 overflow-y-auto mb-8">
222282
{feedbackData.map((roleData, index) => (

frontendAdmin/src/components/files/Files.jsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import React, { useState, useEffect } from "react";
44
import { Button } from "@/components/ui/button";
55
import { Input } from "@/components/ui/input";
6-
import { Download } from "lucide-react";
6+
import { Download, FolderIcon } from "lucide-react";
77
import { toast } from "react-toastify";
88
import { fetchAuthSession } from "aws-amplify/auth";
99
import LoadingScreen from "../Loading/LoadingScreen";
10+
1011
const Files = () => {
1112
const [categories, setCategories] = useState([]);
1213
const [filesByCategory, setFilesByCategory] = useState({});
@@ -120,6 +121,22 @@ const Files = () => {
120121
return <LoadingScreen />;
121122
}
122123

124+
// If there are no categories
125+
if (categories.length === 0) {
126+
return (
127+
<div className="w-full h-[50vh] flex flex-col items-center justify-center p-4 space-y-4">
128+
<FolderIcon className="w-16 h-16 text-gray-300" />
129+
<h2 className="text-xl font-semibold text-gray-600">
130+
No Categories Found
131+
</h2>
132+
<p className="text-gray-500 text-center max-w-md">
133+
There are currently no categories available. Categories will appear
134+
here once they are created.
135+
</p>
136+
</div>
137+
);
138+
}
139+
123140
return (
124141
<div className="w-full mx-auto p-4 space-y-6">
125142
{categories.map((category) => (
@@ -129,7 +146,12 @@ const Files = () => {
129146
char.toUpperCase()
130147
)}
131148
</h2>
132-
{filesByCategory[category.category_id] &&
149+
{!filesByCategory[category.category_id] ||
150+
filesByCategory[category.category_id].length === 0 ? (
151+
<div className="p-4 border rounded-lg mb-2 text-center text-gray-500">
152+
No files available in this category
153+
</div>
154+
) : (
133155
filesByCategory[category.category_id].map((file, index) => {
134156
const fileName = file.fileName || file.name;
135157
return (
@@ -165,7 +187,8 @@ const Files = () => {
165187
</div>
166188
</div>
167189
);
168-
})}
190+
})
191+
)}
169192
</div>
170193
))}
171194
</div>

frontendAdmin/src/components/prompt/PreviousPrompts.jsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,30 @@ import {
1010
} from "@/components/ui/card";
1111
import { ChevronLeft, ChevronRight } from "lucide-react";
1212
import { useState } from "react";
13-
export default function PreviousPrompts({ previousPrompts }) {
13+
14+
export default function PreviousPrompts({ previousPrompts = [] }) {
1415
const [currentPage, setCurrentPage] = useState(0);
16+
17+
// If there are no prompts, show empty state
18+
if (!previousPrompts || previousPrompts.length === 0) {
19+
return (
20+
<div className="w-full sm:max-w-xl md:max-w-full mx-auto px-4 py-1">
21+
<Card className="border-0 shadow-none">
22+
<CardHeader>
23+
<CardTitle className="text-base sm:text-md font-semibold text-center">
24+
Previous Prompts
25+
</CardTitle>
26+
</CardHeader>
27+
<CardContent className="py-1 sm:py-2">
28+
<p className="text-center text-gray-500 text-sm">
29+
No previous prompts yet
30+
</p>
31+
</CardContent>
32+
</Card>
33+
</div>
34+
);
35+
}
36+
1537
return (
1638
<div className="w-full sm:max-w-xl md:max-w-full mx-auto px-4 py-1">
1739
<Card className="border-0 shadow-none">
@@ -64,10 +86,10 @@ export default function PreviousPrompts({ previousPrompts }) {
6486
{/* Prompt Content */}
6587
<div className="text-center">
6688
<p className="text-gray-700 mb-1 text-xs sm:text-sm">
67-
{previousPrompts[currentPage].prompt}
89+
{previousPrompts[currentPage]?.prompt || ""}
6890
</p>
6991
<p className="text-[10px] sm:text-xs text-gray-500">
70-
{previousPrompts[currentPage].time_created}
92+
{previousPrompts[currentPage]?.time_created || ""}
7193
</p>
7294
</div>
7395
</CardContent>

0 commit comments

Comments
 (0)