@eka-care/abha-stg 0.0.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/README.md +114 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Login Frontend App for Eka Care
|
|
2
|
+
|
|
3
|
+
This application is in early development mode.
|
|
4
|
+
|
|
5
|
+
## How to Use Login Frontend App
|
|
6
|
+
|
|
7
|
+
Follow these steps to use the `window.initAuthApp` function from the `main.tsx` file:
|
|
8
|
+
|
|
9
|
+
1. **Include the Required Scripts and Styles**:
|
|
10
|
+
Ensure that you have included the necessary scripts and styles in your HTML file.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<link rel="stylesheet" href="https://login.eka.care/assets/css/index.css" />
|
|
14
|
+
<script type="module" src="https://login.eka.care/assets/js/lo-fe-main.js"></script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. **Prepare the Container Element**:
|
|
18
|
+
Create a container element in your HTML where the React app will be mounted.
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<div id="lofe_root"></div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
3. **Implement Callback Functions**:
|
|
25
|
+
Define the `onSuccess` and `onError` callback functions to handle authentication outcomes.
|
|
26
|
+
|
|
27
|
+
**onSuccess**: This function is called when the authentication is successful. Use it to process the authenticated user's data or redirect them within your application.
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
function onSuccess(params) {
|
|
31
|
+
// Handle successful authentication
|
|
32
|
+
console.log('Authentication successful:', params);
|
|
33
|
+
// Redirect user or update UI accordingly
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- @param params - An object containing authentication tokens and the user's profile information.
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
{
|
|
41
|
+
response: {
|
|
42
|
+
txn_id: "Transaction id string",
|
|
43
|
+
skip_state: 1,
|
|
44
|
+
method: 2,
|
|
45
|
+
data: {
|
|
46
|
+
tokens: {
|
|
47
|
+
sess: "A string representing the session token.",
|
|
48
|
+
refresh: "A string representing the refresh token.",
|
|
49
|
+
},
|
|
50
|
+
profile: "The user's profile.",
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**onError**: This function is invoked when there is an error during authentication. Use it to handle errors, display error messages, or perform logging.
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
function onError(params) {
|
|
60
|
+
// Handle authentication error
|
|
61
|
+
console.error('Authentication error:', params);
|
|
62
|
+
// Display error message to the user or take corrective action
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- @param params - An object containing authentication error.
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
{
|
|
70
|
+
error: 'Error message';
|
|
71
|
+
response: {
|
|
72
|
+
txn_id: "Transaction id string",
|
|
73
|
+
skip_state: 1,
|
|
74
|
+
method: 2,
|
|
75
|
+
error: 'error message from api'
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
4. **Initialize the App**:
|
|
81
|
+
Call the `window.initAuthApp` function with the required parameters.
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<script>
|
|
85
|
+
window.onload = function () {
|
|
86
|
+
window.initAuthApp({
|
|
87
|
+
clientId: 'your_client_id',
|
|
88
|
+
containerId: 'lofe_root',
|
|
89
|
+
workspaceName: 'your_workspace_name', // Optional
|
|
90
|
+
urlParams: { next_url: 'next_url' }, // Optional
|
|
91
|
+
method: 'email_mobile', // Optional
|
|
92
|
+
onSuccess: function (params) {
|
|
93
|
+
// Handle success
|
|
94
|
+
},
|
|
95
|
+
onError: function (params) {
|
|
96
|
+
// Handle error
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`window.initAuthApp` returns an unmount function to remove the Login app.
|
|
104
|
+
|
|
105
|
+
5. **Close the App**:
|
|
106
|
+
To unmount the Lofe app and clear the store, call the `window.closeAuthApp` function or the function that is returned by `window.initAuthApp`
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<script>
|
|
110
|
+
window.closeAuthApp();
|
|
111
|
+
</script>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
By following these steps, you can successfully initialize and use the login frontend app for Eka Care.
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eka-care/abha-stg",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "VITE_APP_MODE=DEBUG vite",
|
|
7
|
+
"build": "tsc -b && vite build",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@elixir/icons": "*",
|
|
13
|
+
"@elixir/utils": "*",
|
|
14
|
+
"@node-minify/clean-css": "^9.0.1",
|
|
15
|
+
"@node-minify/core": "^9.0.2",
|
|
16
|
+
"@tanstack/react-query": "^5.63.0",
|
|
17
|
+
"apis": "*",
|
|
18
|
+
"glob-all": "^3.3.1",
|
|
19
|
+
"purgecss": "^7.0.2",
|
|
20
|
+
"react": "^18.2.0",
|
|
21
|
+
"react-dom": "^18.2.0",
|
|
22
|
+
"react-router-dom": "^6.28.0",
|
|
23
|
+
"ui": "*",
|
|
24
|
+
"zustand": "^5.0.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@elixir/tailwind-config": "*",
|
|
28
|
+
"@eslint/js": "^9.13.0",
|
|
29
|
+
"@types/react": "^18.3.12",
|
|
30
|
+
"@types/react-dom": "^18.3.1",
|
|
31
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
32
|
+
"autoprefixer": "^10.4.20",
|
|
33
|
+
"eslint": "^9.13.0",
|
|
34
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
35
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
|
36
|
+
"globals": "^15.11.0",
|
|
37
|
+
"postcss": "^8.4.49",
|
|
38
|
+
"prettier": "^3.3.3",
|
|
39
|
+
"tailwindcss": "^3.4.15",
|
|
40
|
+
"typescript": "~5.6.2",
|
|
41
|
+
"typescript-eslint": "^8.11.0",
|
|
42
|
+
"vite": "^5.4.10"
|
|
43
|
+
}
|
|
44
|
+
}
|