@igamingcareer/igaming-components 1.0.82 → 1.0.83
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 +112 -0
- package/dist/index.js +264 -264
- package/dist/index.mjs +5459 -5304
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -69,6 +69,118 @@ export function Example() {
|
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
## Follow company callbacks (CompanyCard + CompanyDetail)
|
|
73
|
+
|
|
74
|
+
The company list/detail components are stateless and emit follow actions so your app can handle API calls. Use the follow props to control state and provide callbacks for follow/unfollow actions.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { useState } from "react";
|
|
78
|
+
import {
|
|
79
|
+
CompanyCard,
|
|
80
|
+
CompanyDetail,
|
|
81
|
+
type CompanyFollowActionPayload,
|
|
82
|
+
} from "@igamingcareer/igaming-components";
|
|
83
|
+
|
|
84
|
+
export function FollowCompaniesExample({ company }: { company: Company }) {
|
|
85
|
+
const [isFollowing, setIsFollowing] = useState(false);
|
|
86
|
+
const [followLoading, setFollowLoading] = useState(false);
|
|
87
|
+
|
|
88
|
+
const handleToggleFollow = async (companyId: string, nextIsFollowing: boolean) => {
|
|
89
|
+
setFollowLoading(true);
|
|
90
|
+
try {
|
|
91
|
+
// call your API here
|
|
92
|
+
// await api.followCompany({ companyId, follow: nextIsFollowing });
|
|
93
|
+
setIsFollowing(nextIsFollowing);
|
|
94
|
+
} finally {
|
|
95
|
+
setFollowLoading(false);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleFollowAction = (payload: CompanyFollowActionPayload) => {
|
|
100
|
+
// optional: analytics or logging
|
|
101
|
+
console.log("follow action", payload);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<CompanyCard
|
|
107
|
+
company={{ ...company, isFollowing }}
|
|
108
|
+
isFollowing={isFollowing}
|
|
109
|
+
followLoading={followLoading}
|
|
110
|
+
onToggleFollow={handleToggleFollow}
|
|
111
|
+
onFollowAction={handleFollowAction}
|
|
112
|
+
/>
|
|
113
|
+
|
|
114
|
+
<CompanyDetail
|
|
115
|
+
company={{ ...company, isFollowing }}
|
|
116
|
+
isFollowing={isFollowing}
|
|
117
|
+
followLoading={followLoading}
|
|
118
|
+
onToggleFollow={handleToggleFollow}
|
|
119
|
+
onFollowAction={handleFollowAction}
|
|
120
|
+
/>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Use `followDisabled` to block interactions for unauthenticated users, and `isFollowing` to keep the UI in sync with your data source.
|
|
127
|
+
|
|
128
|
+
## Save company callbacks (CompanyCard + CompanyDetail)
|
|
129
|
+
|
|
130
|
+
The company components also emit save events so host apps can manage bookmarking without API logic inside the library. Use the save props to track state and respond to user interactions.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { useState } from "react";
|
|
134
|
+
import {
|
|
135
|
+
CompanyCard,
|
|
136
|
+
CompanyDetail,
|
|
137
|
+
type SaveCompanyPayload,
|
|
138
|
+
} from "@igamingcareer/igaming-components";
|
|
139
|
+
|
|
140
|
+
export function SaveCompaniesExample({ company }: { company: Company }) {
|
|
141
|
+
const [isSaved, setIsSaved] = useState(false);
|
|
142
|
+
const [saveLoading, setSaveLoading] = useState(false);
|
|
143
|
+
|
|
144
|
+
const handleToggleSave = async (companyId: string, nextIsSaved: boolean) => {
|
|
145
|
+
setSaveLoading(true);
|
|
146
|
+
try {
|
|
147
|
+
// call your API here
|
|
148
|
+
// await api.saveCompany({ companyId, save: nextIsSaved });
|
|
149
|
+
setIsSaved(nextIsSaved);
|
|
150
|
+
} finally {
|
|
151
|
+
setSaveLoading(false);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const handleSaveAction = (payload: SaveCompanyPayload) => {
|
|
156
|
+
// optional: analytics or logging
|
|
157
|
+
console.log("save action", payload);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
<CompanyCard
|
|
163
|
+
company={{ ...company, isSaved }}
|
|
164
|
+
isSaved={isSaved}
|
|
165
|
+
saveLoading={saveLoading}
|
|
166
|
+
onToggleSave={handleToggleSave}
|
|
167
|
+
onSaveAction={handleSaveAction}
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
<CompanyDetail
|
|
171
|
+
company={{ ...company, isSaved }}
|
|
172
|
+
isSaved={isSaved}
|
|
173
|
+
saveLoading={saveLoading}
|
|
174
|
+
onToggleSave={handleToggleSave}
|
|
175
|
+
onSaveAction={handleSaveAction}
|
|
176
|
+
/>
|
|
177
|
+
</>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Use `saveDisabled` to disable the action for unauthenticated users, and keep `isSaved` in sync with your data source.
|
|
183
|
+
|
|
72
184
|
## CV upload from the dashboard
|
|
73
185
|
|
|
74
186
|
The dashboard emits CV upload events so the host application can upload, store,
|