Skip to content

Commit e16b0a2

Browse files
authored
Merge pull request #72 from ownpilot/refactor/profilepage-constants
refactor(ui): extract ProfilePage pure data into ProfilePage.constants
2 parents 43a9f55 + 6156441 commit e16b0a2

2 files changed

Lines changed: 107 additions & 90 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* ProfilePage pure data + types.
3+
*
4+
* Extracted from ProfilePage.tsx — no React component logic: the quick-setup
5+
* shape, autonomy/communication/verbosity option tables, and language list.
6+
*/
7+
8+
import { MessageSquare, Building, Sparkles } from '../components/icons';
9+
10+
export interface QuickSetupData {
11+
name: string;
12+
nickname: string;
13+
location: string;
14+
timezone: string;
15+
occupation: string;
16+
language: string;
17+
communicationStyle: 'formal' | 'casual' | 'mixed';
18+
verbosity: 'concise' | 'detailed' | 'mixed';
19+
autonomyLevel: 'none' | 'low' | 'medium' | 'high' | 'full';
20+
}
21+
22+
export interface EditableSection {
23+
hobbies: string[];
24+
skills: string[];
25+
goals: { short: string[]; medium: string[]; long: string[] };
26+
favoriteFoods: string[];
27+
dietaryRestrictions: string[];
28+
allergies: string[];
29+
}
30+
31+
export type TabId = 'home' | 'overview' | 'identity' | 'behavior' | 'memories' | 'advanced';
32+
33+
export const DEFAULT_QUICK_SETUP: QuickSetupData = {
34+
name: '',
35+
nickname: '',
36+
location: '',
37+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
38+
occupation: '',
39+
language: navigator.language.split('-')[0] || 'en',
40+
communicationStyle: 'casual',
41+
verbosity: 'detailed',
42+
autonomyLevel: 'medium',
43+
};
44+
45+
export const AUTONOMY_DESCRIPTIONS: Record<string, string> = {
46+
none: 'AI always asks before taking any action',
47+
low: 'AI can read freely, asks for writes',
48+
medium: 'AI acts freely, asks for destructive actions',
49+
high: 'AI acts autonomously, rarely asks',
50+
full: 'Full autonomy - AI makes all decisions',
51+
};
52+
53+
export const AUTONOMY_COLORS: Record<string, string> = {
54+
none: 'text-blue-500 bg-blue-500/10 border-blue-500/20',
55+
low: 'text-emerald-500 bg-emerald-500/10 border-emerald-500/20',
56+
medium: 'text-amber-500 bg-amber-500/10 border-amber-500/20',
57+
high: 'text-orange-500 bg-orange-500/10 border-orange-500/20',
58+
full: 'text-purple-500 bg-purple-500/10 border-purple-500/20',
59+
};
60+
61+
export const COMMUNICATION_STYLES: {
62+
value: QuickSetupData['communicationStyle'];
63+
label: string;
64+
icon: typeof MessageSquare;
65+
desc: string;
66+
}[] = [
67+
{ value: 'formal', label: 'Formal', icon: Building, desc: 'Professional and polite' },
68+
{ value: 'casual', label: 'Casual', icon: MessageSquare, desc: 'Friendly and relaxed' },
69+
{ value: 'mixed', label: 'Mixed', icon: Sparkles, desc: 'Adapts to context' },
70+
];
71+
72+
export const VERBOSITY_OPTIONS: {
73+
value: QuickSetupData['verbosity'];
74+
label: string;
75+
desc: string;
76+
}[] = [
77+
{ value: 'concise', label: 'Concise', desc: 'Brief, to-the-point responses' },
78+
{ value: 'detailed', label: 'Detailed', desc: 'Comprehensive explanations' },
79+
{ value: 'mixed', label: 'Adaptive', desc: 'Adjusts based on context' },
80+
];
81+
82+
export const LANGUAGES = [
83+
{ code: 'en', name: 'English', flag: '🇺🇸' },
84+
{ code: 'tr', name: 'Turkish', flag: '🇹🇷' },
85+
{ code: 'de', name: 'German', flag: '🇩🇪' },
86+
{ code: 'fr', name: 'French', flag: '🇫🇷' },
87+
{ code: 'es', name: 'Spanish', flag: '🇪🇸' },
88+
{ code: 'it', name: 'Italian', flag: '🇮🇹' },
89+
{ code: 'pt', name: 'Portuguese', flag: '🇵🇹' },
90+
{ code: 'ru', name: 'Russian', flag: '🇷🇺' },
91+
{ code: 'zh', name: 'Chinese', flag: '🇨🇳' },
92+
{ code: 'ja', name: 'Japanese', flag: '🇯🇵' },
93+
{ code: 'ko', name: 'Korean', flag: '🇰🇷' },
94+
{ code: 'ar', name: 'Arabic', flag: '🇸🇦' },
95+
{ code: 'nl', name: 'Dutch', flag: '🇳🇱' },
96+
{ code: 'pl', name: 'Polish', flag: '🇵🇱' },
97+
{ code: 'sv', name: 'Swedish', flag: '🇸🇪' },
98+
];

packages/ui/src/pages/ProfilePage.tsx

