feat(phase5): deploy keys, profile editing, organization creation
- API: repo deploy keys (list/add/delete), user settings GET/PATCH, org create - hooks: useRepoKeys/useAddRepoKey/useDeleteRepoKey; useUserSettings, useUpdateUserSettings, useCreateOrg - screens: DeployKeys, Profile (edit), CreateOrg; wired into RepoSettings, Settings and Organizations - endpoint body-shape tests for repo update, release, deploy key, user settings, org create and Action run filters (120 tests total)
This commit is contained in:
1 parent
fa1ebc9184
commit
6d0b536009
17 files changed
+738
-8
No files matched your search
@@ -0,0 +1,101 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Field } from '@/components/ui/field';
|
||||
import { TextArea } from '@/components/ui/text-area';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import type { UserSettings } from '@/core/api/types';
|
||||
import { useUpdateUserSettings, useUserSettings } from '@/features/profile/queries';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
|
||||
/** Edit the signed-in user's public profile. */
|
||||
export function ProfileScreen() {
|
||||
const { t } = useTranslation();
|
||||
const query = useUserSettings();
|
||||
|
||||
if (query.isPending) return <LoadingView />;
|
||||
if (query.isError) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(query.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void query.refetch()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <ProfileForm key={query.dataUpdatedAt} settings={query.data ?? {}} />;
|
||||
}
|
||||
|
||||
function ProfileForm({ settings }: { settings: UserSettings }) {
|
||||
const { t } = useTranslation();
|
||||
const update = useUpdateUserSettings();
|
||||
|
||||
const [fullName, setFullName] = useState(settings.full_name ?? '');
|
||||
const [bio, setBio] = useState(settings.description ?? '');
|
||||
const [website, setWebsite] = useState(settings.website ?? '');
|
||||
const [location, setLocation] = useState(settings.location ?? '');
|
||||
|
||||
const save = () => {
|
||||
update.mutate(
|
||||
{
|
||||
full_name: fullName.trim(),
|
||||
description: bio.trim(),
|
||||
website: website.trim(),
|
||||
location: location.trim(),
|
||||
},
|
||||
{
|
||||
onSuccess: () => Alert.alert(t('repoSettings.savedTitle'), t('profile.savedBody')),
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<Field label={t('profile.fullName')} value={fullName} onChangeText={setFullName} autoCapitalize="words" />
|
||||
<TextArea
|
||||
label={t('profile.bio')}
|
||||
value={bio}
|
||||
onChangeText={setBio}
|
||||
autoCapitalize="sentences"
|
||||
autoCorrect
|
||||
minHeight={100}
|
||||
/>
|
||||
<Field
|
||||
label={t('repoSettings.website')}
|
||||
value={website}
|
||||
onChangeText={setWebsite}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
keyboardType="url"
|
||||
/>
|
||||
<Field label={t('profile.location')} value={location} onChangeText={setLocation} autoCapitalize="words" />
|
||||
|
||||
{update.isError ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{apiErrorMessage(update.error, t)}
|
||||
</AppText>
|
||||
) : null}
|
||||
|
||||
<Button
|
||||
label={t('common.save')}
|
||||
onPress={save}
|
||||
loading={update.isPending}
|
||||
fullWidth
|
||||
testID="profile-save"
|
||||
/>
|
||||
<View style={styles.spacer} />
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
spacer: { height: spacing.xl },
|
||||
});
|
||||
Reference in new issue
Block a user