@mrfylke/contact-form 0.1.8 → 0.1.10
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/lib/modules/config/data.d.ts +3 -0
- package/lib/modules/config/data.d.ts.map +1 -0
- package/lib/modules/config/data.js +18 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.js +2 -2
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.d.ts.map +1 -1
- package/lib/server/index.js +3 -1
- package/lib/server/lines-route-handler.d.ts +45 -0
- package/lib/server/lines-route-handler.d.ts.map +1 -0
- package/lib/server/lines-route-handler.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/modules/config/data.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./theme-adapter"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refundCarForm.d.ts","sourceRoot":"","sources":["../../../../src/refund/forms/refund-and-travel-guarantee/refundCarForm.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAe7D,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE;QAAE,OAAO,EAAE,kBAAkB,CAAA;KAAE,CAAC;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,gBAAgB,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,iBAAiB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"refundCarForm.d.ts","sourceRoot":"","sources":["../../../../src/refund/forms/refund-and-travel-guarantee/refundCarForm.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAe7D,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE;QAAE,OAAO,EAAE,kBAAkB,CAAA;KAAE,CAAC;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,gBAAgB,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,iBAAiB,kBAAkB,4CA+bhE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -10,7 +10,7 @@ const RefundCarForm = ({ state, send }) => {
|
|
|
10
10
|
const { t } = (0, translations_1.useTranslation)();
|
|
11
11
|
const { getLinesByMode, getQuaysByLine } = (0, use_lines_1.useLines)();
|
|
12
12
|
const transportModeOptions = (0, use_lines_1.useTransportModeOptions)();
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(components_1.Fieldset, { title: t(translations_1.PageText.Contact.refund.
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(components_1.Fieldset, { title: t(translations_1.PageText.Contact.refund.refundCar.aboutTheCarTrip.title), children: [(0, jsx_runtime_1.jsx)(components_1.Input, { id: "kilometersDriven", label: t(translations_1.PageText.Contact.input.kilometersDriven.label), type: "text", name: "kilometersDriven", value: state.context.kilometersDriven || '', isRequired: true, errorMessage: state.context?.errorMessages['kilometersDriven']?.[0] || undefined, onChange: (e) => send({
|
|
14
14
|
type: 'ON_INPUT_CHANGE',
|
|
15
15
|
inputName: 'kilometersDriven',
|
|
16
16
|
value: e.target.value,
|
|
@@ -22,7 +22,7 @@ const RefundCarForm = ({ state, send }) => {
|
|
|
22
22
|
type: 'ON_INPUT_CHANGE',
|
|
23
23
|
inputName: 'toAddress',
|
|
24
24
|
value: e.target.value,
|
|
25
|
-
}) })] }), (0, jsx_runtime_1.jsxs)(components_1.Fieldset, { title: t(translations_1.PageText.Contact.refund.
|
|
25
|
+
}) })] }), (0, jsx_runtime_1.jsxs)(components_1.Fieldset, { title: t(translations_1.PageText.Contact.refund.refundCar.aboutThePlanedTrip.title), children: [(0, jsx_runtime_1.jsx)(components_1.Select, { id: "transportMode", label: t(translations_1.PageText.Contact.input.transportMode.label), value: state.context.transportMode || '', onChange: (value) => send({
|
|
26
26
|
type: 'ON_TRANSPORTMODE_CHANGE',
|
|
27
27
|
value: value,
|
|
28
28
|
}), isRequired: true, error: state.context?.errorMessages['transportMode']?.[0]
|
package/lib/server/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { getLines } from './journey-planner';
|
|
8
8
|
export { getEnturAuthorityId, EnturAuthority, } from './journey-planner/authority';
|
|
9
|
+
export { createLinesRouteHandler, type LinesRouteHandlerOptions, } from './lines-route-handler';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,mBAAmB,EACnB,cAAc,GACf,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,mBAAmB,EACnB,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,uBAAuB,CAAC"}
|
package/lib/server/index.js
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* API route handlers or server components.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.EnturAuthority = exports.getEnturAuthorityId = exports.getLines = void 0;
|
|
9
|
+
exports.createLinesRouteHandler = exports.EnturAuthority = exports.getEnturAuthorityId = exports.getLines = void 0;
|
|
10
10
|
var journey_planner_1 = require("./journey-planner");
|
|
11
11
|
Object.defineProperty(exports, "getLines", { enumerable: true, get: function () { return journey_planner_1.getLines; } });
|
|
12
12
|
var authority_1 = require("./journey-planner/authority");
|
|
13
13
|
Object.defineProperty(exports, "getEnturAuthorityId", { enumerable: true, get: function () { return authority_1.getEnturAuthorityId; } });
|
|
14
14
|
Object.defineProperty(exports, "EnturAuthority", { enumerable: true, get: function () { return authority_1.EnturAuthority; } });
|
|
15
|
+
var lines_route_handler_1 = require("./lines-route-handler");
|
|
16
|
+
Object.defineProperty(exports, "createLinesRouteHandler", { enumerable: true, get: function () { return lines_route_handler_1.createLinesRouteHandler; } });
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js API route handler for the lines endpoint.
|
|
3
|
+
* Hosts mount this at their chosen path (e.g. /api/contact/lines) and supply
|
|
4
|
+
* the region/authority prefix only.
|
|
5
|
+
*/
|
|
6
|
+
export type LinesRouteHandlerOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Optional function to resolve the Entur authority ID (region prefix).
|
|
9
|
+
* If not provided, the handler uses getEnturAuthorityId() which reads
|
|
10
|
+
* ENTUR_AUTHORITY_ID or NEXT_PUBLIC_ENTUR_AUTHORITY_ID from the environment.
|
|
11
|
+
*/
|
|
12
|
+
getAuthorityId?: () => string | Promise<string>;
|
|
13
|
+
};
|
|
14
|
+
type NextApiResponseLike = {
|
|
15
|
+
status(code: number): {
|
|
16
|
+
json(body: unknown): void;
|
|
17
|
+
};
|
|
18
|
+
json(body: unknown): void;
|
|
19
|
+
};
|
|
20
|
+
type NextApiRequestLike = {
|
|
21
|
+
method?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Creates a Next.js API route handler for GET /api/contact/lines.
|
|
25
|
+
* The handler fetches lines from Entur for the given authority; the host
|
|
26
|
+
* only supplies the region/authority prefix via getAuthorityId or env.
|
|
27
|
+
*
|
|
28
|
+
* @example With env-based authority (host sets ENTUR_AUTHORITY_ID):
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { createLinesRouteHandler } from '@mrfylke/contact-form/server';
|
|
31
|
+
* export default createLinesRouteHandler();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example With app-provided authority (e.g. from org config):
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { createLinesRouteHandler } from '@mrfylke/contact-form/server';
|
|
37
|
+
* import { getOrgData } from '@/modules/org-data';
|
|
38
|
+
* export default createLinesRouteHandler({
|
|
39
|
+
* getAuthorityId: () => getOrgData().authorityId,
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function createLinesRouteHandler(options?: LinesRouteHandlerOptions): (req: NextApiRequestLike, res: NextApiResponseLike) => Promise<void>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=lines-route-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines-route-handler.d.ts","sourceRoot":"","sources":["../../src/server/lines-route-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CA0BtE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Next.js API route handler for the lines endpoint.
|
|
4
|
+
* Hosts mount this at their chosen path (e.g. /api/contact/lines) and supply
|
|
5
|
+
* the region/authority prefix only.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.createLinesRouteHandler = createLinesRouteHandler;
|
|
9
|
+
const journey_planner_1 = require("./journey-planner");
|
|
10
|
+
const authority_1 = require("./journey-planner/authority");
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Next.js API route handler for GET /api/contact/lines.
|
|
13
|
+
* The handler fetches lines from Entur for the given authority; the host
|
|
14
|
+
* only supplies the region/authority prefix via getAuthorityId or env.
|
|
15
|
+
*
|
|
16
|
+
* @example With env-based authority (host sets ENTUR_AUTHORITY_ID):
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { createLinesRouteHandler } from '@mrfylke/contact-form/server';
|
|
19
|
+
* export default createLinesRouteHandler();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example With app-provided authority (e.g. from org config):
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { createLinesRouteHandler } from '@mrfylke/contact-form/server';
|
|
25
|
+
* import { getOrgData } from '@/modules/org-data';
|
|
26
|
+
* export default createLinesRouteHandler({
|
|
27
|
+
* getAuthorityId: () => getOrgData().authorityId,
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function createLinesRouteHandler(options) {
|
|
32
|
+
return async (req, res) => {
|
|
33
|
+
if (req.method !== 'GET') {
|
|
34
|
+
res.status(405).json({ error: 'Method not allowed' });
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
let authorityId;
|
|
39
|
+
if (options?.getAuthorityId) {
|
|
40
|
+
const value = options.getAuthorityId();
|
|
41
|
+
authorityId = typeof value === 'string' ? value : await value;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
authorityId = (0, authority_1.getEnturAuthorityId)();
|
|
45
|
+
}
|
|
46
|
+
const lines = await (0, journey_planner_1.getLines)(authorityId);
|
|
47
|
+
res.status(200).json(lines);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.error('[contact-form] lines API error:', err);
|
|
51
|
+
res.status(500).json({
|
|
52
|
+
error: 'Failed to fetch lines',
|
|
53
|
+
message: err instanceof Error ? err.message : String(err),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|