2026-06-13 10:19:11 +08:00
|
|
|
import { ProgressCard } from "@/components/common/progress-card";
|
|
|
|
|
import { useTranslation } from "@/contexts/i18n-context";
|
|
|
|
|
import { useToolProcessor } from "@/hooks/use-tool-processor";
|
|
|
|
|
import { useFileStore } from "@/stores/file-store";
|
|
|
|
|
|
|
|
|
|
export function CreateZipSettings() {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const s = t.toolSettings["create-zip"];
|
|
|
|
|
const { files } = useFileStore();
|
2026-06-15 22:26:24 +08:00
|
|
|
const { processFiles, processing, error, progress } = useToolProcessor("create-zip");
|
2026-06-13 10:19:11 +08:00
|
|
|
|
|
|
|
|
const hasFile = files.length > 0;
|
|
|
|
|
|
|
|
|
|
const handleProcess = () => {
|
2026-06-15 22:26:24 +08:00
|
|
|
processFiles(files, {});
|
2026-06-13 10:19:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
{error && <p className="text-xs text-red-500">{error}</p>}
|
|
|
|
|
|
|
|
|
|
{processing ? (
|
|
|
|
|
<ProgressCard
|
|
|
|
|
active={processing}
|
|
|
|
|
phase={progress.phase === "idle" ? "uploading" : progress.phase}
|
|
|
|
|
label={s.progressLabel}
|
|
|
|
|
stage={progress.stage}
|
|
|
|
|
percent={progress.percent}
|
|
|
|
|
elapsed={progress.elapsed}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
data-testid="create-zip-submit"
|
|
|
|
|
onClick={handleProcess}
|
|
|
|
|
disabled={!hasFile || processing}
|
|
|
|
|
className="w-full py-2.5 rounded-lg bg-primary text-primary-foreground font-medium disabled:opacity-50 disabled:cursor-not-allowed"
|
|
|
|
|
>
|
2026-06-15 22:26:24 +08:00
|
|
|
{s.submit}
|
2026-06-13 10:19:11 +08:00
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|