@carlonicora/nextjs-jsonapi 1.25.1 → 1.26.0
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/{BlockNoteEditor-UNVKGZ2G.mjs → BlockNoteEditor-6SN4V76A.mjs} +3 -3
- package/dist/{BlockNoteEditor-7WAWEZVW.js → BlockNoteEditor-F7V7MVIU.js} +13 -13
- package/dist/{BlockNoteEditor-7WAWEZVW.js.map → BlockNoteEditor-F7V7MVIU.js.map} +1 -1
- package/dist/billing/index.js +342 -342
- package/dist/billing/index.mjs +2 -2
- package/dist/{chunk-O3LLMGP7.js → chunk-2VZZFQP4.js} +74 -63
- package/dist/chunk-2VZZFQP4.js.map +1 -0
- package/dist/{chunk-6BDOZDZ3.mjs → chunk-ACMJFZO7.mjs} +1552 -1389
- package/dist/chunk-ACMJFZO7.mjs.map +1 -0
- package/dist/{chunk-LNBT2YPZ.mjs → chunk-NAB52T2P.mjs} +20 -9
- package/dist/chunk-NAB52T2P.mjs.map +1 -0
- package/dist/{chunk-JI6BDV7L.js → chunk-RK64POSH.js} +864 -701
- package/dist/chunk-RK64POSH.js.map +1 -0
- package/dist/client/index.d.mts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +3 -3
- package/dist/client/index.mjs +2 -2
- package/dist/components/index.d.mts +20 -3
- package/dist/components/index.d.ts +20 -3
- package/dist/components/index.js +5 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -2
- package/dist/{config-D_91hrI-.d.ts → config-B4pZpLT9.d.ts} +1 -1
- package/dist/{config-h0hNLceh.d.mts → config-DT1K-t6I.d.mts} +1 -1
- package/dist/{content.interface-QcsFR5Ad.d.mts → content.interface-B2Ldg0vg.d.mts} +1 -1
- package/dist/{content.interface-CUIEQ0jk.d.ts → content.interface-D8NHv3DX.d.ts} +1 -1
- package/dist/contexts/index.d.mts +4 -2
- package/dist/contexts/index.d.ts +4 -2
- package/dist/contexts/index.js +3 -3
- package/dist/contexts/index.mjs +2 -2
- package/dist/core/index.d.mts +11 -7
- package/dist/core/index.d.ts +11 -7
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{notification.interface-blT8r47t.d.mts → notification.interface-DEn-Yp_b.d.mts} +6 -3
- package/dist/{notification.interface-D7_g5SnS.d.ts → notification.interface-H0L9WBge.d.ts} +6 -3
- package/dist/{s3.service-DSDfcr0S.d.mts → s3.service-BNytYanU.d.mts} +2 -2
- package/dist/{s3.service-B83hUhqV.d.ts → s3.service-C7f_Ygz5.d.ts} +2 -2
- package/dist/server/index.d.mts +3 -4
- package/dist/server/index.d.ts +3 -4
- package/dist/server/index.js +18 -25
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1 -8
- package/dist/server/index.mjs.map +1 -1
- package/dist/{useSocket-B5M_a4bD.d.mts → useSocket-BcnThTD0.d.mts} +1 -1
- package/dist/{useSocket-Dd03muLJ.d.ts → useSocket-QZTOCzRF.d.ts} +1 -1
- package/package.json +1 -1
- package/src/components/navigations/Header.tsx +34 -2
- package/src/features/auth/components/forms/RefreshUser.tsx +1 -2
- package/src/features/auth/config.ts +0 -1
- package/src/features/auth/data/auth.service.ts +1 -3
- package/src/features/auth/utils/AuthCookies.ts +0 -14
- package/src/features/company/components/details/TokenStatusIndicator.tsx +136 -0
- package/src/features/company/components/details/index.ts +1 -0
- package/src/features/company/components/forms/index.ts +0 -1
- package/src/features/company/data/company.interface.ts +6 -3
- package/src/features/company/data/company.ts +21 -9
- package/src/features/user/contexts/CurrentUserContext.tsx +57 -2
- package/src/server/ServerSession.ts +0 -10
- package/dist/chunk-6BDOZDZ3.mjs.map +0 -1
- package/dist/chunk-JI6BDV7L.js.map +0 -1
- package/dist/chunk-LNBT2YPZ.mjs.map +0 -1
- package/dist/chunk-O3LLMGP7.js.map +0 -1
- package/src/features/company/components/forms/CompanyLicense.tsx +0 -208
- /package/dist/{BlockNoteEditor-UNVKGZ2G.mjs.map → BlockNoteEditor-6SN4V76A.mjs.map} +0 -0
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
-
import { deleteCookie } from "cookies-next";
|
|
5
|
-
import { ClipboardIcon } from "lucide-react";
|
|
6
|
-
import { useTranslations } from "next-intl";
|
|
7
|
-
import Image from "next/image";
|
|
8
|
-
import { SubmitHandler, useForm } from "react-hook-form";
|
|
9
|
-
import { toast } from "sonner";
|
|
10
|
-
import z from "zod";
|
|
11
|
-
import { errorToast, FormInput, FormTextarea } from "../../../../components";
|
|
12
|
-
import { Modules } from "../../../../core";
|
|
13
|
-
import { useI18nRouter, usePageUrlGenerator } from "../../../../hooks";
|
|
14
|
-
import { getRoleId } from "../../../../roles";
|
|
15
|
-
import {
|
|
16
|
-
Button,
|
|
17
|
-
Card,
|
|
18
|
-
CardContent,
|
|
19
|
-
CardDescription,
|
|
20
|
-
CardFooter,
|
|
21
|
-
CardHeader,
|
|
22
|
-
CardTitle,
|
|
23
|
-
Form,
|
|
24
|
-
Input,
|
|
25
|
-
Label,
|
|
26
|
-
Link,
|
|
27
|
-
} from "../../../../shadcnui";
|
|
28
|
-
import { UserInterface } from "../../../user";
|
|
29
|
-
import { useCurrentUserContext } from "../../../user/contexts";
|
|
30
|
-
import { UserService } from "../../../user/data/user.service";
|
|
31
|
-
import { CompanyInput } from "../../data";
|
|
32
|
-
import { CompanyService } from "../../data/company.service";
|
|
33
|
-
|
|
34
|
-
type TokenPayload = {
|
|
35
|
-
userId: string;
|
|
36
|
-
companyId?: string;
|
|
37
|
-
licenseExpirationDate?: Date;
|
|
38
|
-
roles: string[];
|
|
39
|
-
features: string[];
|
|
40
|
-
modules: {
|
|
41
|
-
id: string;
|
|
42
|
-
permissions: {
|
|
43
|
-
create: boolean | string;
|
|
44
|
-
read: boolean | string;
|
|
45
|
-
update: boolean | string;
|
|
46
|
-
delete: boolean | string;
|
|
47
|
-
};
|
|
48
|
-
}[];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type CompanyLicenseProps = {
|
|
52
|
-
onRevalidate?: (path: string) => Promise<void>;
|
|
53
|
-
onUpdateToken?: (token: TokenPayload) => Promise<void>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default function CompanyLicense({ onRevalidate, onUpdateToken }: CompanyLicenseProps = {}) {
|
|
57
|
-
const { currentUser, setUser, hasRole } = useCurrentUserContext<UserInterface>();
|
|
58
|
-
|
|
59
|
-
const t = useTranslations();
|
|
60
|
-
const generateUrl = usePageUrlGenerator();
|
|
61
|
-
const router = useI18nRouter();
|
|
62
|
-
|
|
63
|
-
const copyToClipboard = (text: string) => {
|
|
64
|
-
navigator.clipboard.writeText(text);
|
|
65
|
-
toast("Copied to clipboard");
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const formSchema = z.object({
|
|
69
|
-
license: z.string().min(1, {
|
|
70
|
-
message: `License is required`,
|
|
71
|
-
}),
|
|
72
|
-
privateKey: z.string().min(1, {
|
|
73
|
-
message: `Private key is required`,
|
|
74
|
-
}),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const defaultValues = {
|
|
78
|
-
license:
|
|
79
|
-
"09001678dca2f4a6d2d32bb984811278:3e93a432f6130579e543a511346c0d2c6ca7a97d49c7ff2d3e789ca7c7c8d79b864fd3406c8315e72aa5febf6232776dfaea51d72168ddcdd34a59ea1a05b3b3dd60ac3af6c3934203d19ea68642293aa5b79f012633b4ba2e4a474e9ceed6b6cda13d8dedc8e60ece61886843ee6edc1af6d2da5e07945033295507df6f87994f8347b5759b446aa20b1185d7b5c54c67509ae280e729913d0e68e95b5f090b0577a8a735f24fb7c1df8f6586886d840af4a43f9dc74d5d1f291058a45ace759176fa19fe5e164f5d8307981e8bcd166f346e97b676dd0242d1c30ec4fe744f22621fae603b1caaac25f198d2b29be0e0f2afc81a40edeb20242345e2feac8666027d0c30aa8dadbca742dd68ade46602545979f473b344021d27921553d5b284fd96a717b74573ca7e693723876357013e3c0d07a35d270a0e32654d2c244220e2492380279aa34a4744d145b89d06a8abef49cc2ef0dd0171e0eefcf16724decf53e545d10d9bfd8e0c4b03ca720b0fc63d8a20ca2c71d74cb0cf7e547637dbcc8d27257414b5b0b40eabe9eb53a4b5f61ca2250d5933a13565f785a89fc5e3e3c468acbeddf14627aa4109f32af641fc96513e52edc21849e81331cafc900ea85f58927d583aafe5a959af69ce5c967d0cd5d9050cf6601a615e8e3ccf32e6a04227f1f228d94f9bd24073c7b0ec2550f4efc69bddde745144dcb279864fb3e7e7d57d1e96d0701b55f0d6f3bd688880e4a78adb0974cba278cd34bc02753e8a736a4b3a4e48afdf206b9330fee4e29a3c28dec8457e0f44adc10735c1d1992b798e0dd710053ce98ff38b6ff59004079a5face769950401b49fdc13e4cd3324d7df2cf0f40593f51c117debbafd",
|
|
80
|
-
privateKey:
|
|
81
|
-
"-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCKDXrjEXBcYx6p\nChtixITGiFqZeaurD3n2SeJl8QuniKlbl7ytC71gS9BzIG5Q/ENhAE41qa7FaHdN\nHLQ2anfAjS/wd/41wx9ilvQeN/IcDb5Dx3Qd07OMLdrgDvkhlUPSvt7Y5/yft1IX\nS8NaDrKoO4zjpVB9SeLYGyFXmfP0ciJ97AkWDfXp3l2WjwwxEQByo5uXOMzpEZla\nkqBFy7kkO3c/SJWqnuXbXrUVr7AjZ9zMCPP/NbvvOkGzovrOYHN5WO9Rg7m+wIFK\n+gTL2e3RnyjUUSoX5/NMZO9oyDNEaaWgIv6LOG72A2Xq55gpNQihjltZWd/o+xFb\nIRZzbmllAgMBAAECggEABrrvgcBo5OgkJ4OJoEAKZQ9is1a+KsG/ZWVmtyeQNOOx\ntfhox1rqKZaom+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W5xQl+hEOywT95OcWB9b4CiZsp1P\nZyjkByeUuraVM1DoFh66UdXUvC2FECdyz4N3JyKHvV82GdrTPsQLVPCsGfzkj7V8\nX+iuQoeEbUvwnnrg3pbClQ==\n-----END PRIVATE KEY-----\n",
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const form = useForm<z.infer<typeof formSchema>>({
|
|
85
|
-
resolver: zodResolver(formSchema),
|
|
86
|
-
defaultValues: defaultValues,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const onSubmit: SubmitHandler<z.infer<typeof formSchema>> = async (values: z.infer<typeof formSchema>) => {
|
|
90
|
-
if (!currentUser || !currentUser.company) {
|
|
91
|
-
errorToast({
|
|
92
|
-
title: t("generic.errors.error"),
|
|
93
|
-
error: new Error("User or company not found"),
|
|
94
|
-
});
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const payload: CompanyInput = {
|
|
99
|
-
id: currentUser.company.id,
|
|
100
|
-
license: values.license,
|
|
101
|
-
privateKey: values.privateKey,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const updatedLicense = await CompanyService.activateLicense(payload);
|
|
106
|
-
|
|
107
|
-
const fullUser = await UserService.findFullUser();
|
|
108
|
-
|
|
109
|
-
if (fullUser) {
|
|
110
|
-
setUser(fullUser);
|
|
111
|
-
const token = {
|
|
112
|
-
userId: fullUser.id,
|
|
113
|
-
companyId: fullUser.company?.id,
|
|
114
|
-
licenseExpirationDate: fullUser.company?.licenseExpirationDate,
|
|
115
|
-
roles: fullUser.roles.map((role) => role.id),
|
|
116
|
-
features: fullUser.company?.features?.map((feature) => feature.id) ?? [],
|
|
117
|
-
modules: fullUser.modules.map((module) => {
|
|
118
|
-
return { id: module.id, permissions: module.permissions };
|
|
119
|
-
}),
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
if (onUpdateToken) {
|
|
123
|
-
await onUpdateToken(token);
|
|
124
|
-
}
|
|
125
|
-
deleteCookie("reloadData");
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (onRevalidate) {
|
|
129
|
-
await onRevalidate(generateUrl({ page: Modules.Company, id: updatedLicense.id, language: `[locale]` }));
|
|
130
|
-
}
|
|
131
|
-
router.push(generateUrl({ page: "/" }));
|
|
132
|
-
} catch (error) {
|
|
133
|
-
errorToast({
|
|
134
|
-
title: t(`generic.errors.update`),
|
|
135
|
-
error,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
if (!currentUser || !currentUser.company) return null;
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<Form {...form}>
|
|
144
|
-
<form
|
|
145
|
-
onSubmit={form.handleSubmit(onSubmit)}
|
|
146
|
-
className="relative flex min-h-screen w-full flex-col items-center justify-center"
|
|
147
|
-
>
|
|
148
|
-
<div className="absolute top-4 left-4 z-0">
|
|
149
|
-
<Image src={`/logo.webp`} className="object-contain p-4" height={300} width={300} alt={"Logo"} priority />
|
|
150
|
-
</div>
|
|
151
|
-
<Card className="z-10 w-3xl">
|
|
152
|
-
{hasRole(getRoleId().CompanyAdministrator) ? (
|
|
153
|
-
<>
|
|
154
|
-
<CardHeader>
|
|
155
|
-
<CardTitle>Company License Required</CardTitle>
|
|
156
|
-
<CardDescription className={`flex w-full flex-col`}>
|
|
157
|
-
<div>You need to activate your license to use Only35.</div>
|
|
158
|
-
<div>
|
|
159
|
-
<span>To obtain your license, please visit</span>
|
|
160
|
-
<Link href="https://only35.com" target="_blank" className={`text-primary`}>
|
|
161
|
-
our website (https://only35.com)
|
|
162
|
-
</Link>
|
|
163
|
-
<span>, register for an account and follow the instructions provided.</span>
|
|
164
|
-
</div>
|
|
165
|
-
<div>You will be required to provide the installation identifier provided below.</div>
|
|
166
|
-
<div>
|
|
167
|
-
Once you have activated your license, please paste your license and private key in the fields below.
|
|
168
|
-
</div>
|
|
169
|
-
</CardDescription>
|
|
170
|
-
</CardHeader>
|
|
171
|
-
<CardContent className="flex flex-col gap-y-4">
|
|
172
|
-
<div>
|
|
173
|
-
<Label>Installation Identifier</Label>
|
|
174
|
-
<div className="flex items-center">
|
|
175
|
-
<Input disabled value={currentUser.company.id} />
|
|
176
|
-
<ClipboardIcon
|
|
177
|
-
className="text-muted-foreground ml-2 cursor-pointer"
|
|
178
|
-
onClick={() => copyToClipboard(currentUser!.company!.id)}
|
|
179
|
-
/>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
<div>
|
|
183
|
-
<FormInput form={form} id="license" name={"license"} placeholder="Enter your license" />
|
|
184
|
-
</div>
|
|
185
|
-
<div>
|
|
186
|
-
<FormTextarea name="Private Key" form={form} id="privateKey" placeholder="Enter your private key" />
|
|
187
|
-
</div>
|
|
188
|
-
</CardContent>
|
|
189
|
-
<CardFooter className="flex justify-end">
|
|
190
|
-
<Button type="submit">Activate License</Button>
|
|
191
|
-
</CardFooter>
|
|
192
|
-
</>
|
|
193
|
-
) : (
|
|
194
|
-
<>
|
|
195
|
-
<CardHeader>
|
|
196
|
-
<CardTitle>Company License Required</CardTitle>
|
|
197
|
-
<CardDescription className={`flex w-full flex-col`}>
|
|
198
|
-
The company license is either missing or expired.
|
|
199
|
-
</CardDescription>
|
|
200
|
-
</CardHeader>
|
|
201
|
-
<CardContent>Please contact your system administrator to resolve this issue.</CardContent>
|
|
202
|
-
</>
|
|
203
|
-
)}
|
|
204
|
-
</Card>
|
|
205
|
-
</form>
|
|
206
|
-
</Form>
|
|
207
|
-
);
|
|
208
|
-
}
|
|
File without changes
|