feat: Implement subscription management and article saving features

- Added subscriptionPlan and subscriptionExpiresAt fields to UserProfile model.
- Enhanced profile routes to handle subscription state updates and expiration logic.
- Introduced email and password validation during user registration.
- Implemented link stripping for processed articles in the articles route.
- Added save article functionality with appropriate UI feedback in the frontend.
- Updated AccountSettings and FeedContent components to reflect subscription state and saved articles.
- Improved error handling and local storage management for user preferences.
This commit is contained in:
Nicolo-Salvafiorita
2026-05-07 11:56:14 +02:00
parent 249db76341
commit 54ae86a88a
18 changed files with 548 additions and 63 deletions
+5 -1
View File
@@ -9,6 +9,8 @@ export type ProfileResponse = {
email?: string
macroTopics?: string[]
keywords?: string[]
subscriptionPlan?: 'free' | 'pro'
subscriptionExpiresAt?: string | null
}
}
@@ -47,6 +49,7 @@ export const updateProfile = async (data: {
userId?: string
macroTopics?: string[]
keywords?: string[]
subscriptionState?: 'free' | 'pro'
}) => {
// Sync to backend
const backendRes = await authFetch('/api/profile', {
@@ -57,7 +60,7 @@ export const updateProfile = async (data: {
// Opt-in sync to n8n if url is present and userId is known
const n8nUrl = import.meta.env.VITE_N8N_URL;
if (n8nUrl && data.userId && data.macroTopics) {
if (n8nUrl && data.userId) {
try {
await fetch(`${n8nUrl}/briefai/profile/update`, {
method: 'POST',
@@ -66,6 +69,7 @@ export const updateProfile = async (data: {
userId: data.userId,
macroTopics: data.macroTopics,
keywords: data.keywords,
subscriptionState: data.subscriptionState,
})
});
} catch (e) {