Skip to content

Commit f131afa

Browse files
Merge pull request #42 from foundersandcoders/mobile
Mobile mode & Help panel, welcome panel
2 parents 1ad438d + 9cae85a commit f131afa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2760
-2207
lines changed

GRATITUDE_API.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Gratitude API
2+
3+
## Overview
4+
5+
The Gratitude feature allows users to send appreciation messages to others when marking actions as completed. This functionality enhances the collaborative nature of the application by enabling users to acknowledge contributions and express thanks to colleagues, managers, or team members.
6+
7+
## API Endpoints
8+
9+
### 1. Send Gratitude Email Endpoint
10+
11+
- **URL**: `/api/gratitude/send`
12+
- **Method**: POST
13+
- **Content-Type**: application/json
14+
- **Credentials**: include
15+
- **Request Body**:
16+
```json
17+
{
18+
"statementId": "string", // ID of the statement containing the action
19+
"actionId": "string", // ID of the specific action
20+
"message": "string", // The gratitude message to send
21+
"recipientEmail": "string", // Email address of the recipient
22+
"recipientName": "string" // Optional name of the recipient
23+
}
24+
```
25+
- **Expected Response**:
26+
27+
- Success:
28+
```json
29+
{
30+
"success": true,
31+
"message": "Gratitude email sent successfully",
32+
"id": "string" // Unique ID for the sent message (for tracking)
33+
}
34+
```
35+
- Error:
36+
```json
37+
{
38+
"success": false,
39+
"message": "Error description"
40+
}
41+
```
42+
43+
- **Backend Behavior**:
44+
- Validate all inputs, especially the email format
45+
- Compose an email using an appropriate template
46+
- Include the gratitude message in the email
47+
- Send the email to the recipient
48+
- Return success confirmation with a unique ID
49+
- Handle failures gracefully with meaningful error messages
50+
51+
### 2. Mark Gratitude Sent Endpoint
52+
53+
- **URL**: `/api/gratitude/mark/{statementId}/{actionId}`
54+
- **Method**: POST
55+
- **Content-Type**: application/json
56+
- **Credentials**: include
57+
- **URL Parameters**:
58+
- `statementId`: The ID of the statement
59+
- `actionId`: The ID of the action
60+
- **Request Body**:
61+
```json
62+
{
63+
"message": "string" // The gratitude message that was sent
64+
}
65+
```
66+
- **Expected Response**:
67+
68+
- Success: Return the updated Action object:
69+
```json
70+
{
71+
"id": "string", // Action ID
72+
"creationDate": "string", // ISO date string
73+
"byDate": "string", // ISO date string (can be empty)
74+
"action": "string", // Action text
75+
"completed": true, // Should be true for gratitude to be sent
76+
"gratitudeSent": true, // Must be set to true
77+
"gratitudeMessage": "string", // The message that was sent
78+
"gratitudeSentDate": "string" // Current timestamp in ISO format
79+
}
80+
```
81+
- Error:
82+
```json
83+
{
84+
"success": false,
85+
"message": "Error description"
86+
}
87+
```
88+
89+
- **Backend Behavior**:
90+
- Verify the statement and action exist
91+
- Update the action record with gratitude information
92+
- Set the `gratitudeSent` flag to true
93+
- Store the gratitude message
94+
- Record the current timestamp as the sent date
95+
- Return the complete updated action object
96+
97+
## Feature Flow
98+
99+
The Gratitude feature flow in the LIFT frontend consists of the following steps:
100+
101+
1. **Initiating Gratitude**
102+
103+
- User completes an action
104+
- User clicks the dropdown menu for the action
105+
- User selects "Send gratitude" option
106+
- System displays the GratitudeModal
107+
108+
2. **Composing the Message**
109+
110+
- User enters recipient email
111+
- User enters gratitude message
112+
- System validates inputs
113+
- User submits the form
114+
115+
3. **Sending the Gratitude**
116+
117+
- System calls the `/api/gratitude/send` endpoint
118+
- Email is sent to the recipient
119+
- System calls the `/api/gratitude/mark/{statementId}/{actionId}` endpoint
120+
- Action is updated with gratitude information
121+
122+
4. **Visual Feedback**
123+
- System displays success confirmation
124+
- Action UI updates to show gratitude was sent
125+
- Dropdown menu options are updated
126+
- Tooltips display gratitude information
127+
128+
## Mock Implementation
129+
130+
For development and testing purposes, the frontend includes a mock implementation:
131+
132+
- Controlled by the environment variable `VITE_MOCK_EMAIL_SENDING`
133+
- When enabled, simulates the API responses without real backend
134+
- Logs details to console for debugging
135+
- Includes realistic delays to simulate network latency
136+
137+
To use the mock implementation:
138+
139+
1. Set `VITE_MOCK_EMAIL_SENDING=true` in your environment
140+
2. The frontend will use the mock implementations in `gratitudeApi.ts`
141+
3. No actual emails will be sent, but the UI will behave as if they were
142+
143+
## Security Considerations
144+
145+
When implementing the Gratitude API endpoints, consider the following security aspects:
146+
147+
1. **Input Validation**
148+
149+
- Validate email formats
150+
- Sanitize message content to prevent injection
151+
- Validate that IDs exist and belong to the requesting user
152+
153+
2. **Authorization**
154+
155+
- Ensure users can only send gratitude for actions they have access to
156+
- Implement proper authentication checks
157+
- Verify user permissions before processing requests
158+
159+
3. **Rate Limiting**
160+
161+
- Implement rate limiting to prevent abuse
162+
- Consider limits like maximum 10 emails per hour per user
163+
- Add exponential backoff for repeated failures
164+
165+
4. **Email Security**
166+
167+
- Ensure proper email headers
168+
- Prevent header injection
169+
- Include unsubscribe options
170+
- Follow email sending best practices
171+
172+
5. **Logging**
173+
- Log all gratitude emails sent for auditing
174+
- Track failures and errors
175+
- Monitor for unusual patterns
176+
177+
## Testing the Integration
178+
179+
When testing the integration between frontend and backend:
180+
181+
1. **Verify Email Sending**
182+
183+
- Test with valid and invalid email addresses
184+
- Confirm emails are received by recipients
185+
- Check email content and formatting
186+
187+
2. **Test State Updates**
188+
189+
- Ensure action records are properly updated
190+
- Verify timestamps are accurate
191+
- Confirm UI updates correctly after sending
192+
193+
3. **Error Handling**
194+
195+
- Test with various error scenarios
196+
- Verify user-friendly error messages
197+
- Ensure system recovers gracefully from failures
198+
199+
4. **Edge Cases**
200+
- Test with very long messages
201+
- Test with special characters
202+
- Test with high volume of requests
203+
204+
## Conclusion
205+
206+
The Gratitude API enhances the LIFT application by enabling users to express appreciation for completed actions. When implemented correctly, it creates a positive feedback loop within teams and reinforces collaborative behaviors.
207+
208+
This document provides a comprehensive guide for backend developers to implement the required endpoints and behaviors to support the Gratitude feature in the LIFT frontend application.

MIGRATION_GUIDE.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

allcode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
".DS_Store",
3434
".aider.chat.history.md",
3535
".aider.input.history",
36+
"MAGIC_LINK_AUTH.md",
37+
"CLADE.md",
38+
"GRATITUDE_API.md",
3639
}
3740

3841

docs/IGT DPIA Screening Tool.docx

-87.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)