Lines changed: 9 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -50,101 +50,20 @@ import { memoriesApi } from '../api/endpoints/personal-data';
5050
import { InferredFactsPanel } from './profile/InferredFactsPanel';
5151
import type { ProfileData } from '../api';
5252
import type { Memory } from '../api/types';
53+
import {
54+
DEFAULT_QUICK_SETUP,
55+
AUTONOMY_DESCRIPTIONS,
56+
AUTONOMY_COLORS,
57+
COMMUNICATION_STYLES,
58+
VERBOSITY_OPTIONS,
59+
LANGUAGES,
60+
} from './ProfilePage.constants';
61+
import type { QuickSetupData, EditableSection, TabId } from './ProfilePage.constants';
5362

5463
// =============================================================================
5564
// Types
5665
// =============================================================================
5766

58-
interface QuickSetupData {
59-
name: string;
60-
nickname: string;
61-
location: string;
62-
timezone: string;
63-
occupation: string;
64-
language: string;
65-
communicationStyle: 'formal' | 'casual' | 'mixed';
66-
verbosity: 'concise' | 'detailed' | 'mixed';
67-
autonomyLevel: 'none' | 'low' | 'medium' | 'high' | 'full';
68-
}
69-
70-
interface EditableSection {
71-
hobbies: string[];
72-
skills: string[];
73-
goals: { short: string[]; medium: string[]; long: string[] };
74-
favoriteFoods: string[];
75-
dietaryRestrictions: string[];
76-
allergies: string[];
77-
}
78-
79-
type TabId = 'home' | 'overview' | 'identity' | 'behavior' | 'memories' | 'advanced';
80-
81-
// =============================================================================
82-
// Constants
83-
// =============================================================================
84-
85-
const DEFAULT_QUICK_SETUP: QuickSetupData = {
86-
name: '',
87-
nickname: '',
88-
location: '',
89-
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
90-
occupation: '',
91-
language: navigator.language.split('-')[0] || 'en',
92-
communicationStyle: 'casual',
93-
verbosity: 'detailed',
94-
autonomyLevel: 'medium',
95-
};
96-
97-
const AUTONOMY_DESCRIPTIONS: Record<string, string> = {
98-
none: 'AI always asks before taking any action',
99-
low: 'AI can read freely, asks for writes',
100-
medium: 'AI acts freely, asks for destructive actions',
101-
high: 'AI acts autonomously, rarely asks',
102-
full: 'Full autonomy - AI makes all decisions',
103-
};
104-
105-
const AUTONOMY_COLORS: Record<string, string> = {
106-
none: 'text-blue-500 bg-blue-500/10 border-blue-500/20',
107-
low: 'text-emerald-500 bg-emerald-500/10 border-emerald-500/20',
108-
medium: 'text-amber-500 bg-amber-500/10 border-amber-500/20',
109-
high: 'text-orange-500 bg-orange-500/10 border-orange-500/20',
110-
full: 'text-purple-500 bg-purple-500/10 border-purple-500/20',
111-
};
112-
113-
const COMMUNICATION_STYLES: {
114-
value: QuickSetupData['communicationStyle'];
115-
label: string;
116-
icon: typeof MessageSquare;
117-
desc: string;
118-
}[] = [
119-
{ value: 'formal', label: 'Formal', icon: Building, desc: 'Professional and polite' },
120-
{ value: 'casual', label: 'Casual', icon: MessageSquare, desc: 'Friendly and relaxed' },
121-
{ value: 'mixed', label: 'Mixed', icon: Sparkles, desc: 'Adapts to context' },
122-
];
123-
124-
const VERBOSITY_OPTIONS: { value: QuickSetupData['verbosity']; label: string; desc: string }[] = [
125-
{ value: 'concise', label: 'Concise', desc: 'Brief, to-the-point responses' },
126-
{ value: 'detailed', label: 'Detailed', desc: 'Comprehensive explanations' },
127-
{ value: 'mixed', label: 'Adaptive', desc: 'Adjusts based on context' },
128-
];
129-
130-
const LANGUAGES = [
131-
{ code: 'en', name: 'English', flag: '🇺🇸' },
132-
{ code: 'tr', name: 'Turkish', flag: '🇹🇷' },
133-
{ code: 'de', name: 'German', flag: '🇩🇪' },
134-
{ code: 'fr', name: 'French', flag: '🇫🇷' },
135-
{ code: 'es', name: 'Spanish', flag: '🇪🇸' },
136-
{ code: 'it', name: 'Italian', flag: '🇮🇹' },
137-
{ code: 'pt', name: 'Portuguese', flag: '🇵🇹' },
138-
{ code: 'ru', name: 'Russian', flag: '🇷🇺' },
139-
{ code: 'zh', name: 'Chinese', flag: '🇨🇳' },
140-
{ code: 'ja', name: 'Japanese', flag: '🇯🇵' },
141-
{ code: 'ko', name: 'Korean', flag: '🇰🇷' },
142-
{ code: 'ar', name: 'Arabic', flag: '🇸🇦' },
143-
{ code: 'nl', name: 'Dutch', flag: '🇳🇱' },
144-
{ code: 'pl', name: 'Polish', flag: '🇵🇱' },
145-
{ code: 'sv', name: 'Swedish', flag: '🇸🇪' },
146-
];
147-
14867
// =============================================================================
14968
// Utility Components
15069
// =============================================================================

0 commit comments

Comments
 (0)