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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user