mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
feat(mobile): the admin services section gets what the desktop tab has
- Place search and routing as one card, as on the desktop: TREK's own services, today's allowance with a new identity behind a confirm sheet (MAdminServiceQuota), sharing place details (MAdminPlaceContrib), the transit backend and the place search provider as TREK selects, and the search log. - The key card holds Google (with its options and the daily request cap, MAdminGoogleDailyLimit), Unsplash and Amap, in the desktop order. - The logic both views need moves into one place: the transit switch into useAdminSettingsActions, the allowance figures into serviceIdentityModel, and the share-place-details panel into usePlaceContribPanel. - MAdminSettingsSection renders each section in a function of its own. - Tests follow the split admin sections (Save order, 2FA label, field marker).
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { TransitKeySource, TransitProvider } from '@trek/shared';
|
||||
import { adminApi, authApi } from '../../api/client';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import { getApiErrorMessage } from '../../types';
|
||||
@@ -28,6 +29,9 @@ interface SettingsActionsHost {
|
||||
setPlacesEnrichEnabled: Flag;
|
||||
setPlaceShadowEnabledState: Flag;
|
||||
setPlaceShadowEnabled: Flag;
|
||||
transitProvider: TransitProvider;
|
||||
setTransitProviderState: (provider: TransitProvider) => void;
|
||||
setTransitGoogleKeySource: (source: TransitKeySource) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,9 +90,29 @@ export function useAdminSettingsActions(admin: SettingsActionsHost, t: Translati
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The transit backend (#1699): shown at once, and back to the previous one with a
|
||||
* word when the save fails, so a select that springs back does not read as broken.
|
||||
* A pick of the provider already selected writes nothing: the route is audited.
|
||||
*/
|
||||
const changeTransitProvider = async (value: string) => {
|
||||
if (value === admin.transitProvider) return;
|
||||
const next: TransitProvider = value === 'google' ? 'google' : 'transitous';
|
||||
const previous = admin.transitProvider;
|
||||
admin.setTransitProviderState(next);
|
||||
try {
|
||||
const saved = await adminApi.updateTransitProvider(next);
|
||||
admin.setTransitGoogleKeySource(saved.googleKeySource);
|
||||
} catch (err: unknown) {
|
||||
admin.setTransitProviderState(previous);
|
||||
toast.error(getApiErrorMessage(err, t('common.error')));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
saveOidc,
|
||||
saveFileTypes,
|
||||
changeTransitProvider,
|
||||
togglePlacesPhotos: placeSwitch(admin.setPlacesPhotosEnabledState, admin.setPlacesPhotosEnabled, (enabled) =>
|
||||
adminApi.updatePlacesPhotos(enabled)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user