Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/components/csv/CSVSingleImportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
onClose: () => void;
onImport: (file: File, onProgress: (progressEvent: AxiosProgressEvent) => void) => Promise<void>;
onDownloadTemplate: () => void;
/**
* Optional component to display help instructions for the import process
* If provided, a help section will be displayed below the CSV upload section
*/
VideoHelp?: React.ComponentType;
}

/**
Expand Down Expand Up @@ -118,6 +123,8 @@
return null;
}

const { VideoHelp } = props;

Check warning on line 126 in app/src/components/csv/CSVSingleImportDialog.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/csv/CSVSingleImportDialog.tsx#L126

Added line #L126 was not covered by tests

return (
<Dialog open={props.open} maxWidth={'xl'} fullScreen={fullScreen}>
<DialogContent sx={{ mt: 2 }}>
Expand All @@ -138,6 +145,9 @@
/>
</CSVDropzoneSection>
</Box>

{/* Display video help component if provided */}
{VideoHelp && <VideoHelp />}

Check warning on line 150 in app/src/components/csv/CSVSingleImportDialog.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/csv/CSVSingleImportDialog.tsx#L150

Added line #L150 was not covered by tests
</DialogContent>
<Divider />

Expand Down
29 changes: 29 additions & 0 deletions app/src/components/dialog/video-help/TransformDataHelp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { VideoHelpSection, VideoHelpSectionProps } from './VideoHelpSection';

/**
* Help content for transforming data from wide to narrow format
*/
export const TransformDataHelp = () => {
const helpProps: VideoHelpSectionProps = {
title: 'How to Transform Your Data from Wide to Narrow Format in Excel',
videoUrl: 'https://nrs.objectstore.gov.bc.ca/locsch/resources/Import_PQMP4_2_slow.mp4',
steps: [
{
label: 'Step 1:',
text: 'Select your data, navigate to the "Data" tab and choose "From Data/Range", then confirm with "OK".'
},
{
label: 'Step 2:',
text: 'Select all columns you want to transform, open the "Transform" tab and select "Unpivot Columns".'
},
{
label: 'Step 3:',
text: 'Rename your new columns appropriately, return to the home tab, then select "Close and Load".'
}
],
collapsedText: 'Need help transforming data from wide to narrow?',
expandedText: 'Hide data transformation instructions'
};

Check warning on line 26 in app/src/components/dialog/video-help/TransformDataHelp.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/TransformDataHelp.tsx#L6-L26

Added lines #L6 - L26 were not covered by tests

return <VideoHelpSection {...helpProps} />;
};

Check warning on line 29 in app/src/components/dialog/video-help/TransformDataHelp.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/TransformDataHelp.tsx#L28-L29

Added lines #L28 - L29 were not covered by tests
108 changes: 108 additions & 0 deletions app/src/components/dialog/video-help/VideoHelpSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { Box, Stack, Typography } from '@mui/material';
import { useState } from 'react';

Check warning on line 5 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L2-L5

Added lines #L2 - L5 were not covered by tests

export interface VideoHelpStep {
label: string;
text: string;
}

export interface VideoHelpSectionProps {
/**
* Title of the help section
*/
title: string;

/**
* URL to the video to play
*/
videoUrl: string;

/**
* Array of steps to display
*/
steps: VideoHelpStep[];

/**
* Text to show when collapsed
*/
collapsedText?: string;

/**
* Text to show when expanded
*/
expandedText?: string;
}

