Skip to content

Commit 92c63a5

Browse files
YuvalYuval
authored andcommitted
Refactor components and context for improved geolocation handling and UI updates
- Removed unused image import and adjusted layout in FirstTimeQuestions component. - Updated ActionIcon styles for better text handling and responsiveness. - Modified AddressDetailsSection for consistent spacing and text styles. - Changed BottomNavBar and DrawerMenu labels from "מועדפים" to "שמורים". - Refactored useGeolocation hook to utilize GeoContext for state management. - Added new API function getMySubscriptions to fetch user subscriptions. - Introduced SubscriptionItem type for better type safety in notifications. - Created SavedAddressCard component for displaying saved addresses. - Implemented GeoContext for centralized geolocation state management.
1 parent d53f835 commit 92c63a5

18 files changed

Lines changed: 647 additions & 250 deletions

File tree

01-Database/GroundShareDB.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,31 @@ BEGIN
838838
END
839839
GO
840840

841+
CREATE OR ALTER PROCEDURE sp_GetUserSubscriptions
842+
@User_ID INT
843+
AS
844+
BEGIN
845+
SET NOCOUNT ON;
846+
SELECT
847+
ns.Location_ID,
848+
ns.Created_At AS Subscribed_At,
849+
c.City_Name,
850+
s.Street_Name,
851+
l.House_Number,
852+
l.Latitude,
853+
l.Longitude,
854+
(SELECT COUNT(1) FROM event e
855+
WHERE e.Location_ID = ns.Location_ID
856+
AND e.EventStatus = N'קורה') AS Active_Event_Count
857+
FROM notification_subscription ns
858+
INNER JOIN location l ON ns.Location_ID = l.Location_ID
859+
INNER JOIN city c ON l.City_ID = c.City_ID
860+
LEFT JOIN streets s ON l.Street_ID = s.Street_ID
861+
WHERE ns.User_ID = @User_ID
862+
ORDER BY ns.Created_At DESC;
863+
END
864+
GO
865+
841866
-- ---- ONBOARDING ----
842867

843868
CREATE OR ALTER PROCEDURE sp_SaveOnboarding

02-Server/Controllers/NotificationsController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ public class NotificationsController : ControllerBase
1515
private readonly NotificationsDAL _dal;
1616
public NotificationsController(NotificationsDAL dal) { _dal = dal; }
1717

18+
[HttpGet]
19+
public async Task<IActionResult> GetMySubscriptions()
20+
{
21+
int userId = GetUserId();
22+
var subscriptions = await _dal.GetUserSubscriptionsAsync(userId);
23+
return Ok(subscriptions);
24+
}
25+
1826
[HttpGet("check/{locationId}")]
1927
public async Task<IActionResult> Check(int locationId)
2028
{

02-Server/DAL/Interfaces/INotificationsDAL.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public interface INotificationsDAL
44
{
55
Task<bool> IsSubscribedAsync(int userId, int locationId);
66
Task<bool> ToggleNotificationAsync(int userId, int locationId);
7+
Task<List<Dictionary<string, object>>> GetUserSubscriptionsAsync(int userId);
78

89
Task UpsertDeviceTokenAsync(int userId, string token, string platform);
910
Task DeleteDeviceTokenAsync(string token);

02-Server/DAL/NotificationsDAL.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ public async Task<bool> ToggleNotificationAsync(int userId, int locationId)
3333
return Convert.ToInt32(await cmd.ExecuteScalarAsync()) == 1;
3434
}
3535

36+
public async Task<List<Dictionary<string, object>>> GetUserSubscriptionsAsync(int userId)
37+
{
38+
using SqlConnection con = await ConnectAsync();
39+
var p = new Dictionary<string, object> { { "@User_ID", userId } };
40+
SqlCommand cmd = CreateSP("sp_GetUserSubscriptions", con, p);
41+
42+
var list = new List<Dictionary<string, object>>();
43+
using SqlDataReader reader = await cmd.ExecuteReaderAsync();
44+
while (await reader.ReadAsync())
45+
{
46+
var row = new Dictionary<string, object>();
47+
for (int i = 0; i < reader.FieldCount; i++)
48+
row[reader.GetName(i)] = reader.IsDBNull(i) ? null! : reader.GetValue(i);
49+
list.Add(row);
50+
}
51+
return list;
52+
}
53+
3654
public async Task UpsertDeviceTokenAsync(int userId, string token, string platform)
3755
{
3856
using SqlConnection con = await ConnectAsync();

03-Client/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
"type": "module",
66
"scripts": {
77
"build": "vite build",
8+
"build:dev": "vite build --mode development",
89
"dev": "vite",
910
"test": "vitest run",
1011
"test:watch": "vitest",
1112
"build:android": "vite build && cap sync android",
13+
"build:android:dev": "vite build --mode development && cap sync android",
1214
"run:android": "vite build && cap sync android && cap run android",
15+
"run:android:dev": "vite build --mode development && cap sync android && cap run android",
1316
"open:android": "vite build && cap sync android && cap open android"
1417
},
1518
"dependencies": {

03-Client/src/app/App.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { RouterProvider } from "react-router";
22
import { router } from "./routes";
3+
import { GeoProvider } from "./context/GeoContext";
34
import { OfflineBanner } from "./components/shared/OfflineBanner";
45
import { InstallBanner } from "./components/shared/InstallBanner";
56

67
export default function App() {
78
return (
8-
<div className="size-full flex items-center justify-center bg-gray-200">
9-
{/* On mobile: fill viewport. On desktop: fixed phone preview. */}
10-
<div className="w-full h-dvh md:w-[412px] md:h-[915px] md:max-h-screen overflow-hidden relative bg-white md:shadow-2xl">
11-
<OfflineBanner />
12-
<RouterProvider router={router} />
13-
<InstallBanner />
9+
<GeoProvider>
10+
<div className="size-full flex items-center justify-center bg-gray-200">
11+
{/* On mobile: fill viewport. On desktop: fixed phone preview. */}
12+
<div className="w-full h-dvh md:w-[412px] md:h-[915px] md:max-h-screen overflow-hidden relative bg-white md:shadow-2xl">
13+
<OfflineBanner />
14+
<RouterProvider router={router} />
15+
<InstallBanner />
16+
</div>
1417
</div>
15-
</div>
18+
</GeoProvider>
1619
);
1720
}

0 commit comments

Comments
 (0)