Added some changes to the propagate corporate changes
This commit is contained in:
@@ -90,7 +90,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
if (updatedUser.status || updatedUser.type === "corporate") {
|
if (updatedUser.status || updatedUser.type === "corporate") {
|
||||||
// there's no await as this does not affect the user
|
// there's no await as this does not affect the user
|
||||||
propagateStatusChange(queryId, updatedUser.status);
|
propagateStatusChange(queryId, updatedUser.status);
|
||||||
propagateExpiryDateChanges(queryId, user.subscriptionExpirationDate || null, updatedUser.subscriptionExpirationDate || null);
|
propagateExpiryDateChanges(queryId, user.subscriptionExpirationDate, updatedUser.subscriptionExpirationDate || null);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json({ok: true});
|
res.status(200).json({ok: true});
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const propagateStatusChange = (userId: string, status: UserStatus) =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export const propagateExpiryDateChanges = (userId: string, initialExpiryDate: Date | null, subscriptionExpirationDate: Date | null) =>
|
export const propagateExpiryDateChanges = (userId: string, initialExpiryDate: Date | null | undefined, subscriptionExpirationDate: Date | null) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
getDoc(doc(db, "users", userId))
|
getDoc(doc(db, "users", userId))
|
||||||
.then((docUser) => {
|
.then((docUser) => {
|
||||||
@@ -93,6 +93,7 @@ export const propagateExpiryDateChanges = (userId: string, initialExpiryDate: Da
|
|||||||
.then(async (data) => {
|
.then(async (data) => {
|
||||||
const filtered = data.filter((x) => {
|
const filtered = data.filter((x) => {
|
||||||
if (x === null) return false;
|
if (x === null) return false;
|
||||||
|
if (!x.subscriptionExpirationDate && !initialExpiryDate) return true;
|
||||||
if (x.subscriptionExpirationDate !== initialExpiryDate) return false;
|
if (x.subscriptionExpirationDate !== initialExpiryDate) return false;
|
||||||
return true;
|
return true;
|
||||||
}) as User[];
|
}) as User[];
|
||||||
|
|||||||
Reference in New Issue
Block a user