@myrjfa/state 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/lib/actions/actions.d.ts +56 -7
- package/dist/lib/actions/actions.d.ts.map +1 -1
- package/dist/lib/actions/actions.js +50 -10
- package/dist/lib/actions/auth.d.ts +12 -2
- package/dist/lib/actions/auth.d.ts.map +1 -1
- package/dist/lib/actions/chat.d.ts +80 -11
- package/dist/lib/actions/chat.d.ts.map +1 -1
- package/dist/lib/actions/chat.js +81 -20
- package/dist/lib/actions/fetcher.d.ts +0 -3
- package/dist/lib/actions/fetcher.d.ts.map +1 -1
- package/dist/lib/actions/fetcher.js +44 -6
- package/dist/lib/{severActions.d.ts → actions/serverActions.d.ts} +1 -1
- package/dist/lib/actions/serverActions.d.ts.map +1 -0
- package/dist/lib/actions/{severActions.js → serverActions.js} +3 -0
- package/dist/lib/actions/user.d.ts +23 -0
- package/dist/lib/actions/user.d.ts.map +1 -0
- package/dist/lib/actions/user.js +55 -0
- package/dist/lib/authSessionManager.d.ts.map +1 -1
- package/dist/lib/authSessionManager.js +14 -7
- package/dist/lib/context/ChatContext.d.ts +7 -0
- package/dist/lib/context/ChatContext.d.ts.map +1 -1
- package/dist/lib/context/ChatContext.js +121 -11
- package/dist/lib/models/blog.d.ts +3 -2
- package/dist/lib/models/blog.d.ts.map +1 -1
- package/dist/lib/models/chat.d.ts +32 -7
- package/dist/lib/models/chat.d.ts.map +1 -1
- package/dist/lib/models/notifications.d.ts +94 -0
- package/dist/lib/models/notifications.d.ts.map +1 -0
- package/dist/lib/models/notifications.js +60 -0
- package/dist/lib/models/opportunities/freelance.d.ts +48 -20
- package/dist/lib/models/opportunities/freelance.d.ts.map +1 -1
- package/dist/lib/models/opportunities/internship.d.ts +48 -20
- package/dist/lib/models/opportunities/internship.d.ts.map +1 -1
- package/dist/lib/models/opportunities/job.d.ts +58 -30
- package/dist/lib/models/opportunities/job.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.d.ts +61 -33
- package/dist/lib/models/opportunities/opportunity.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.js +1 -0
- package/dist/lib/models/opportunities/volunteerJob.d.ts +48 -20
- package/dist/lib/models/opportunities/volunteerJob.d.ts.map +1 -1
- package/dist/lib/models/portfolio.d.ts +2 -2
- package/dist/lib/models/props.d.ts +21 -4
- package/dist/lib/models/props.d.ts.map +1 -1
- package/dist/lib/models/user.d.ts +19 -4
- package/dist/lib/models/user.d.ts.map +1 -1
- package/dist/lib/models/user.js +5 -0
- package/dist/lib/userAtom.d.ts +24 -4
- package/dist/lib/userAtom.d.ts.map +1 -1
- package/dist/lib/userAtom.js +13 -11
- package/dist/lib/utils/fileCompression.d.ts +16 -0
- package/dist/lib/utils/fileCompression.d.ts.map +1 -0
- package/dist/lib/utils/fileCompression.js +56 -0
- package/dist/lib/utils/socialMediaUrl.d.ts +25 -0
- package/dist/lib/utils/socialMediaUrl.d.ts.map +1 -0
- package/dist/lib/utils/socialMediaUrl.js +97 -0
- package/dist/lib/utils.js +4 -4
- package/package.json +3 -1
- package/dist/lib/actions/severActions.d.ts +0 -3
- package/dist/lib/actions/severActions.d.ts.map +0 -1
- package/dist/lib/actions.d.ts +0 -141
- package/dist/lib/actions.d.ts.map +0 -1
- package/dist/lib/actions.js +0 -307
- package/dist/lib/auth.d.ts +0 -150
- package/dist/lib/auth.d.ts.map +0 -1
- package/dist/lib/auth.js +0 -125
- package/dist/lib/fetcher.d.ts +0 -9
- package/dist/lib/fetcher.d.ts.map +0 -1
- package/dist/lib/fetcher.js +0 -84
- package/dist/lib/models/notfications.d.ts +0 -26
- package/dist/lib/models/notfications.d.ts.map +0 -1
- package/dist/lib/models/notfications.js +0 -46
- package/dist/lib/models/volunteerJob.d.ts +0 -398
- package/dist/lib/models/volunteerJob.d.ts.map +0 -1
- package/dist/lib/models/volunteerJob.js +0 -152
- package/dist/lib/severActions.d.ts.map +0 -1
- package/dist/lib/severActions.js +0 -19
- package/dist/lib/socket.d.ts +0 -7
- package/dist/lib/socket.d.ts.map +0 -1
- package/dist/lib/socket.js +0 -22
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes social media input (username or partial URL) into a fully qualified URL.
|
|
3
|
+
* Handles cases where users enter just a username, handle, or partial URL.
|
|
4
|
+
*/
|
|
5
|
+
const PLATFORM_CONFIGS = {
|
|
6
|
+
instagram: {
|
|
7
|
+
baseUrl: 'https://instagram.com/',
|
|
8
|
+
usernameRegex: /^[a-zA-Z0-9._]{1,30}$/,
|
|
9
|
+
urlPattern: /^https?:\/\/(www\.)?instagram\.com\/([a-zA-Z0-9._]+)\/?/,
|
|
10
|
+
buildUrl: (u) => `https://instagram.com/${u}`,
|
|
11
|
+
placeholder: 'pankaj.sharma or https://instagram.com/pankaj.sharma',
|
|
12
|
+
hint: 'Username: letters, numbers, . and _ (max 30 chars)',
|
|
13
|
+
},
|
|
14
|
+
twitter: {
|
|
15
|
+
baseUrl: 'https://x.com/',
|
|
16
|
+
usernameRegex: /^[a-zA-Z0-9_]{1,15}$/,
|
|
17
|
+
urlPattern: /^https?:\/\/(www\.)?(twitter\.com|x\.com)\/([a-zA-Z0-9_]+)\/?/,
|
|
18
|
+
buildUrl: (u) => `https://x.com/${u}`,
|
|
19
|
+
placeholder: 'pankajsharma or https://x.com/pankajsharma',
|
|
20
|
+
hint: 'Username: letters, numbers, _ (max 15 chars)',
|
|
21
|
+
},
|
|
22
|
+
linkedin: {
|
|
23
|
+
baseUrl: 'https://linkedin.com/in/',
|
|
24
|
+
usernameRegex: /^[a-zA-Z0-9-]{3,100}$/,
|
|
25
|
+
urlPattern: /^https?:\/\/(www\.)?linkedin\.com\/in\/([a-zA-Z0-9-]+)\/?/,
|
|
26
|
+
buildUrl: (u) => `https://linkedin.com/in/${u}`,
|
|
27
|
+
placeholder: 'pankaj-sharma or https://linkedin.com/in/pankaj-sharma',
|
|
28
|
+
hint: 'Username: letters, numbers, - (3–100 chars)',
|
|
29
|
+
},
|
|
30
|
+
facebook: {
|
|
31
|
+
baseUrl: 'https://facebook.com/',
|
|
32
|
+
usernameRegex: /^[a-zA-Z0-9.]{5,50}$/,
|
|
33
|
+
urlPattern: /^https?:\/\/(www\.)?facebook\.com\/([a-zA-Z0-9.]+)\/?/,
|
|
34
|
+
buildUrl: (u) => `https://facebook.com/${u}`,
|
|
35
|
+
placeholder: 'pankaj.sharma or https://facebook.com/pankaj.sharma',
|
|
36
|
+
hint: 'Username: letters, numbers, . (5–50 chars)',
|
|
37
|
+
},
|
|
38
|
+
youtube: {
|
|
39
|
+
baseUrl: 'https://youtube.com/@',
|
|
40
|
+
usernameRegex: /^@?[a-zA-Z0-9_-]{3,30}$/,
|
|
41
|
+
urlPattern: /^https?:\/\/(www\.)?youtube\.com\/@?([a-zA-Z0-9_-]+)\/?/,
|
|
42
|
+
buildUrl: (u) => `https://youtube.com/@${u.replace(/^@/, '')}`,
|
|
43
|
+
placeholder: '@pankajsharma or https://youtube.com/@pankajsharma',
|
|
44
|
+
hint: 'Handle: letters, numbers, _ and - (3–30 chars)',
|
|
45
|
+
},
|
|
46
|
+
github: {
|
|
47
|
+
baseUrl: 'https://github.com/',
|
|
48
|
+
usernameRegex: /^[a-zA-Z0-9-]{1,39}$/,
|
|
49
|
+
urlPattern: /^https?:\/\/(www\.)?github\.com\/([a-zA-Z0-9-]+)\/?/,
|
|
50
|
+
buildUrl: (u) => `https://github.com/${u}`,
|
|
51
|
+
placeholder: 'pankaj-sharma or https://github.com/pankaj-sharma',
|
|
52
|
+
hint: 'Username: letters, numbers, - (max 39 chars)',
|
|
53
|
+
},
|
|
54
|
+
googleBusiness: {
|
|
55
|
+
baseUrl: 'https://mybusiness.google.com/',
|
|
56
|
+
usernameRegex: /^[a-zA-Z0-9-]{1,39}$/, // Adjust regex as needed
|
|
57
|
+
urlPattern: /^https?:\/\/(www\.)?mybusiness\.google\.com\/([a-zA-Z0-9-]+)\/?/,
|
|
58
|
+
buildUrl: (u) => `https://mybusiness.google.com/${u}`,
|
|
59
|
+
placeholder: 'pankaj-sharma or https://mybusiness.google.com/pankaj-sharma',
|
|
60
|
+
hint: 'Username: letters, numbers, - (max 39 chars)',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Attempts to normalize a social media input into a full URL.
|
|
65
|
+
* Returns { url, error } — url is the corrected URL or the original input, error is a message if invalid.
|
|
66
|
+
*/
|
|
67
|
+
export function normalizeSocialUrl(platform, input) {
|
|
68
|
+
const cfg = PLATFORM_CONFIGS[platform];
|
|
69
|
+
if (!input || input.trim() === '')
|
|
70
|
+
return { url: '', error: null };
|
|
71
|
+
const trimmed = input.trim();
|
|
72
|
+
// Already a full URL for this platform → extract username and rebuild canonical
|
|
73
|
+
const urlMatch = trimmed.match(cfg.urlPattern);
|
|
74
|
+
if (urlMatch) {
|
|
75
|
+
// Take the captured username group (last capture group)
|
|
76
|
+
const username = urlMatch[urlMatch.length - 1] ?? trimmed;
|
|
77
|
+
return { url: cfg.buildUrl(username), error: null };
|
|
78
|
+
}
|
|
79
|
+
// Looks like a URL for a *different* site or malformed URL
|
|
80
|
+
if (trimmed.startsWith('http://') || trimmed.startsWith('https://') || trimmed.includes('.com/') || trimmed.includes('.net/')) {
|
|
81
|
+
return {
|
|
82
|
+
url: trimmed,
|
|
83
|
+
error: `That doesn't look like a valid ${platform} URL. ${cfg.hint}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Plain username — validate and build URL
|
|
87
|
+
const usernameToTest = trimmed.replace(/^@/, ''); // strip leading @ for youtube/etc
|
|
88
|
+
const testValue = platform === 'youtube' ? trimmed : usernameToTest;
|
|
89
|
+
if (!cfg.usernameRegex.test(testValue)) {
|
|
90
|
+
return {
|
|
91
|
+
url: trimmed,
|
|
92
|
+
error: `Invalid ${platform} username. ${cfg.hint}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return { url: cfg.buildUrl(usernameToTest), error: null };
|
|
96
|
+
}
|
|
97
|
+
export { PLATFORM_CONFIGS };
|
package/dist/lib/utils.js
CHANGED
|
@@ -61,11 +61,11 @@ export function getProgressValue(status) {
|
|
|
61
61
|
export const truncateText = (text, limit) => text.length > limit ? text.substring(0, limit) + "..." : text;
|
|
62
62
|
export const numToStr = (input) => {
|
|
63
63
|
if (input > 1000000000)
|
|
64
|
-
return `${input /
|
|
64
|
+
return `${(input / 1000000000).toFixed(1)}B+`;
|
|
65
65
|
if (input > 1000000)
|
|
66
|
-
return `${input / 1000000}M+`;
|
|
66
|
+
return `${(input / 1000000).toFixed(1)}M+`;
|
|
67
67
|
if (input > 1000)
|
|
68
|
-
return `${input / 1000}K+`;
|
|
68
|
+
return `${(input / 1000).toFixed(1)}K+`;
|
|
69
69
|
return `${input}`;
|
|
70
70
|
};
|
|
71
71
|
export const handleEmail = (email, subject, body) => window.location.href = `mailto:${email}?subject=${subject}&body=${body}`;
|
|
@@ -173,7 +173,7 @@ export function incompleteMVP(user) {
|
|
|
173
173
|
if (!user.pinCode)
|
|
174
174
|
incompletions.push("PinCode");
|
|
175
175
|
if (!user.profilePic)
|
|
176
|
-
incompletions.push("
|
|
176
|
+
incompletions.push("Profile Pic");
|
|
177
177
|
}
|
|
178
178
|
else {
|
|
179
179
|
incompletions.push("Please login first");
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrjfa/state",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Shared state management for myrjfa apps",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
7
9
|
"files": [
|
|
8
10
|
"dist"
|
|
9
11
|
],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"severActions.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/severActions.ts"],"names":[],"mappings":"AAKA,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAKvD;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQtD"}
|
package/dist/lib/actions.d.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Review, reviewTargetType, reviewType } from "./models/review";
|
|
2
|
-
import { tileType } from "./models/tile";
|
|
3
|
-
import { User } from "./models/user";
|
|
4
|
-
export declare function getCurrentUser(): Promise<User | null>;
|
|
5
|
-
export declare function userDetails(query: string, role: "user" | "host" | "admin"): Promise<{
|
|
6
|
-
success: boolean;
|
|
7
|
-
user: User | null;
|
|
8
|
-
message?: string;
|
|
9
|
-
status?: string;
|
|
10
|
-
error?: string;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function subscribeToNewsLetter(email: string): Promise<{
|
|
13
|
-
success: boolean;
|
|
14
|
-
message?: string;
|
|
15
|
-
error?: string;
|
|
16
|
-
}>;
|
|
17
|
-
export declare function toggleUserWishlist(slug: string, tileType: tileType): Promise<{
|
|
18
|
-
success: boolean;
|
|
19
|
-
message?: string;
|
|
20
|
-
error?: string;
|
|
21
|
-
wishlist: string[];
|
|
22
|
-
}>;
|
|
23
|
-
export declare function subscribeToCareersPage(email: string): Promise<{
|
|
24
|
-
success: boolean;
|
|
25
|
-
message?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
}>;
|
|
28
|
-
export declare function contactUs(email: string, name: string, subject: string, message: string): Promise<{
|
|
29
|
-
success: boolean;
|
|
30
|
-
message?: string;
|
|
31
|
-
error?: string;
|
|
32
|
-
}>;
|
|
33
|
-
export declare function saveUserResume(file: File): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
message?: string;
|
|
36
|
-
error?: string;
|
|
37
|
-
user: User | null;
|
|
38
|
-
}>;
|
|
39
|
-
export declare function getUserContact(username: string, role: string): Promise<{
|
|
40
|
-
success: boolean;
|
|
41
|
-
message?: string;
|
|
42
|
-
error?: string;
|
|
43
|
-
details: {
|
|
44
|
-
name: string;
|
|
45
|
-
email: string;
|
|
46
|
-
phoneNumber: string;
|
|
47
|
-
} | null;
|
|
48
|
-
}>;
|
|
49
|
-
export declare function getReviewsById(id: string, type: reviewTargetType): Promise<{
|
|
50
|
-
success: boolean;
|
|
51
|
-
reviews: Review[];
|
|
52
|
-
message?: string;
|
|
53
|
-
error?: string;
|
|
54
|
-
}>;
|
|
55
|
-
export declare function getRatingById(id: string[], type: reviewTargetType): Promise<{
|
|
56
|
-
success: boolean;
|
|
57
|
-
message?: string;
|
|
58
|
-
error?: string;
|
|
59
|
-
ratings: {
|
|
60
|
-
slug: string;
|
|
61
|
-
rating: number;
|
|
62
|
-
ratingCount: number;
|
|
63
|
-
reviewCount: number;
|
|
64
|
-
}[];
|
|
65
|
-
}>;
|
|
66
|
-
export declare function addReview(id: string, type: reviewTargetType, formData: reviewType): Promise<{
|
|
67
|
-
success: boolean;
|
|
68
|
-
review: Review | null;
|
|
69
|
-
message?: string;
|
|
70
|
-
error?: string;
|
|
71
|
-
}>;
|
|
72
|
-
export declare function editReview(id: string, formData: reviewType): Promise<{
|
|
73
|
-
success: boolean;
|
|
74
|
-
review: Review | null;
|
|
75
|
-
message?: string;
|
|
76
|
-
error?: string;
|
|
77
|
-
}>;
|
|
78
|
-
export declare function deleteReview(id: string): Promise<{
|
|
79
|
-
success: boolean;
|
|
80
|
-
message?: string;
|
|
81
|
-
error?: string;
|
|
82
|
-
}>;
|
|
83
|
-
export declare function getAllNotifications(): Promise<{
|
|
84
|
-
success: boolean;
|
|
85
|
-
message: string;
|
|
86
|
-
notifs: {
|
|
87
|
-
_id: string;
|
|
88
|
-
userId: string;
|
|
89
|
-
message: string;
|
|
90
|
-
timestamp: Date;
|
|
91
|
-
read: boolean;
|
|
92
|
-
url?: string | undefined;
|
|
93
|
-
}[];
|
|
94
|
-
unreadCount: number;
|
|
95
|
-
error?: undefined;
|
|
96
|
-
} | {
|
|
97
|
-
success: boolean;
|
|
98
|
-
error: any;
|
|
99
|
-
notifs: never[];
|
|
100
|
-
unreadCount: number;
|
|
101
|
-
message?: undefined;
|
|
102
|
-
}>;
|
|
103
|
-
export declare function getNotifications(limit: number): Promise<{
|
|
104
|
-
success: boolean;
|
|
105
|
-
message: string;
|
|
106
|
-
notifs: {
|
|
107
|
-
_id: string;
|
|
108
|
-
userId: string;
|
|
109
|
-
message: string;
|
|
110
|
-
timestamp: Date;
|
|
111
|
-
read: boolean;
|
|
112
|
-
url?: string | undefined;
|
|
113
|
-
}[];
|
|
114
|
-
unreadCount: number;
|
|
115
|
-
error?: undefined;
|
|
116
|
-
} | {
|
|
117
|
-
success: boolean;
|
|
118
|
-
error: any;
|
|
119
|
-
notifs: never[];
|
|
120
|
-
unreadCount: number;
|
|
121
|
-
message?: undefined;
|
|
122
|
-
}>;
|
|
123
|
-
export declare function toggleNotification(id: string, read: boolean): Promise<{
|
|
124
|
-
success: boolean;
|
|
125
|
-
message: string;
|
|
126
|
-
error?: undefined;
|
|
127
|
-
} | {
|
|
128
|
-
success: boolean;
|
|
129
|
-
error: any;
|
|
130
|
-
message?: undefined;
|
|
131
|
-
}>;
|
|
132
|
-
export declare function toggleAllNotification(read: boolean): Promise<{
|
|
133
|
-
success: boolean;
|
|
134
|
-
message: string;
|
|
135
|
-
error?: undefined;
|
|
136
|
-
} | {
|
|
137
|
-
success: boolean;
|
|
138
|
-
error: any;
|
|
139
|
-
message?: undefined;
|
|
140
|
-
}>;
|
|
141
|
-
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/lib/actions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO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AAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CA2BzJ;AAED,wBAAsB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBhL;AAED,wBAAsB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBzJ;AAED,wBAAsB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAe9G;AAGD,wBAAsB,mBAAmB;;;;;;;;;;;;;;;;;;;GAmBxC;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAmBnD;AAED,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;;;;;;;;GAejE;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,OAAO;;;;;;;;GAexD"}
|
package/dist/lib/actions.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import { del, get, patch, post } from "./fetcher";
|
|
2
|
-
// host
|
|
3
|
-
// user/host
|
|
4
|
-
export async function getCurrentUser() {
|
|
5
|
-
try {
|
|
6
|
-
const endpoint = `/users/me`;
|
|
7
|
-
const data = await get(endpoint);
|
|
8
|
-
// console.log(data.message);
|
|
9
|
-
return data?.data;
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
console.error('Failed to fetch user details: ', error);
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export async function userDetails(query, role) {
|
|
17
|
-
try {
|
|
18
|
-
if (role == "admin")
|
|
19
|
-
role = "user";
|
|
20
|
-
const endpoint = `/${role}s/other-${role}/${query}`;
|
|
21
|
-
const data = await get(endpoint);
|
|
22
|
-
return {
|
|
23
|
-
success: true,
|
|
24
|
-
user: data?.data,
|
|
25
|
-
message: data.message
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error('Failed to fetch user details: ', error);
|
|
30
|
-
return { success: false, user: null, status: error.status, error: error.message };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export async function subscribeToNewsLetter(email) {
|
|
34
|
-
try {
|
|
35
|
-
const endpoint = `/subscription/create`;
|
|
36
|
-
const data = await post(endpoint, { email: email });
|
|
37
|
-
return { success: true, message: data.message };
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
console.error('Error subscribing to newsletter: ', error);
|
|
41
|
-
return {
|
|
42
|
-
success: false,
|
|
43
|
-
error: error.message,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export async function toggleUserWishlist(slug, tileType) {
|
|
48
|
-
try {
|
|
49
|
-
const endpoint = `/users/fav/${tileType}/toggle`;
|
|
50
|
-
const data = await post(endpoint, { id: slug });
|
|
51
|
-
return { success: true, message: data.message, wishlist: data.data };
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
console.error(`Failed to add ${tileType} to wishlist: `, error);
|
|
55
|
-
return {
|
|
56
|
-
success: false,
|
|
57
|
-
error: error.message,
|
|
58
|
-
wishlist: []
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// subscribe
|
|
63
|
-
export async function subscribeToCareersPage(email) {
|
|
64
|
-
try {
|
|
65
|
-
const endpoint = `/subscription/create-job`;
|
|
66
|
-
const data = await post(endpoint, { email: email });
|
|
67
|
-
return { success: true, message: data.message };
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
console.error('Error subscribing to newsletter: ', error);
|
|
71
|
-
return {
|
|
72
|
-
success: false,
|
|
73
|
-
error: error.message,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
export async function contactUs(email, name, subject, message) {
|
|
78
|
-
try {
|
|
79
|
-
const endpoint = `/contactUs`;
|
|
80
|
-
const data = await post(endpoint, { email: email, name: name, subject: subject, message: message });
|
|
81
|
-
return { success: true, message: data.message };
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.error('Error contacting trippeaze: ', error);
|
|
85
|
-
return {
|
|
86
|
-
success: false,
|
|
87
|
-
error: error.message,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// resume
|
|
92
|
-
export async function saveUserResume(file) {
|
|
93
|
-
try {
|
|
94
|
-
const endpoint = `/users/resume-update`;
|
|
95
|
-
const formData = new FormData();
|
|
96
|
-
formData.append('resume', file);
|
|
97
|
-
const data = await patch(endpoint, formData);
|
|
98
|
-
return {
|
|
99
|
-
success: true,
|
|
100
|
-
message: data.message,
|
|
101
|
-
user: data.data,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
return { success: false, error: error.message, user: null };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export async function getUserContact(username, role) {
|
|
109
|
-
try {
|
|
110
|
-
const endpoint = `/${role}s/getUserContact/${username}`;
|
|
111
|
-
const data = await get(endpoint);
|
|
112
|
-
return {
|
|
113
|
-
success: true,
|
|
114
|
-
message: data.message,
|
|
115
|
-
details: data.data,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
return {
|
|
120
|
-
success: false,
|
|
121
|
-
error: error.message,
|
|
122
|
-
details: null,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// rating and reviews
|
|
127
|
-
export async function getReviewsById(id, type) {
|
|
128
|
-
try {
|
|
129
|
-
const endpoint = `/reviews/entity/${id}/${type}`;
|
|
130
|
-
const data = await get(endpoint);
|
|
131
|
-
// const data = { data: sampleReviews, message: "success" };
|
|
132
|
-
return {
|
|
133
|
-
success: true,
|
|
134
|
-
reviews: data.data,
|
|
135
|
-
message: data.message,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
console.error('Failed to get reviews: ', error);
|
|
140
|
-
return {
|
|
141
|
-
success: true,
|
|
142
|
-
reviews: [],
|
|
143
|
-
error: error.message,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
export async function getRatingById(id, type) {
|
|
148
|
-
try {
|
|
149
|
-
const endpoint = `/reviews/entity/${id}`;
|
|
150
|
-
const data = await get(endpoint);
|
|
151
|
-
// const data = {
|
|
152
|
-
// data:
|
|
153
|
-
// [{
|
|
154
|
-
// slug: id[0] ?? "",
|
|
155
|
-
// rating: truncateDecimal(sampleReviews.reduce((acc, review) => acc + review.rating, 0) / sampleReviews.length, 1),
|
|
156
|
-
// ratingCount: sampleReviews.length,
|
|
157
|
-
// reviewCount: 100,
|
|
158
|
-
// }],
|
|
159
|
-
// message: "success"
|
|
160
|
-
// }
|
|
161
|
-
return {
|
|
162
|
-
success: true,
|
|
163
|
-
ratings: data.data,
|
|
164
|
-
message: data.message,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
console.error('Failed to get reviews: ', error);
|
|
169
|
-
return {
|
|
170
|
-
success: true,
|
|
171
|
-
ratings: [],
|
|
172
|
-
error: error.message,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
export async function addReview(id, type, formData) {
|
|
177
|
-
try {
|
|
178
|
-
const endpoint = `/reviews/`;
|
|
179
|
-
const data = await post(endpoint, { reviewee: id, revieweeType: type, rating: formData.rating, comment: formData.comment });
|
|
180
|
-
return {
|
|
181
|
-
success: true,
|
|
182
|
-
review: data.data,
|
|
183
|
-
message: data.message,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
console.error('Failed to get reviews: ', error);
|
|
188
|
-
return {
|
|
189
|
-
success: false,
|
|
190
|
-
review: null,
|
|
191
|
-
error: error.message,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export async function editReview(id, formData) {
|
|
196
|
-
try {
|
|
197
|
-
const endpoint = `/reviews/${id}`;
|
|
198
|
-
const data = await patch(endpoint, { rating: formData.rating, comment: formData.comment });
|
|
199
|
-
return {
|
|
200
|
-
success: true,
|
|
201
|
-
review: data.data,
|
|
202
|
-
message: data.message,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
console.error('Failed to get reviews: ', error);
|
|
207
|
-
return {
|
|
208
|
-
success: false,
|
|
209
|
-
review: null,
|
|
210
|
-
error: error.message,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
export async function deleteReview(id) {
|
|
215
|
-
try {
|
|
216
|
-
const endpoint = `/reviews/${id}`;
|
|
217
|
-
const data = await del(endpoint);
|
|
218
|
-
return {
|
|
219
|
-
success: true,
|
|
220
|
-
message: data.message,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
catch (error) {
|
|
224
|
-
console.error('Failed to get reviews: ', error);
|
|
225
|
-
return {
|
|
226
|
-
success: false,
|
|
227
|
-
error: error.message,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
// notifications
|
|
232
|
-
export async function getAllNotifications() {
|
|
233
|
-
try {
|
|
234
|
-
const endpoint = `/notification?all=true`;
|
|
235
|
-
const data = await get(endpoint);
|
|
236
|
-
return {
|
|
237
|
-
success: true,
|
|
238
|
-
message: data.message,
|
|
239
|
-
notifs: data.data.notifications,
|
|
240
|
-
unreadCount: data.data.unreadCount,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
console.error('Failed to fetch notifications: ', error);
|
|
245
|
-
return {
|
|
246
|
-
success: false,
|
|
247
|
-
error: error.message,
|
|
248
|
-
notifs: [],
|
|
249
|
-
unreadCount: 0,
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
export async function getNotifications(limit) {
|
|
254
|
-
try {
|
|
255
|
-
const endpoint = `/notification?limit=${limit}`;
|
|
256
|
-
const data = await get(endpoint);
|
|
257
|
-
return {
|
|
258
|
-
success: true,
|
|
259
|
-
message: data.message,
|
|
260
|
-
notifs: data.data.notifications,
|
|
261
|
-
unreadCount: data.data.unreadCount,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
console.error('Failed to fetch notifications: ', error);
|
|
266
|
-
return {
|
|
267
|
-
success: false,
|
|
268
|
-
error: error.message,
|
|
269
|
-
notifs: [],
|
|
270
|
-
unreadCount: 0,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
export async function toggleNotification(id, read) {
|
|
275
|
-
try {
|
|
276
|
-
const endpoint = `/notfication/${id}`;
|
|
277
|
-
const data = await patch(endpoint, { isRead: read });
|
|
278
|
-
return {
|
|
279
|
-
success: true,
|
|
280
|
-
message: data.message,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
catch (error) {
|
|
284
|
-
console.error('Failed to toggle notfication: ', error);
|
|
285
|
-
return {
|
|
286
|
-
success: false,
|
|
287
|
-
error: error.message,
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
export async function toggleAllNotification(read) {
|
|
292
|
-
try {
|
|
293
|
-
const endpoint = `/notfication/update/all`;
|
|
294
|
-
const data = await patch(endpoint, { isRead: read });
|
|
295
|
-
return {
|
|
296
|
-
success: true,
|
|
297
|
-
message: data.message,
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
console.error('Failed to toggle all notfications: ', error);
|
|
302
|
-
return {
|
|
303
|
-
success: false,
|
|
304
|
-
error: error.message,
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|