@plasius/profile 1.0.4
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/CHANGELOG.md +66 -0
- package/CODE_OF_CONDUCT.md +79 -0
- package/CONTRIBUTORS.md +27 -0
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/SECURITY.md +17 -0
- package/dist/Pages/Settings/Settings.d.ts +3 -0
- package/dist/Pages/Settings/Settings.d.ts.map +1 -0
- package/dist/Pages/Settings/Settings.js +93 -0
- package/dist/Pages/Settings/Settings.module.css +13 -0
- package/dist/Pages/Settings/index.d.ts +2 -0
- package/dist/Pages/Settings/index.d.ts.map +1 -0
- package/dist/Pages/Settings/index.js +1 -0
- package/dist/SettingsProvider.d.ts +28 -0
- package/dist/SettingsProvider.d.ts.map +1 -0
- package/dist/SettingsProvider.js +96 -0
- package/dist/UserProvider.d.ts +51 -0
- package/dist/UserProvider.d.ts.map +1 -0
- package/dist/UserProvider.js +141 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist-cjs/Pages/Settings/Settings.d.ts +3 -0
- package/dist-cjs/Pages/Settings/Settings.d.ts.map +1 -0
- package/dist-cjs/Pages/Settings/Settings.js +99 -0
- package/dist-cjs/Pages/Settings/Settings.module.css +13 -0
- package/dist-cjs/Pages/Settings/index.d.ts +2 -0
- package/dist-cjs/Pages/Settings/index.d.ts.map +1 -0
- package/dist-cjs/Pages/Settings/index.js +17 -0
- package/dist-cjs/SettingsProvider.d.ts +28 -0
- package/dist-cjs/SettingsProvider.d.ts.map +1 -0
- package/dist-cjs/SettingsProvider.js +100 -0
- package/dist-cjs/UserProvider.d.ts +51 -0
- package/dist-cjs/UserProvider.d.ts.map +1 -0
- package/dist-cjs/UserProvider.js +146 -0
- package/dist-cjs/index.d.ts +4 -0
- package/dist-cjs/index.d.ts.map +1 -0
- package/dist-cjs/index.js +19 -0
- package/docs/adrs/adr-0001-profile-package-scope.md +21 -0
- package/docs/adrs/adr-0002-public-repo-governance.md +24 -0
- package/docs/adrs/adr-template.md +35 -0
- package/legal/CLA-REGISTRY.csv +1 -0
- package/legal/CLA.md +22 -0
- package/legal/CORPORATE_CLA.md +57 -0
- package/legal/INDIVIDUAL_CLA.md +91 -0
- package/package.json +109 -0
- package/src/Pages/Settings/Settings.module.css +13 -0
- package/src/Pages/Settings/Settings.tsx +228 -0
- package/src/Pages/Settings/index.ts +1 -0
- package/src/SettingsProvider.tsx +146 -0
- package/src/UserProvider.tsx +167 -0
- package/src/declarations.d.ts +5 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,19 @@
|
|
|
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("./UserProvider.js"), exports);
|
|
18
|
+
__exportStar(require("./SettingsProvider.js"), exports);
|
|
19
|
+
__exportStar(require("./Pages/Settings/index.js"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ADR-0001: Standalone @plasius/profile Package Scope
|
|
2
|
+
|
|
3
|
+
- Date: 2026-02-11
|
|
4
|
+
- Status: Accepted
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
This package was previously maintained as a workspace-only module inside
|
|
9
|
+
`plasius-ltd-site`. External consumers and remote builds require it to be
|
|
10
|
+
installable from npm without monorepo-local links.
|
|
11
|
+
|
|
12
|
+
## Decision
|
|
13
|
+
|
|
14
|
+
Move `@plasius/profile` to a standalone root package with independent build,
|
|
15
|
+
test, governance, CI, and publish workflows.
|
|
16
|
+
|
|
17
|
+
## Consequences
|
|
18
|
+
|
|
19
|
+
- The package can be versioned and released independently.
|
|
20
|
+
- `plasius-ltd-site` and other repositories can depend on npm-published versions.
|
|
21
|
+
- Build and lint rules must no longer rely on monorepo-relative tsconfig paths.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# ADR-0002: Public Repository Governance Baseline
|
|
2
|
+
|
|
3
|
+
- Date: 2026-02-11
|
|
4
|
+
- Status: Accepted
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
Public npm distribution requires transparent contributor and security policy
|
|
9
|
+
artifacts and consistent release automation.
|
|
10
|
+
|
|
11
|
+
## Decision
|
|
12
|
+
|
|
13
|
+
Include these baseline governance assets:
|
|
14
|
+
|
|
15
|
+
- `CODE_OF_CONDUCT.md`
|
|
16
|
+
- `CONTRIBUTORS.md`
|
|
17
|
+
- `SECURITY.md`
|
|
18
|
+
- `legal/` CLA documents
|
|
19
|
+
- CI/CD GitHub Actions workflows
|
|
20
|
+
|
|
21
|
+
## Consequences
|
|
22
|
+
|
|
23
|
+
- Public contributors and consumers can follow a predictable governance process.
|
|
24
|
+
- Release quality gates (build, test, coverage, publish) are standardized.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Architectural Decision Record (ADR)
|
|
2
|
+
|
|
3
|
+
## Title
|
|
4
|
+
|
|
5
|
+
> Concise, descriptive title of the decision.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
- Proposed | Accepted | Rejected | Superseded | Deprecated
|
|
10
|
+
- Date: YYYY-MM-DD
|
|
11
|
+
- Version: 1.0
|
|
12
|
+
|
|
13
|
+
## Context
|
|
14
|
+
|
|
15
|
+
Describe the problem, constraints, and relevant background.
|
|
16
|
+
|
|
17
|
+
## Decision
|
|
18
|
+
|
|
19
|
+
Clear statement of the selected approach.
|
|
20
|
+
|
|
21
|
+
## Alternatives Considered
|
|
22
|
+
|
|
23
|
+
- Option A
|
|
24
|
+
- Option B
|
|
25
|
+
- Option C
|
|
26
|
+
|
|
27
|
+
## Consequences
|
|
28
|
+
|
|
29
|
+
- Positive outcomes
|
|
30
|
+
- Negative outcomes / trade-offs
|
|
31
|
+
- Follow-up work
|
|
32
|
+
|
|
33
|
+
## References
|
|
34
|
+
|
|
35
|
+
- https://adr.github.io/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type,github_handle,full_name,company,email,date,approver
|
package/legal/CLA.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Contributor License Agreements (CLA)
|
|
2
|
+
|
|
3
|
+
To protect the intellectual property of this project and ensure clarity of rights, all contributors must sign a Contributor License Agreement (CLA) before their first contribution.
|
|
4
|
+
|
|
5
|
+
## Which CLA should I sign?
|
|
6
|
+
|
|
7
|
+
- **Individual CLA**: If you are contributing personally and not on behalf of an employer, sign the [Individual CLA](INDIVIDUAL_CLA.md).
|
|
8
|
+
- **Corporate CLA**: If you are contributing as part of your work for a company, the company should sign the [Corporate CLA](CORPORATE_CLA.md).
|
|
9
|
+
|
|
10
|
+
## How to sign
|
|
11
|
+
|
|
12
|
+
1. Download the appropriate CLA file (Individual or Corporate).
|
|
13
|
+
2. Fill in the required details, sign, and date it.
|
|
14
|
+
3. Email a PDF copy of the signed document to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject: `CLA – Individual` or `CLA – Corporate`.
|
|
15
|
+
|
|
16
|
+
## Registry
|
|
17
|
+
|
|
18
|
+
All signed CLAs are logged internally in the CLA registry (`CLA-REGISTRY.csv`).
|
|
19
|
+
|
|
20
|
+
## Questions?
|
|
21
|
+
|
|
22
|
+
If you have any questions about which CLA to sign or how the process works, please email **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)**.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Corporate Contributor License Agreement (CLA)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This Corporate Contributor License Agreement ("Agreement") is intended to protect the intellectual property rights of the contributors and the project, ensure clear licensing terms for contributions, and maintain trust within the community. By signing this Agreement, the corporation agrees to the terms that facilitate the use, distribution, and modification of contributions under the project's licensing framework.
|
|
6
|
+
|
|
7
|
+
## Agreement
|
|
8
|
+
|
|
9
|
+
1. **Representation of Authority**
|
|
10
|
+
The undersigned individual represents and warrants that they have the full legal authority to enter into this Agreement on behalf of the corporation named below ("Corporation") and to grant the rights contained herein.
|
|
11
|
+
|
|
12
|
+
2. **Grant of Copyright License**
|
|
13
|
+
The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable copyright license to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the contributions submitted to the project.
|
|
14
|
+
|
|
15
|
+
3. **Grant of Patent License**
|
|
16
|
+
The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under any patent claims that are necessarily infringed by the contributions to make, use, sell, offer for sale, import, and otherwise dispose of the contributions or derivative works thereof.
|
|
17
|
+
|
|
18
|
+
4. **Warranties and Representations**
|
|
19
|
+
The Corporation represents and warrants that:
|
|
20
|
+
|
|
21
|
+
- The contributions are the original work of the Corporation or that the Corporation has sufficient rights to grant the licenses herein.
|
|
22
|
+
- The submission of the contributions does not violate any agreements or rights of third parties.
|
|
23
|
+
|
|
24
|
+
5. **No Revocation**
|
|
25
|
+
This license is granted on a perpetual basis and cannot be revoked, provided that the terms of this Agreement are met.
|
|
26
|
+
|
|
27
|
+
6. **Governing Law**
|
|
28
|
+
This Agreement shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of laws principles.
|
|
29
|
+
|
|
30
|
+
7. **Execution**
|
|
31
|
+
|
|
32
|
+
This Agreement is effective upon signature by the authorized representative of the Corporation. Please sign and date this document, then email a scanned PDF copy to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### **@plasius/api**
|
|
37
|
+
|
|
38
|
+
**Corporation Legal Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
39
|
+
|
|
40
|
+
**Authorized Representative:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
41
|
+
|
|
42
|
+
**Title:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
43
|
+
|
|
44
|
+
**Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
45
|
+
|
|
46
|
+
**Date:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
47
|
+
|
|
48
|
+
**Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## How to Sign
|
|
53
|
+
|
|
54
|
+
- Download this file as a template.
|
|
55
|
+
- Fill in the Corporation’s legal name, authorized representative, title, email, date, and provide a signature.
|
|
56
|
+
- Sign and date the document.
|
|
57
|
+
- Send a scanned copy of the signed Agreement to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Individual Contributor License Agreement (CLA)
|
|
2
|
+
|
|
3
|
+
**Project:** @plasius/api (Plasius LTD)
|
|
4
|
+
**Version:** 1.0 — 2025‑09‑12
|
|
5
|
+
**Contact:** [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Definitions
|
|
10
|
+
|
|
11
|
+
- **"You"** (or **"Contributor"**) means the individual signing this CLA and submitting Contributions to the Project.
|
|
12
|
+
- **"Contribution"** means any original work of authorship, including code, documentation, data, designs, or feedback that You submit to the Project in any form (e.g., pull request, issue comment, email, file upload).
|
|
13
|
+
- **"Project"** means the @plasius/api repositories and related materials owned or managed by **Plasius LTD**.
|
|
14
|
+
|
|
15
|
+
## 2. Copyright License Grant
|
|
16
|
+
|
|
17
|
+
You hereby grant to Plasius LTD a **perpetual, worldwide, non‑exclusive, transferable, sublicensable, royalty‑free, irrevocable** copyright license to:
|
|
18
|
+
|
|
19
|
+
- use, reproduce, publicly display, publicly perform, modify, create derivative works of, and
|
|
20
|
+
- distribute Contributions in source and object form,
|
|
21
|
+
- and to **sublicense** these rights under any terms Plasius LTD chooses, including proprietary or open‑source licenses.
|
|
22
|
+
|
|
23
|
+
## 3. Patent License Grant
|
|
24
|
+
|
|
25
|
+
You hereby grant to Plasius LTD and its sublicensees a **perpetual, worldwide, non‑exclusive, transferable, royalty‑free, irrevocable** patent license to **make, have made, use, offer to sell, sell, import, and otherwise transfer** the Contribution and derivative works thereof, where such license applies only to patent claims that You **own or control** and that would be infringed by Your Contribution or its combination with the Project.
|
|
26
|
+
|
|
27
|
+
## 4. Moral Rights & Attribution
|
|
28
|
+
|
|
29
|
+
To the maximum extent permitted by applicable law, You **waive** and agree not to assert any moral rights (e.g., rights of attribution or integrity) in or to the Contribution against Plasius LTD. Plasius LTD may, but is not required to, credit You.
|
|
30
|
+
|
|
31
|
+
## 5. Representations & Warranties
|
|
32
|
+
|
|
33
|
+
You represent that:
|
|
34
|
+
|
|
35
|
+
1. **Originality / Rights:** Each Contribution is Your original creation, or You have sufficient rights to submit it and grant the licenses above.
|
|
36
|
+
2. **No Confidential Info:** Contributions **do not** include confidential information or trade secrets of any third party.
|
|
37
|
+
3. **No Infringement:** To the best of Your knowledge, Contributions do not infringe any third‑party IP rights.
|
|
38
|
+
4. **Employment / Contractor Status:** If Your employer or a third party might claim rights in Your Contribution, You have obtained **written permission** to make the Contribution and grant these licenses (attach or reference below), or Your Contribution is made **outside the scope** of your employment and without using your employer’s confidential information or resources.
|
|
39
|
+
5. **Compliance:** You will follow the Project’s policies (e.g., Code of Conduct, Security Policy) and applicable laws.
|
|
40
|
+
|
|
41
|
+
## 6. Third‑Party Code
|
|
42
|
+
|
|
43
|
+
If Your Contribution includes code, data, or other material from a third party, You will **identify the material and its license** in the pull request or submission, and ensure it is **compatible** with the Project’s licensing model. You will not submit material subject to terms that require the Project to disclose proprietary source code (e.g., certain copyleft obligations) unless the Project has **pre‑approved** such inclusion in writing.
|
|
44
|
+
|
|
45
|
+
## 7. Scope & Duration
|
|
46
|
+
|
|
47
|
+
- This CLA covers **all past and future** Contributions You submit to the Project, unless and until You provide written notice to **revoke** it.
|
|
48
|
+
- Revocation is **not retroactive**: rights granted for prior Contributions remain in effect.
|
|
49
|
+
|
|
50
|
+
## 8. Disclaimer
|
|
51
|
+
|
|
52
|
+
THE CONTRIBUTION IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON‑INFRINGEMENT.
|
|
53
|
+
|
|
54
|
+
## 9. Governing Law & Jurisdiction
|
|
55
|
+
|
|
56
|
+
This CLA is governed by the **laws of England and Wales**, and the courts of England and Wales shall have **exclusive jurisdiction** over any dispute arising out of or relating to it.
|
|
57
|
+
|
|
58
|
+
## 10. Entire Agreement
|
|
59
|
+
|
|
60
|
+
This CLA is the entire agreement between You and Plasius LTD regarding Contributions. It supersedes any prior discussions relating to Contributions. If any provision is held unenforceable, the remaining provisions remain in full force.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 11. Contributor Information & Signature
|
|
65
|
+
|
|
66
|
+
By signing below, You agree to the terms of this CLA for Your Contributions to the Project.
|
|
67
|
+
|
|
68
|
+
**Full Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
69
|
+
|
|
70
|
+
**Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
71
|
+
|
|
72
|
+
**GitHub Handle:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
73
|
+
|
|
74
|
+
**Address (optional):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
75
|
+
|
|
76
|
+
**Employer (if applicable):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
77
|
+
|
|
78
|
+
**If employed:** ☐ I confirm Contributions are made outside the scope of employment **or** ☐ I have attached my employer’s written permission.
|
|
79
|
+
|
|
80
|
+
**Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
81
|
+
|
|
82
|
+
**Date (YYYY‑MM‑DD):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
83
|
+
|
|
84
|
+
_Electronic signatures are accepted. You may type your name in the Signature field and email a PDF copy._
|
|
85
|
+
|
|
86
|
+
**Submission:** Please email the signed CLA to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject line: `CLA – Individual – <GitHubHandle>`.
|
|
87
|
+
|
|
88
|
+
**(Optional) Attachments / Notes:**
|
|
89
|
+
|
|
90
|
+
- Employer permission letter (if required)
|
|
91
|
+
- Third‑party license disclosures (if any)
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plasius/profile",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"main": "./dist-cjs/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"private": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"description": "User Profile component for Plasius projects",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc --build --listEmittedFiles && rsync -av --include '*/' --include '*.module.css' --exclude '*' src/ dist/ || true && npm run build:cjs",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"test:watch": "vitest",
|
|
13
|
+
"test:coverage": "vitest run --coverage",
|
|
14
|
+
"test:coverage:watch": "vitest --coverage",
|
|
15
|
+
"clean": "rimraf dist-cjs dist tsconfig.tsbuildinfo",
|
|
16
|
+
"reset:clean": "rm -rf node_modules package-lock.json && npm run clean",
|
|
17
|
+
"audit:ts": "tsc --noEmit --pretty",
|
|
18
|
+
"audit:eslint": "eslint \"{src,apps,packages}/**/*.{ts,tsx}\" --max-warnings=0 --ext .ts,.tsx",
|
|
19
|
+
"audit:deps": "depcheck --skip-missing=true",
|
|
20
|
+
"audit:npm": "npm audit --audit-level=moderate || true",
|
|
21
|
+
"audit:test": "vitest run --coverage",
|
|
22
|
+
"audit:all": "npm-run-all -l audit:ts audit:eslint audit:deps audit:npm audit:test",
|
|
23
|
+
"build:cjs": "tsc -p tsconfig.json --module commonjs --moduleResolution node --outDir dist-cjs --tsBuildInfoFile dist-cjs/tsconfig.tsbuildinfo --listEmittedFiles && rsync -av --include '*/' --include '*.module.css' --exclude '*' src/ dist-cjs/ || true",
|
|
24
|
+
"lint": "eslint .",
|
|
25
|
+
"prepare": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"author": "Plasius LTD <development@plasius.co.uk>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^19.1.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@plasius/auth": "^1.0.0",
|
|
34
|
+
"@plasius/entity-manager": "^1.0.4",
|
|
35
|
+
"@plasius/environment": "^1.0.0",
|
|
36
|
+
"@plasius/react-query": "^1.0.0",
|
|
37
|
+
"@plasius/react-state": "^1.2.0",
|
|
38
|
+
"@plasius/schema": "^1.0.0",
|
|
39
|
+
"@plasius/translations": "^1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@testing-library/react": "^16.3.0",
|
|
43
|
+
"@types/react": "^19.1.8",
|
|
44
|
+
"@types/uuid": "^10.0.0",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
46
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
47
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
48
|
+
"ajv": "^6.12.6",
|
|
49
|
+
"depcheck": "^1.4.7",
|
|
50
|
+
"eslint": "^9.33.0",
|
|
51
|
+
"npm-run-all": "^4.1.5",
|
|
52
|
+
"react": "19.1.0",
|
|
53
|
+
"react-dom": "19.1.0",
|
|
54
|
+
"tsx": "^4.20.3",
|
|
55
|
+
"typescript": "^5.8.3",
|
|
56
|
+
"vitest": "^3.2.4",
|
|
57
|
+
"zod": "^4.0.17",
|
|
58
|
+
"rimraf": "^6.0.1"
|
|
59
|
+
},
|
|
60
|
+
"sideEffects": [
|
|
61
|
+
"*.css"
|
|
62
|
+
],
|
|
63
|
+
"exports": {
|
|
64
|
+
".": {
|
|
65
|
+
"types": "./dist/index.d.ts",
|
|
66
|
+
"import": "./dist/index.js",
|
|
67
|
+
"require": "./dist-cjs/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./package.json": "./package.json"
|
|
70
|
+
},
|
|
71
|
+
"module": "./dist/index.js",
|
|
72
|
+
"files": [
|
|
73
|
+
"dist",
|
|
74
|
+
"dist-cjs",
|
|
75
|
+
"src",
|
|
76
|
+
"README.md",
|
|
77
|
+
"CHANGELOG.md",
|
|
78
|
+
"LICENSE",
|
|
79
|
+
"SECURITY.md",
|
|
80
|
+
"CODE_OF_CONDUCT.md",
|
|
81
|
+
"CONTRIBUTORS.md",
|
|
82
|
+
"docs",
|
|
83
|
+
"legal"
|
|
84
|
+
],
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "git+https://github.com/Plasius-LTD/profile.git"
|
|
88
|
+
},
|
|
89
|
+
"bugs": {
|
|
90
|
+
"url": "https://github.com/Plasius-LTD/profile/issues"
|
|
91
|
+
},
|
|
92
|
+
"homepage": "https://github.com/Plasius-LTD/profile#readme",
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"access": "public"
|
|
95
|
+
},
|
|
96
|
+
"funding": [
|
|
97
|
+
{
|
|
98
|
+
"type": "patreon",
|
|
99
|
+
"url": "https://www.patreon.com/c/plasiusltd/membership"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"type": "github",
|
|
103
|
+
"url": "https://github.com/sponsors/Plasius-LTD"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": ">=22.12"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.avatarPreview {
|
|
2
|
+
margin-top: 10px;
|
|
3
|
+
border-radius: 50%;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
width: 100px;
|
|
6
|
+
height: 100px;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
background-color: var(--color-surface-muted);
|
|
11
|
+
box-shadow: var(--shadow-elevation-low);
|
|
12
|
+
transition: background-color 0.3s ease, box-shadow 0.3s ease;
|
|
13
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import type { UserAvatarEntity, UserName } from "@plasius/entity-manager";
|
|
3
|
+
import {
|
|
4
|
+
userEntitySchema,
|
|
5
|
+
userAvatarSchema,
|
|
6
|
+
UserEmailPreferences,
|
|
7
|
+
PreferredDisplayOrder,
|
|
8
|
+
} from "@plasius/entity-manager";
|
|
9
|
+
import { useAuthorizedFetch } from "@plasius/auth";
|
|
10
|
+
import { useI18n } from "@plasius/translations";
|
|
11
|
+
import { UserStore } from "../../UserProvider.js";
|
|
12
|
+
|
|
13
|
+
import styles from "./Settings.module.css";
|
|
14
|
+
|
|
15
|
+
const getEmailPreferenceOptions = () =>
|
|
16
|
+
Object.entries(UserEmailPreferences).map(([key, value]) => ({
|
|
17
|
+
label: key.replace(/([a-z])([A-Z])/g, "$1 $2"), // Optional: format nicely
|
|
18
|
+
value,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const getPreferredDisplayOrder = () =>
|
|
22
|
+
Object.entries(PreferredDisplayOrder).map(([key, value]) => ({
|
|
23
|
+
label: key.replace(/([a-z])([A-Z])/g, "$1 $2"), // Optional: format nicely
|
|
24
|
+
value,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
export function SettingsPage() {
|
|
28
|
+
const authorizedFetch = useAuthorizedFetch();
|
|
29
|
+
const { t } = useI18n();
|
|
30
|
+
const { user } = UserStore.useStore();
|
|
31
|
+
const dispatch = UserStore.useDispatch();
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (user) {
|
|
35
|
+
const res = userEntitySchema.validate(user);
|
|
36
|
+
if (!res.valid || res.errors?.length != 0) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Invalid user ${String(user)}. Errors: ${res.errors?.join("\n") ?? "unknown"}`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [user]);
|
|
43
|
+
|
|
44
|
+
const handleChange = (
|
|
45
|
+
e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>
|
|
46
|
+
) => {
|
|
47
|
+
const { name, value } = e.target;
|
|
48
|
+
|
|
49
|
+
if (name.startsWith("name.")) {
|
|
50
|
+
const [, field] = name.split(".");
|
|
51
|
+
dispatch({ type: "updateNameField", payload: { field, value } });
|
|
52
|
+
} else {
|
|
53
|
+
dispatch({ type: "updateField", payload: { field: name, value } });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const uploadAvatar = async (file: File): Promise<unknown> => {
|
|
58
|
+
const formData = new FormData();
|
|
59
|
+
formData.append("avatar", file); // "avatar" must match the expected server-side field
|
|
60
|
+
|
|
61
|
+
const response = await authorizedFetch(`/user/avatar`, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: formData,
|
|
64
|
+
headers: {
|
|
65
|
+
// Do NOT set Content-Type explicitly; browser will set it with boundary
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new Error("Failed to upload avatar");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const data: unknown = await response.json();
|
|
74
|
+
return data; // e.g. { imageUrl: "...uploaded file url..." }
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleAvatarChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
78
|
+
const file = e.target.files?.[0];
|
|
79
|
+
if (!file) return;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const uploadedAvatar = await uploadAvatar(file);
|
|
83
|
+
const validatedAvatar = userAvatarSchema.validate(uploadedAvatar);
|
|
84
|
+
|
|
85
|
+
if (!validatedAvatar.valid || validatedAvatar.errors?.length) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
(validatedAvatar.errors ?? []).map((e) => String(e)).join("; ")
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const base = validatedAvatar.value as unknown as UserAvatarEntity;
|
|
92
|
+
const userAvatar: UserAvatarEntity = {
|
|
93
|
+
...base,
|
|
94
|
+
originalName: file.name,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
dispatch({
|
|
98
|
+
type: "updateField",
|
|
99
|
+
payload: {
|
|
100
|
+
field: "avatar",
|
|
101
|
+
value: userAvatar,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.error(err);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
const errors = userEntitySchema.validate(user);
|
|
112
|
+
if (errors) {
|
|
113
|
+
console.warn("Validation failed", errors);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.info("Saved:", user);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div className={styles.settingsContainer}>
|
|
122
|
+
<form onSubmit={handleSubmit} className={styles.settingsForm}>
|
|
123
|
+
<h2>{t("profile_settings")}</h2>
|
|
124
|
+
<label className={styles.label}>
|
|
125
|
+
{t("upload_avatar")}
|
|
126
|
+
<input
|
|
127
|
+
type="file"
|
|
128
|
+
accept="image/*"
|
|
129
|
+
onChange={handleAvatarChange}
|
|
130
|
+
className={styles.input}
|
|
131
|
+
/>
|
|
132
|
+
</label>
|
|
133
|
+
|
|
134
|
+
{user?.avatar?.url && (
|
|
135
|
+
<div>
|
|
136
|
+
<img
|
|
137
|
+
src={(user?.avatar as UserAvatarEntity)?.url as string}
|
|
138
|
+
alt={t("avatar_preview")}
|
|
139
|
+
className={styles.avatarPreview}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
<label className={styles.label}>
|
|
144
|
+
{t("first_name")}
|
|
145
|
+
<input
|
|
146
|
+
name="name.firstName"
|
|
147
|
+
value={(user?.name as UserName)?.firstName as string}
|
|
148
|
+
onChange={handleChange}
|
|
149
|
+
className={styles.input}
|
|
150
|
+
/>
|
|
151
|
+
</label>
|
|
152
|
+
<label className={styles.label}>
|
|
153
|
+
{t("middle_name")}
|
|
154
|
+
<input
|
|
155
|
+
name="name.middleName"
|
|
156
|
+
value={(user?.name as UserName)?.middleName as string}
|
|
157
|
+
onChange={handleChange}
|
|
158
|
+
className={styles.input}
|
|
159
|
+
/>
|
|
160
|
+
</label>
|
|
161
|
+
<label className={styles.label}>
|
|
162
|
+
{t("last_name")}
|
|
163
|
+
<input
|
|
164
|
+
name="name.lastName"
|
|
165
|
+
value={(user?.name as UserName)?.lastName as string}
|
|
166
|
+
onChange={handleChange}
|
|
167
|
+
className={styles.input}
|
|
168
|
+
/>
|
|
169
|
+
</label>
|
|
170
|
+
<label className={styles.label}>
|
|
171
|
+
{t("display_name")}
|
|
172
|
+
<input
|
|
173
|
+
name="name.displayName"
|
|
174
|
+
value={(user?.name as UserName)?.displayName as string}
|
|
175
|
+
onChange={handleChange}
|
|
176
|
+
className={styles.input}
|
|
177
|
+
/>
|
|
178
|
+
</label>
|
|
179
|
+
<label className={styles.label}>
|
|
180
|
+
{t("preferred_name_display")}
|
|
181
|
+
<select
|
|
182
|
+
name="displayPreferences"
|
|
183
|
+
value={(user?.name as UserName).preferredDisplayOrder as PreferredDisplayOrder}
|
|
184
|
+
onChange={handleChange}
|
|
185
|
+
className={styles.select}
|
|
186
|
+
>
|
|
187
|
+
<option value="">{t("select_preference")}</option>
|
|
188
|
+
{getPreferredDisplayOrder().map((opt) => (
|
|
189
|
+
<option key={opt.value} value={opt.value}>
|
|
190
|
+
{opt.label}
|
|
191
|
+
</option>
|
|
192
|
+
))}
|
|
193
|
+
</select>
|
|
194
|
+
</label>
|
|
195
|
+
<label className={styles.label}>
|
|
196
|
+
{t("email")}
|
|
197
|
+
<input
|
|
198
|
+
name="email"
|
|
199
|
+
value={user?.email}
|
|
200
|
+
onChange={handleChange}
|
|
201
|
+
className={styles.input}
|
|
202
|
+
/>
|
|
203
|
+
</label>
|
|
204
|
+
<label className={styles.label}>
|
|
205
|
+
{t("email_preferences")}
|
|
206
|
+
<select
|
|
207
|
+
name="emailPreferences"
|
|
208
|
+
value={user?.emailPreferences as UserEmailPreferences[]}
|
|
209
|
+
onChange={handleChange}
|
|
210
|
+
className={styles.select}
|
|
211
|
+
>
|
|
212
|
+
<option value="">{t("select_preference")}</option>
|
|
213
|
+
{getEmailPreferenceOptions().map((opt) => (
|
|
214
|
+
<option key={opt.value} value={opt.value}>
|
|
215
|
+
{opt.label}
|
|
216
|
+
</option>
|
|
217
|
+
))}
|
|
218
|
+
</select>
|
|
219
|
+
</label>
|
|
220
|
+
<button type="submit" className={styles.submitButton}>
|
|
221
|
+
{t("save_settings")}
|
|
222
|
+
</button>
|
|
223
|
+
</form>
|
|
224
|
+
</div>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export default SettingsPage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Settings.js";
|