mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 13:15:24 +02:00
Optimize app loading and fix product lines in experiments
Performance improvements: - Fetch traffic, stock, vendor stock, buybox, and experiments data in parallel using Promise.all - Reduces initial loading time significantly - Non-blocking background fetches after sales data loads Bug fixes: - Pass availableLines from App.tsx to ExperimentForm as prop - Remove localStorage dependency for product lines - Product lines now correctly populated from rawData Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
co-authored by
Qwen-Coder
parent
5efc2d519e
commit
d535004a29
@@ -8,6 +8,7 @@ interface ExperimentFormProps {
|
||||
initialAsins?: string[];
|
||||
initialMarketplace?: string;
|
||||
initialLine?: string;
|
||||
availableLines?: string[];
|
||||
}
|
||||
|
||||
const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
@@ -15,7 +16,8 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
onSuccess,
|
||||
initialAsins = [],
|
||||
initialMarketplace = 'DE',
|
||||
initialLine = ''
|
||||
initialLine = '',
|
||||
availableLines = []
|
||||
}) => {
|
||||
const [formData, setFormData] = useState<ExperimentCreateInput>({
|
||||
name: '',
|
||||
@@ -36,21 +38,6 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
const [targetType, setTargetType] = useState<'asin' | 'line'>(initialAsins.length > 0 ? 'asin' : initialLine ? 'line' : 'asin');
|
||||
const [selectedLine, setSelectedLine] = useState(initialLine);
|
||||
|
||||
// Get available product lines from localStorage (sales data)
|
||||
const availableLines = useMemo(() => {
|
||||
try {
|
||||
const cachedData = localStorage.getItem('craze_sales_data');
|
||||
if (cachedData) {
|
||||
const data = JSON.parse(cachedData);
|
||||
const lines = new Set(data.map((r: any) => r.line).filter(Boolean));
|
||||
return Array.from(lines).sort();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load product lines:', e);
|
||||
}
|
||||
return [];
|
||||
}, []);
|
||||
|
||||
const handleAddAsin = () => {
|
||||
// Support both comma and space separated ASINs
|
||||
const newAsins = asinInput
|
||||
|
||||
Reference in New Issue
Block a user