import { Download, Loader2, Share } from 'lucide-react';
import { useTranslation } from '../../i18n';
import { BarButton } from '../Planner/planParts';
import { DialogButton } from '../shared/DialogShell';
import { Tooltip } from '../shared/Tooltip';
import { useTourGpxExport, type TourGpxExportTarget } from './useTourGpxExport';
/**
* PR1-06A, IO-01 in a footer: the saved tour as a GPX file, its own action
* beside the navigation, which only leads to the start. "GPX" says the format,
* the tooltip what the file holds. The share button beside it hands the same
* file to the system's share sheet where the platform takes GPX files, and a
* short text about the tour where it does not.
*/
export function TourGpxExportButton({ target }: { target: TourGpxExportTarget }) {
const { t } = useTranslation();
const { exportGpx, shareGpx, sharesFile, exporting } = useTourGpxExport(target);
const shareLabel = t(sharesFile ? 'tours.gpxExport.share' : 'tours.gpxExport.shareTour');
return (
<>
void exportGpx(target)}
disabled={exporting}
aria-label={t('tours.gpxExport.action')}
data-testid="tour-gpx-export"
icon={exporting ? : }
>
GPX
void shareGpx(target)}
disabled={exporting}
aria-label={shareLabel}
data-testid="tour-gpx-share"
icon={}
>
{t('tours.gpxExport.shareShort')}
>
);
}
/**
* The same export in the planner's head. While the tour has unsaved changes
* the file would not hold them, so the buttons wait for the save and say so.
*/
export function TourGpxExportBarButton({ target, unsaved }: { target: TourGpxExportTarget; unsaved: boolean }) {
const { t } = useTranslation();
const { exportGpx, shareGpx, sharesFile, exporting } = useTourGpxExport(unsaved ? null : target);
const shareLabel = sharesFile
? t(unsaved ? 'tours.gpxExport.shareSaveFirst' : 'tours.gpxExport.share')
: t(unsaved ? 'tours.gpxExport.shareTourSaveFirst' : 'tours.gpxExport.shareTour');
return (
<>
void exportGpx(target)}
disabled={unsaved || exporting}
>
{exporting ? : }
void shareGpx(target)} disabled={unsaved || exporting}>
>
);
}