@minnai/create-aura-app 0.0.12 → 0.0.15

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/templates/starter/package.json +2 -2
  3. package/templates/starter/src/ambiance/index.ts +1 -3
  4. package/templates/starter/src/components/Playground/Playground.tsx +1 -1
  5. package/templates/starter/src/src/App.css +0 -32
  6. package/templates/starter/src/src/App.tsx +0 -82
  7. package/templates/starter/src/src/ambiance/currency-air/index.tsx +0 -25
  8. package/templates/starter/src/src/ambiance/currency-air/logic.ts +0 -49
  9. package/templates/starter/src/src/ambiance/currency-air/manifest.ts +0 -15
  10. package/templates/starter/src/src/ambiance/currency-air/resources.ts +0 -16
  11. package/templates/starter/src/src/ambiance/currency-air/ui/index.tsx +0 -42
  12. package/templates/starter/src/src/ambiance/index.ts +0 -48
  13. package/templates/starter/src/src/ambiance/stocks-air/index.ts +0 -3
  14. package/templates/starter/src/src/ambiance/stocks-air/index.tsx +0 -28
  15. package/templates/starter/src/src/ambiance/stocks-air/logic.ts +0 -87
  16. package/templates/starter/src/src/ambiance/stocks-air/manifest.ts +0 -15
  17. package/templates/starter/src/src/ambiance/stocks-air/resources.ts +0 -23
  18. package/templates/starter/src/src/ambiance/stocks-air/ui/index.tsx +0 -67
  19. package/templates/starter/src/src/assets/react.svg +0 -1
  20. package/templates/starter/src/src/components/AnalyticsTracker.tsx +0 -13
  21. package/templates/starter/src/src/components/Playground/CodeEditor.tsx +0 -121
  22. package/templates/starter/src/src/components/Playground/Debugger.tsx +0 -71
  23. package/templates/starter/src/src/components/Playground/Playground.tsx +0 -221
  24. package/templates/starter/src/src/components/Playground/Sidebar.tsx +0 -68
  25. package/templates/starter/src/src/components/ProjectSidebar/ProjectSidebar.tsx +0 -219
  26. package/templates/starter/src/src/components/TourGuide/TourGuide.tsx +0 -16
  27. package/templates/starter/src/src/components/TourGuide/index.ts +0 -1
  28. package/templates/starter/src/src/components/TourGuide/tour-flow.yaml +0 -137
  29. package/templates/starter/src/src/components/TourGuide/useTourEngine.ts +0 -376
  30. package/templates/starter/src/src/index.css +0 -68
  31. package/templates/starter/src/src/main.tsx +0 -10
  32. package/templates/starter/src/src/services/AnalyticsService.ts +0 -181
  33. package/templates/starter/src/src/types/ContextHandler.ts +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minnai/create-aura-app",
3
- "version": "0.0.12",
3
+ "version": "0.0.15",
4
4
  "description": "Scaffolding tool for new Aura projects",
5
5
  "bin": "dist/index.js",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "preview": "vite preview"
11
11
  },
12
12
  "engines": {
13
- "node": ">=22.0.0"
13
+ "node": ">=18.0.0"
14
14
  },
15
15
  "dependencies": {
16
16
  "@minnai/aura": "^0.1.6",
@@ -35,6 +35,6 @@
35
35
  "globals": "^16.5.0",
36
36
  "typescript": "~5.9.3",
37
37
  "typescript-eslint": "^8.46.4",
38
- "vite": "^7.2.4"
38
+ "vite": "^5.4.11"
39
39
  }
40
40
  }
@@ -1,7 +1,6 @@
1
1
  import { atmosphere } from '@minnai/aura/atmosphere';
2
2
  import TasksAIR from '@minnai/aura/atmosphere/tasks';
3
3
  import YouTubeAIR from '@minnai/aura/atmosphere/youtube-player';
4
- import NoteTakerAIR from '@minnai/aura/atmosphere/note-taker';
5
4
 
6
5
  // Local Ambiance
7
6
  import { StocksManifest, Component as StocksComponent, resources as stocksResources } from './stocks-air';
