@ludo.ninja/components 2.3.65 → 2.3.67

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.
@@ -19,7 +19,7 @@ const redirectToApp = () => {
19
19
  newUser &&
20
20
  // inviteCode &&
21
21
  role) {
22
- url = `${ludoDomains_1.ludoDomains[process_1.default.env.NEXT_PUBLIC_ENV_VALUE]['profile']}/${userId}/nfts`;
22
+ url = `${ludoDomains_1.ludoDomains[process_1.default.env.NEXT_PUBLIC_ENV_VALUE]['profile']}/${userId}/new-opportunities`;
23
23
  }
24
24
  else {
25
25
  url = `${ludoDomains_1.ludoDomains[process_1.default.env.NEXT_PUBLIC_ENV_VALUE]['auth']}/login`;
@@ -0,0 +1,8 @@
1
+ import { GetServerSideProps } from 'next';
2
+ export type TimestampProps = {
3
+ isoTimestamp: string;
4
+ displayTimestamp: string;
5
+ checksum: number;
6
+ };
7
+ export declare function withTimestampSSR<P extends Record<string, any>>(getServerSideProps: GetServerSideProps<P>): GetServerSideProps<P & TimestampProps>;
8
+ export declare function withTimestampSSR(): GetServerSideProps<TimestampProps>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTimestampSSR = withTimestampSSR;
4
+ let lastTimestamp = 0;
5
+ function hashString(str) {
6
+ let hash = 0;
7
+ for (let i = 0; i < str.length; i++) {
8
+ hash = (hash << 5) - hash + str.charCodeAt(i);
9
+ hash |= 0;
10
+ }
11
+ return Math.abs(hash);
12
+ }
13
+ function withTimestampSSR(getServerSideProps) {
14
+ return async (context) => {
15
+ const now = Date.now();
16
+ const url = context.resolvedUrl || '/';
17
+ const hash = hashString(url);
18
+ const secondsAgo = (hash % 59) + 2;
19
+ let proposedTimestamp = now - secondsAgo * 1000;
20
+ if (proposedTimestamp <= lastTimestamp) {
21
+ proposedTimestamp = lastTimestamp + 1000;
22
+ }
23
+ lastTimestamp = proposedTimestamp;
24
+ const updatedDate = new Date(proposedTimestamp);
25
+ const isoTimestamp = updatedDate.toISOString();
26
+ const displayTimestamp = updatedDate.toLocaleString('en-GB', {
27
+ day: '2-digit',
28
+ month: 'long',
29
+ year: 'numeric',
30
+ hour: '2-digit',
31
+ minute: '2-digit',
32
+ second: '2-digit',
33
+ });
34
+ const checksum = hashString(url + isoTimestamp);
35
+ if (getServerSideProps) {
36
+ const result = await getServerSideProps(context);
37
+ if ('props' in result) {
38
+ return {
39
+ props: {
40
+ ...result.props,
41
+ isoTimestamp,
42
+ displayTimestamp,
43
+ checksum,
44
+ },
45
+ };
46
+ }
47
+ return result;
48
+ }
49
+ return {
50
+ props: {
51
+ isoTimestamp,
52
+ displayTimestamp,
53
+ checksum,
54
+ },
55
+ };
56
+ };
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.3.65",
3
+ "version": "2.3.67",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",