/**
* A reusable component for displaying video help instructions
*/
export const VideoHelpSection = (props: VideoHelpSectionProps) => {
const [showInstructions, setShowInstructions] = useState<boolean>(false);

Check warning on line 43 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L42-L43

Added lines #L42 - L43 were not covered by tests

const { title, videoUrl, steps, collapsedText = 'Show instructions', expandedText = 'Hide instructions' } = props;

Check warning on line 45 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L45

Added line #L45 was not covered by tests

return (
<>
<Box
onClick={() => setShowInstructions(!showInstructions)}
sx={{
display: 'flex',
alignItems: 'center',
my: 2,
cursor: 'pointer',
color: 'primary.main',
'&:hover': {
textDecoration: 'underline'
}
}}>
<InfoOutlinedIcon fontSize="small" sx={{ mr: 0.5 }} />
<Typography variant="body2" component="span">
{showInstructions ? expandedText : collapsedText}
</Typography>
{showInstructions ? (
<KeyboardArrowUpIcon fontSize="small" sx={{ ml: 0.5 }} />

Check warning on line 66 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L47-L66

Added lines #L47 - L66 were not covered by tests
) : (
<KeyboardArrowDownIcon fontSize="small" sx={{ ml: 0.5 }} />

Check warning on line 68 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L68

Added line #L68 was not covered by tests
)}
</Box>

Check warning on line 70 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L70

Added line #L70 was not covered by tests

{showInstructions && (
<Box sx={{ width: '100%', my: 3 }}>
<Stack spacing={2}>
<Typography variant="h6" component="h3">
{title}
</Typography>

Check warning on line 77 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L72-L77

Added lines #L72 - L77 were not covered by tests

<Box sx={{ pl: 2 }}>
{steps.map((step, index) => (
<Typography key={index} variant="body1" component="div" sx={{ mb: 1 }}>
<strong>{step.label}</strong> {step.text}
</Typography>
))}
</Box>

Check warning on line 85 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L79-L85

Added lines #L79 - L85 were not covered by tests

<Box sx={{ overflow: 'hidden', position: 'relative' }}>
<video
src={videoUrl}
playsInline
controls
style={{
display: 'block',
width: '100%',
maxWidth: '800px',
height: 'auto',
margin: '0 auto',
border: '1px solid #eee',
objectFit: 'cover'
}}
/>
</Box>
</Stack>
</Box>

Check warning on line 104 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L87-L104

Added lines #L87 - L104 were not covered by tests
)}
</>

Check warning on line 106 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L106

Added line #L106 was not covered by tests
);
};

Check warning on line 108 in app/src/components/dialog/video-help/VideoHelpSection.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/VideoHelpSection.tsx#L108

Added line #L108 was not covered by tests
29 changes: 29 additions & 0 deletions app/src/components/dialog/video-help/observationsHelp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { VideoHelpSection, VideoHelpSectionProps } from './VideoHelpSection';

/**
* Help content for importing observation data
*/
export const ObservationsHelp = () => {
const helpProps: VideoHelpSectionProps = {
title: 'How to Prepare Observation Data for Import',
videoUrl: 'https://nrs.objectstore.gov.bc.ca/locsch/resources/observations_demo.mp4', // Example URL
steps: [
{
label: 'Step 1:',
text: 'Ensure your observation data is in the correct format with required columns.'
},
{
label: 'Step 2:',
text: 'Each row should represent a single observation with date, location, and measurement values.'
},
{
label: 'Step 3:',
text: 'Use the template to ensure all required fields are included.'
}
],
collapsedText: 'Need help preparing observation data?',
expandedText: 'Hide observation data instructions'
};

Check warning on line 26 in app/src/components/dialog/video-help/observationsHelp.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/observationsHelp.tsx#L6-L26

Added lines #L6 - L26 were not covered by tests

return <VideoHelpSection {...helpProps} />;
};

Check warning on line 29 in app/src/components/dialog/video-help/observationsHelp.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/dialog/video-help/observationsHelp.tsx#L28-L29

Added lines #L28 - L29 were not covered by tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Button, { ButtonProps } from '@mui/material/Button';
import axios, { AxiosProgressEvent } from 'axios';
import { CSVSingleImportDialog } from 'components/csv/CSVSingleImportDialog';
import { TransformDataHelp } from 'components/dialog/video-help/TransformDataHelp';

Check warning on line 4 in app/src/features/surveys/observations/components/ImportObservationsButton.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/features/surveys/observations/components/ImportObservationsButton.tsx#L4

Added line #L4 was not covered by tests
import { SurveyContext } from 'contexts/surveyContext';
import { useBiohubApi } from 'hooks/useBioHubApi';
import { useContext, useState } from 'react';
Expand Down Expand Up @@ -118,6 +119,7 @@
onClose={() => setOpen(false)}
onImport={handleImportObservations}
onDownloadTemplate={() => downloadFile(getObservationCSVTemplate(), 'SIMS-observations-template.csv')}
VideoHelp={TransformDataHelp}

Check warning on line 122 in app/src/features/surveys/observations/components/ImportObservationsButton.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/features/surveys/observations/components/ImportObservationsButton.tsx#L122

Added line #L122 was not covered by tests
/>
</>
);
Expand Down