CognxSafeTrack commited on
Commit
38123ba
·
1 Parent(s): 0c9a5b4

fix: resolve missing API_URL and refactor payment portal call

Browse files
apps/admin/src/pages/SettingsPage.tsx CHANGED
@@ -227,22 +227,11 @@ export default function SettingsPage() {
227
  <button
228
  onClick={async () => {
229
  try {
230
- const apiKey = localStorage.getItem('edtech_admin_key');
231
- const res = await fetch(`${API_URL}/v1/payments/customer-portal`, {
232
- method: 'POST',
233
- headers: {
234
- 'Authorization': `Bearer ${apiKey}`,
235
- 'x-organization-id': selectedOrgId!
236
- }
237
- });
238
- if (res.ok) {
239
- const { url } = await res.json();
240
- window.location.href = url;
241
- } else {
242
- alert('Impossible d\'ouvrir le portail de facturation.');
243
- }
244
  } catch (err) {
245
  console.error(err);
 
246
  }
247
  }}
248
  className="w-full py-3 bg-indigo-600 text-white rounded-xl font-bold hover:bg-indigo-700 transition-all flex items-center justify-center gap-2"
 
227
  <button
228
  onClick={async () => {
229
  try {
230
+ const { url } = await api.post('/v1/payments/customer-portal', {}, token, selectedOrgId);
231
+ window.location.href = url;
 
 
 
 
 
 
 
 
 
 
 
 
232
  } catch (err) {
233
  console.error(err);
234
+ alert('Impossible d\'ouvrir le portail de facturation.');
235
  }
236
  }}
237
  className="w-full py-3 bg-indigo-600 text-white rounded-xl font-bold hover:bg-indigo-700 transition-all flex items-center justify-center gap-2"