@@ -12,7 +11,7 @@ export const registerExampleAIRs = () => {
12
11
  // 1. Register Standard AIRs (Core)
13
12
  // The Standard AIRs export a wrapper object { manifest, resources, component }
14
13
  // We need to flatten this to match AIRManifest { id, meta, component }
15
- [TasksAIR, YouTubeAIR, NoteTakerAIR].forEach((air: any) => {
14
+ [TasksAIR, YouTubeAIR].forEach((air: any) => {
16
15
  if (LOCAL_AIRS.includes(air.manifest.id)) {
17
16
  atmosphere.register({
18
17
  ...air.manifest,
@@ -40,7 +39,6 @@ export const registerExampleAIRs = () => {
40
39
  };
41
40
 
42
41
  export const EXAMPLE_AIRS = [
43
- NoteTakerAIR.manifest,
44
42
  YouTubeAIR.manifest,
45
43
  TasksAIR.manifest,
46
44
  StocksManifest,
@@ -13,7 +13,7 @@ export function Playground() {
13
13
  const [activeFile, setActiveFile] = useState<string | null>(null);
14
14
  const [fileContent, setFileContent] = useState<string>('');
15
15
 
16
- const BUILTIN_AIRS = ['note-taker-air', 'youtube-player-air', 'tasks-air'];
16
+ const BUILTIN_AIRS = ['youtube-player-air', 'tasks-air'];
17
17
 
18
18
  const handleSelect = async (id: string) => {
19
19
  setSelectedId(id);
@@ -1,32 +0,0 @@
1
- #root {
2
- width: 100vw;
3
- height: 100vh;
4
- margin: 0;
5
- padding: 0;
6
- }
7
-
8
- :root {
9
- --bg-app: #f5f5f7;
10
- --bg-sidebar: #ffffff;
11
- --bg-primary: #ffffff;
12
- --bg-secondary: #f0f0f5;
13
- --text-primary: #1d1d1f;
14
- --text-secondary: #86868b;
15
- --text-tertiary: #d2d2d7;
16
- --border-color: #e5e5e5;
17
- --border-subtle: rgba(0, 0, 0, 0.05);
18
- --accent-primary: #007aff;
19
- --accent-hover: #0062cc;
20
- }
21
-
22
- * {
23
- box-sizing: border-box;
24
- }
25
-
26
- body {
27
- margin: 0;
28
- padding: 0;
29
- background-color: var(--bg-app);
30
- color: var(--text-primary);
31
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
32
- }
@@ -1,82 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import { BrowserRouter, Routes, Route, useSearchParams } from 'react-router-dom';
3
- import { Space, ControllerProvider, ChatInterface, createStorage } from '@minnai/aura';
4
- import { AuraProvider } from '@minnai/aura/sdk';
5
- import { flux } from '@minnai/aura/flux/index';
6
- import { registerExampleAIRs } from './ambiance';
7
- import { AnalyticsTracker } from './components/AnalyticsTracker';
8
- import { TourGuide } from './components/TourGuide';
9
- import { analyticsService } from './services/AnalyticsService';
10
- import { ProjectSidebar } from './components/ProjectSidebar/ProjectSidebar';
11
- import './App.css';
12
-
13
- const baseAuraConfig = {
14
- llm: {
15
- gatewayUrl: 'https://auraproxy-7bpt7e5tua-uc.a.run.app',
16
- proxyUrl: 'https://auraproxy-7bpt7e5tua-uc.a.run.app'
17
- },
18
- apiUrl: 'https://auraproxy-7bpt7e5tua-uc.a.run.app',
19
- storage: {
20
- documents: { driver: 'indexeddb' as any },
21
- objects: { driver: 'indexeddb' as any }
22
- }
23
- };
24
-
25
- createStorage(baseAuraConfig.storage);
26
-
27
- const defaultProjectId = 'aura-tour-demo';
28
-
29
- function Home() {
30
- const [searchParams] = useSearchParams();
31
- const projectId = searchParams.get('project') || defaultProjectId;
32
-
33
- return (
34
- <div style={{ display: 'flex', height: '100vh', width: '100vw', background: '#f5f5f7' }}>
35
- {/* Reset explicit projectId passing to TourController if it reads from hook, or pass it */}
36
- {/* We will pass it to keep it pure if possible, or render it here knowing it can use hooks */}
37
- <TourGuide projectId={projectId} />
38
- <ProjectSidebar currentProjectId={projectId} />
39
- <aside style={{
40
- width: '350px',
41
- borderRight: '1px solid #ddd',
42
- background: 'white',
43
- display: 'flex',
44
- flexDirection: 'column',
45
- zIndex: 10
46
- }}>
47
- <ChatInterface
48
- placeholder="Talk to Aura..."
49
- />
50
- </aside>
51
- <main style={{ flex: 1, position: 'relative', overflow: 'hidden', background: '#fff' }}>
52
- <Space projectId={projectId} />
53
- </main>
54
- </div>
55
- );
56
- }
57
-
58
- function App() {
59
- const [sessionId] = useState(() => 'sess_' + Math.random().toString(36).substr(2, 9));
60
- const config = { ...baseAuraConfig, sessionId };
61
-
62
- useEffect(() => {
63
- registerExampleAIRs();
64
- analyticsService.startTTVTimer();
65
- (window as any).flux = flux;
66
- }, []);
67
-
68
- return (
69
- <AuraProvider config={config}>
70
- <ControllerProvider>
71
- <BrowserRouter>
72
- <AnalyticsTracker />
73
- <Routes>
74
- <Route path="/" element={<Home />} />
75
- </Routes>
76
- </BrowserRouter>
77
- </ControllerProvider>
78
- </AuraProvider>
79
- );
80
- }
81
-
82
- export default App;
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { CurrencyManifest } from './manifest';
3
- import { resources } from './resources';
4
- import CurrencyUI from './ui';
5
- import { useCurrencyLogic } from './logic';
6
-
7
- const CurrencyAIR = React.forwardRef<any, any>((props, ref) => {
8
- const logic = useCurrencyLogic({ ...props, resources });
9
-
10
- React.useImperativeHandle(ref, () => ({
11
- getContext: async () => ({ from: logic.from, to: logic.to, amount: logic.amount, result: logic.result }),
12
- capabilities: ['currency-conversion']
13
- }));
14
-
15
- return <CurrencyUI {...logic} />;
16
- });
17
-
18
- export default {
19
- manifest: CurrencyManifest,
20
- resources,
21
- component: CurrencyAIR
22
- };
23
- export { CurrencyManifest } from './manifest';
24
- export { resources } from './resources';
25
- export const Component = CurrencyAIR;
@@ -1,49 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import { flux } from '@minnai/aura/flux/index';
3
-
4
- export function useCurrencyLogic(props: any) {
5
- const [amount, setAmount] = useState(1);
6
- const [from, setFrom] = useState('USD');
7
- const [to, setTo] = useState('EUR');
8
- const [result, setResult] = useState<number | null>(null);
9
- const [loading, setLoading] = useState(false);
10
- const [error, setError] = useState<string | null>(null);
11
-
12
- const { resources } = props;
13
- // BUG: This should use resources.api.currency.rates.config.url instead!
14
- // It's currently hardcoded to the wrong file name
15
- const API_URL = '/dollar.json'; // Should be '/usd.json'!
16
-
17
- useEffect(() => {
18
- convert();
19
- }, []);
20
-
21
- const convert = async () => {
22
- setLoading(true);
23
- setError(null);
24
- try {
25
- const response = await fetch(API_URL);
26
- if (!response.ok) throw new Error(`Failed to fetch rates: ${response.statusText}`);
27
- const data = await response.json();
28
- const rate = data.rates[to];
29
- const finalResult = amount * rate;
30
- setResult(finalResult);
31
- flux.dispatch({
32
- type: 'UPDATE_STATE',
33
- payload: { airId: 'currency-air', amount, from, to, result: finalResult },
34
- to: 'all'
35
- });
36
- } catch (err: any) {
37
- setError(err.message || "Conversion failed");
38
- flux.dispatch({
39
- type: 'AIR_ERROR',
40
- payload: { airId: 'currency-air', error: err.message || "Conversion failed" },
41
- to: 'all'
42
- });
43
- } finally {
44
- setLoading(false);
45
- }
46
- };
47
-
48
- return { amount, setAmount, from, setFrom, to, setTo, result, loading, error, convert };
49
- }
@@ -1,15 +0,0 @@
1
- export const CurrencyManifest = {
2
- id: 'currency-air',
3
- meta: {
4
- title: 'Currency Converter',
5
- icon: '💱',
6
- description: 'Convert between different currencies.',
7
- width: 350,
8
- height: 400
9
- },
10
- instructions: {
11
- tasks: {
12
- 'convert': 'Convert an amount from one currency to another.'
13
- }
14
- }
15
- };
@@ -1,16 +0,0 @@
1
- // Currency conversion using local exchange rate data
2
- export const resources = {
3
- api: {
4
- currency: {
5
- rates: {
6
- id: 'local-exchange-rates',
7
- provider: 'static',
8
- config: {
9
- url: '/usd.json', // This should be 'usd.json' not 'dollar.json'!
10
- method: 'GET',
11
- base: 'USD'
12
- }
13
- }
14
- }
15
- }
16
- } as const;
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
-
3
- export default function CurrencyUI({
4
- amount, setAmount, from, setFrom, to, setTo, result, loading, error, convert
5
- }: any) {
6
- return (
7
- <div style={{ paddingTop: 0, height: '100%', display: 'flex', flexDirection: 'column' }}>
8
- <div style={{ marginTop: 10, fontSize: '0.8rem', fontWeight: 600, textTransform: 'uppercase', color: '#888', letterSpacing: '0.5px' }}>Currency Converter</div>
9
- <div style={{ display: 'flex', flexDirection: 'column', gap: 15, marginTop: 20 }}>
10
- <div style={{ display: 'flex', gap: 10 }}>
11
- <input type="number" value={amount} onChange={(e) => setAmount(parseFloat(e.target.value))} style={{ flex: 1, padding: 8, borderRadius: 4, border: '1px solid #ddd' }} />
12
- <select value={from} onChange={(e) => setFrom(e.target.value)} style={{ padding: 8, borderRadius: 4, border: '1px solid #ddd' }}>
13
- <option value="USD">USD</option>
14
- <option value="EUR">EUR</option>
15
- </select>
16
- </div>
17
- <div style={{ textAlign: 'center', color: '#999' }}>⬇️</div>
18
- <div style={{ display: 'flex', gap: 10 }}>
19
- <div style={{ flex: 1, padding: 8, background: '#f5f5f5', borderRadius: 4 }}>{result !== null ? result.toFixed(2) : '-'}</div>
20
- <select value={to} onChange={(e) => setTo(e.target.value)} style={{ padding: 8, borderRadius: 4, border: '1px solid #ddd' }}>
21
- <option value="EUR">EUR</option>
22
- <option value="USD">USD</option>
23
- </select>
24
- </div>
25
- <button onClick={convert} style={{ padding: 10, background: '#007aff', color: 'white', border: 'none', borderRadius: 6, cursor: 'pointer' }}>Convert</button>
26
- </div>
27
- {loading && <div style={{ textAlign: 'center', marginTop: 20, color: '#666' }}>Loading...</div>}
28
- {error && (
29
- <div style={{ marginTop: 20, padding: 15, background: '#fff0f0', border: '1px solid #ffcccc', borderRadius: 8, color: '#d32f2f', fontSize: '0.9rem' }}>
30
- <strong>Error:</strong> {error}
31
- <div style={{ marginTop: 5, fontSize: '0.8rem', opacity: 0.8 }}>File not found: /dollar.json</div>
32
- </div>
33
- )}
34
- {result !== null && !loading && !error && (
35
- <div style={{ marginTop: 20, padding: 15, background: '#e8f5e9', border: '1px solid #c8e6c9', borderRadius: 8, color: '#2e7d32', fontSize: '0.9rem', textAlign: 'center' }}>
36
- <strong>Success!</strong>
37
- <div style={{ fontSize: '1.2rem', fontWeight: 600, marginTop: 5 }}>Result: {result.toFixed(2)} {to}</div>
38
- </div>
39
- )}
40
- </div>
41
- );
42
- }
@@ -1,48 +0,0 @@
1
- import { atmosphere } from '@minnai/aura/atmosphere';
2
- import TasksAIR from '@minnai/aura/atmosphere/tasks';
3
- import YouTubeAIR from '@minnai/aura/atmosphere/youtube-player';
4
- import NoteTakerAIR from '@minnai/aura/atmosphere/note-taker';
5
-
6
- // Local Ambiance
7
- import { StocksManifest, Component as StocksComponent, resources as stocksResources } from './stocks-air';
8
- import { CurrencyManifest, Component as CurrencyComponent, resources as currencyResources } from './currency-air';
9
- import { LOCAL_AIRS } from '../../aura.config';
10
-
11
- export const registerExampleAIRs = () => {
12
- // 1. Register Standard AIRs (Core)
13
- // The Standard AIRs export a wrapper object { manifest, resources, component }
14
- // We need to flatten this to match AIRManifest { id, meta, component }
15
- [TasksAIR, YouTubeAIR, NoteTakerAIR].forEach((air: any) => {
16
- if (LOCAL_AIRS.includes(air.manifest.id)) {
17
- atmosphere.register({
18
- ...air.manifest,
19
- component: air.component,
20
- resources: air.resources
21
- });
22
- }
23
- });
24
-
25
- // 2. Register Local Demo AIRs
26
- if (LOCAL_AIRS.includes(StocksManifest.id)) {
27
- atmosphere.register({
28
- ...StocksManifest,
29
- component: StocksComponent as any,
30
- resources: stocksResources
31
- });
32
- }
33
- if (LOCAL_AIRS.includes(CurrencyManifest.id)) {
34
- atmosphere.register({
35
- ...CurrencyManifest,
36
- component: CurrencyComponent as any,
37
- resources: currencyResources
38
- });
39
- }
40
- };
41
-
42
- export const EXAMPLE_AIRS = [
43
- NoteTakerAIR.manifest,
44
- YouTubeAIR.manifest,
45
- TasksAIR.manifest,
46
- StocksManifest,
47
- CurrencyManifest
48
- ].filter(manifest => LOCAL_AIRS.includes(manifest.id));
@@ -1,3 +0,0 @@
1
- export * from './manifest';
2
- export * from './index.tsx';
3
- export * from './resources';
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import { StocksManifest } from './manifest';
3
- import { resources } from './resources';
4
- import StocksUI from './ui';
5
- import { useStocksLogic } from './logic';
6
-
7
- const StocksAIR = React.forwardRef<any, any>((props, ref) => {
8
- const logic = useStocksLogic({ ...props, resources });
9
-
10
- React.useImperativeHandle(ref, () => ({
11
- getContext: async () => ({
12
- symbol: logic.symbol,
13
- lastPrice: logic.data?.price,
14
- change: logic.data?.changePercent
15
- }),
16
- capabilities: ['market-data']
17
- }));
18
-
19
- return <StocksUI {...logic} onSearch={logic.fetchStock} />;
20
- });
21
-
22
- export default {
23
- manifest: StocksManifest,
24
- resources,
25
- component: StocksAIR
26
- };
27
- export { StocksManifest } from './manifest';
28
- export const Component = StocksAIR;
@@ -1,87 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import { flux } from '@minnai/aura/flux/index';
3
-
4
- export function useStocksLogic(props: any) {
5
- const [symbol, setSymbol] = useState(props.symbol || 'AAPL');
6
- const [data, setData] = useState<any>(null);
7
- const [loading, setLoading] = useState(false);
8
- const [error, setError] = useState<string | null>(null);
9
- const [apiKeyMissing, setApiKeyMissing] = useState(false);
10
-
11
- const { resources } = props;
12
- const apiKey = resources?.keys?.STOCKS_API_KEY;
13
- const apiConfig = resources?.api?.stocks?.timeSeries?.config;
14
-
15
- useEffect(() => {
16
- if (!apiKey || apiKey === 'YOUR_API_KEY' || apiKey.length < 5) {
17
- setApiKeyMissing(true);
18
- flux.dispatch({
19
- type: 'AIR_ERROR',
20
- payload: {
21
- airId: 'stocks-air',
22
- error: '🚨 STOCKS_API_KEY is missing in resources.ts!'
23
- },
24
- to: 'all'
25
- });
26
- return;
27
- }
28
- fetchStock(symbol);
29
- }, [apiKey]);
30
-
31
- const fetchStock = async (sym: string) => {
32
- setLoading(true);
33
- setError(null);
34
- try {
35
- const url = `${apiConfig.url}?function=${apiConfig.params.function}&symbol=${sym}&apikey=${apiKey}`;
36
- const response = await fetch(url);
37
- const json = await response.json();
38
-
39
- if (json['Time Series (Daily)']) {
40
- const timeSeries = json['Time Series (Daily)'];
41
- const dates = Object.keys(timeSeries).sort();
42
- const latestDate = dates[dates.length - 1];
43
- const prevDate = dates[dates.length - 2];
44
-
45
- const latestClose = parseFloat(timeSeries[latestDate]['4. close']);
46
- const prevClose = parseFloat(timeSeries[prevDate]['4. close']);
47
- const change = latestClose - prevClose;
48
- const changePercent = (change / prevClose) * 100;
49
-
50
- const history = dates.slice(-30).map(date => ({
51
- date: date.substring(5),
52
- price: parseFloat(timeSeries[date]['4. close'])
53
- }));
54
-
55
- setData({
56
- symbol: json['Meta Data']['2. Symbol'],
57
- price: latestClose.toFixed(2),
58
- change: change.toFixed(2),
59
- changePercent: `${changePercent.toFixed(2)}%`,
60
- history
61
- });
62
-
63
- flux.dispatch({
64
- type: 'UPDATE_STATE',
65
- payload: { airId: 'stocks-air', price: latestClose.toFixed(2) },
66
- to: 'all'
67
- });
68
- } else if (json['Note']) {
69
- const msg = "API limit reached.";
70
- setError(msg);
71
- flux.dispatch({ type: 'AIR_ERROR', payload: { airId: 'stocks-air', error: msg }, to: 'all' });
72
- } else {
73
- const msg = "Symbol not found.";
74
- setError(msg);
75
- flux.dispatch({ type: 'AIR_ERROR', payload: { airId: 'stocks-air', error: msg }, to: 'all' });
76
- }
77
- } catch (err) {
78
- const msg = "Network error.";
79
- setError(msg);
80
- flux.dispatch({ type: 'AIR_ERROR', payload: { airId: 'stocks-air', error: msg }, to: 'all' });
81
- } finally {
82
- setLoading(false);
83
- }
84
- };
85
-
86
- return { symbol, setSymbol, data, loading, error, apiKeyMissing, fetchStock };
87
- }
@@ -1,15 +0,0 @@
1
- export const StocksManifest = {
2
- id: 'stocks-air',
3
- meta: {
4
- title: 'Stock Tracker',
5
- icon: '📈',
6
- description: 'Track real-time stock prices.',
7
- width: 350,
8
- height: 400
9
- },
10
- instructions: {
11
- tasks: {
12
- 'check_price': 'Check the stock price for a given symbol.'
13
- }
14
- }
15
- };
@@ -1,23 +0,0 @@
1
- // Add your AlphaVantage API key here
2
- // Get a free key at: https://www.alphavantage.co/support/#api-key
3
- export const resources = {
4
- api: {
5
- stocks: {
6
- timeSeries: {
7
- id: 'alphavantage-timeseries',
8
- provider: 'proxy',
9
- config: {
10
- url: 'https://www.alphavantage.co/query',
11
- method: 'GET',
12
- auth: 'STOCKS_API_KEY',
13
- params: {
14
- function: 'TIME_SERIES_DAILY'
15
- }
16
- }
17
- }
18
- }
19
- },
20
- keys: {
21
- STOCKS_API_KEY: 'PUT YOUR API KEY HERE'
22
- }
23
- } as const;
@@ -1,67 +0,0 @@
1
- import React from 'react';
2
- import { LineChart, Line, ResponsiveContainer, YAxis, Tooltip } from 'recharts';
3
-
4
- export default function StocksUI({
5
- symbol, setSymbol, data, loading, error, apiKeyMissing, onSearch
6
- }: any) {
7
- const isPositive = data && parseFloat(data.change) >= 0;
8
-
9
- return (
10
- <div style={{ paddingTop: 0, height: '100%', display: 'flex', flexDirection: 'column' }}>
11
- <div style={{ marginTop: 10, fontSize: '0.8rem', fontWeight: 600, textTransform: 'uppercase', color: '#888', letterSpacing: '0.5px' }}>Market Data</div>
12
-
13
- {apiKeyMissing ? (
14
- <div style={{ padding: 20, background: '#fff0f0', borderRadius: 8, border: '1px solid #ffcccc', color: '#d32f2f' }}>
15
- <strong>API Key Missing</strong>
16
- <p style={{ margin: '10px 0', fontSize: '0.9rem' }}>Please add <code>STOCK_API_KEY</code> to your environment variables.</p>
17
- </div>
18
- ) : (
19
- <>
20
- <form onSubmit={(e) => { e.preventDefault(); onSearch(symbol); }} style={{ marginBottom: 10 }}>
21
- <input
22
- value={symbol}
23
- onChange={(e) => setSymbol(e.target.value.toUpperCase())}
24
- placeholder="Enter Symbol (e.g. AAPL)"
25
- style={{ width: '100%', padding: '10px', borderRadius: 8, border: '1px solid #ddd', outline: 'none' }}
26
- />
27
- </form>
28
-
29
- {loading && <div style={{ textAlign: 'center', color: '#666' }}>Loading...</div>}
30
- {error && <div style={{ color: 'red', textAlign: 'center' }}>{error}</div>}
31
-
32
- {data && !loading && (
33
- <div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
34
- <div style={{ textAlign: 'center', marginBottom: 10 }}>
35
- <h2 style={{ fontSize: '2rem', margin: '0 0 5px 0', fontWeight: 800 }}>{data.price}</h2>
36
- <div style={{ fontSize: '1.2rem', color: isPositive ? '#00c853' : '#d32f2f', fontWeight: 600 }}>
37
- {isPositive ? '▲' : '▼'} {data.change} ({data.changePercent})
38
- </div>
39
- <div style={{ color: '#999', fontSize: '0.8rem' }}>{data.symbol} - Last 30 Days</div>
40
- </div>
41
-
42
- <div style={{ flex: 1, minHeight: 150, width: '100%' }}>
43
- <ResponsiveContainer width="100%" height="100%">
44
- <LineChart data={data.history}>
45
- <YAxis domain={['auto', 'auto']} hide={true} />
46
- <Tooltip
47
- contentStyle={{ borderRadius: 8, border: 'none', boxShadow: '0 2px 10px rgba(0,0,0,0.1)' }}
48
- itemStyle={{ color: '#333' }}
49
- formatter={(value: any) => [parseFloat(value).toFixed(2), 'Price']}
50
- />
51
- <Line
52
- type="monotone"
53
- dataKey="price"
54
- stroke={isPositive ? '#00c853' : '#d32f2f'}
55
- strokeWidth={2}
56
- dot={false}
57
- />
58
- </LineChart>
59
- </ResponsiveContainer>
60
- </div>
61
- </div>
62
- )}
63
- </>
64
- )}
65
- </div>
66
- );
67
- }
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -1,13 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { useLocation } from 'react-router-dom';
3
- import { analyticsService } from '../services/AnalyticsService';
4
-
5
- export function AnalyticsTracker() {
6
- const location = useLocation();
7
-
8
- useEffect(() => {
9
- analyticsService.logPageView(location.pathname + location.search);
10
- }, [location]);
11
-
12
- return null;
13
- }