mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { OrganizationFormData } from '@/types.ts';
|
|
import { useWizard } from '@/hooks/useWizard.ts';
|
|
import { useOrganizationAI } from '@/hooks/features/useOrganizationAI.ts';
|
|
import { useOrganizationForm } from '@/hooks/features/useOrganizationForm.ts';
|
|
|
|
interface UseOrganizationWizardProps {
|
|
onSuccess: (data: OrganizationFormData) => void;
|
|
}
|
|
|
|
export const useOrganizationWizard = ({ onSuccess }: UseOrganizationWizardProps) => {
|
|
const wizardState = useWizard(3);
|
|
const { goToStep } = wizardState;
|
|
|
|
const formManager = useOrganizationForm({ onSuccess });
|
|
|
|
const aiManager = useOrganizationAI({
|
|
formData: {
|
|
description: formManager.watch('description'),
|
|
name: formManager.watch('name'),
|
|
sector: formManager.watch('sector'),
|
|
tags: formManager.watch('tags'),
|
|
},
|
|
});
|
|
|
|
const handleNext = useCallback(async () => {
|
|
let fieldsToValidate: (keyof OrganizationFormData | 'location.lat' | 'location.lng')[] = [];
|
|
if (wizardState.currentStep === 2) {
|
|
fieldsToValidate = [
|
|
'name',
|
|
'sector',
|
|
'description',
|
|
'business_focus',
|
|
'founding_year',
|
|
'location.lat',
|
|
'location.lng',
|
|
];
|
|
}
|
|
const isValidStep = await formManager.validateFields(fieldsToValidate);
|
|
if (isValidStep) {
|
|
wizardState.nextStep();
|
|
}
|
|
}, [wizardState, formManager]);
|
|
|
|
const resetWizard = useCallback(() => {
|
|
formManager.resetForm();
|
|
goToStep(1);
|
|
}, [formManager, goToStep]);
|
|
|
|
return {
|
|
wizardState,
|
|
form: {
|
|
control: formManager.form.control,
|
|
errors: formManager.form.formState.errors,
|
|
isValid: formManager.form.formState.isValid,
|
|
handleSubmit: formManager.form.handleSubmit,
|
|
watch: formManager.watch,
|
|
setValue: formManager.setValue,
|
|
formState: formManager.form.formState,
|
|
},
|
|
smartFill: {
|
|
extractFromText: aiManager.extractDataFromText,
|
|
isExtractingFromText: aiManager.isExtractingFromText,
|
|
},
|
|
descriptionGeneration: {
|
|
generateDescription: aiManager.generateOrganizationDescription,
|
|
isGeneratingDescription: aiManager.isGeneratingDescription,
|
|
},
|
|
actions: {
|
|
handleNext,
|
|
onSubmit: formManager.onSubmit,
|
|
resetWizard,
|
|
},
|
|
};
|
|
};
|