remove strict mode

This commit is contained in:
Simon Larsen 2022-12-15 13:30:17 +05:30
parent f258860e7f
commit 22f6fa1baa
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
3 changed files with 40 additions and 7 deletions

View File

@ -10,9 +10,7 @@ const root: any = ReactDOM.createRoot(
);
root.render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
);

View File

@ -22,10 +22,45 @@ export class Service extends DatabaseService<Model> {
protected override async onBeforeCreate(
data: CreateBy<Model>
): Promise<OnCreate<Model>> {
if (!data.data.statusPageId) {
throw new BadDataException('Status Page ID is required.');
}
if (data.data.subscriberEmail) {
const subscriber: Model | null = await this.findOneBy({
query: {
statusPageId: data.data.statusPageId,
subscriberEmail: data.data.subscriberEmail
},
select: {
_id: true,
isUnsubscribed: true
},
props: {
isRoot: true,
ignoreHooks: true
}
});
if (subscriber && !subscriber.isUnsubscribed) {
throw new BadDataException("You are already subscribed to this status page.");
}
// if the user is unsubscribed, delete this record and it'll create a new one.
await this.deleteOneBy({
query: {
_id: subscriber?._id!
},
props: {
ignoreHooks: true,
isRoot: true
}
});
}
const statuspage: StatusPage | null =
await StatusPageService.findOneById({
id: data.data.statusPageId,
@ -45,6 +80,8 @@ export class Service extends DatabaseService<Model> {
throw new BadDataException('Status Page not found');
}
data.data.projectId = statuspage.projectId;
return { createBy: data, carryForward: statuspage };

View File

@ -9,9 +9,7 @@ const root: any = ReactDOM.createRoot(
);
root.render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
);