refactor(reporting-layout): streamline sidebar and content layout

- Replaced the existing sidebar implementation with a new ReportingSider component that accepts collapse state and toggle function as props.
- Simplified the ReportingCollapsedButton component for better readability and functionality.
- Updated layout styles to enhance responsiveness and maintain consistent margins.
- Removed unused CSS styles related to the sidebar for cleaner code.
This commit is contained in:
chamikaJ
2025-07-28 14:54:54 +05:30
parent 2c860b0cc8
commit dd511b236f
17 changed files with 447 additions and 7 deletions

View File

@@ -0,0 +1,49 @@
import { useState, useEffect } from 'react';
import { surveyApiService } from '@/api/survey/survey.api.service';
import logger from '@/utils/errorLogger';
export interface UseSurveyStatusResult {
hasCompletedSurvey: boolean | null;
loading: boolean;
error: Error | null;
refetch: () => Promise<void>;
}
export const useSurveyStatus = (): UseSurveyStatusResult => {
const [hasCompletedSurvey, setHasCompletedSurvey] = useState<boolean | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
const checkSurveyStatus = async () => {
try {
setLoading(true);
setError(null);
const response = await surveyApiService.checkAccountSetupSurveyStatus();
if (response.done) {
setHasCompletedSurvey(response.body.is_completed);
} else {
setHasCompletedSurvey(false);
}
} catch (err) {
logger.error('Failed to check survey status', err);
setError(err as Error);
// Assume not completed if there's an error
setHasCompletedSurvey(false);
} finally {
setLoading(false);
}
};
useEffect(() => {
checkSurveyStatus();
}, []);
return {
hasCompletedSurvey,
loading,
error,
refetch: checkSurveyStatus
};
};