Add batch upload configure modal and settings mapping utilities.
Users configure share mode, expiry, and max views before upload; batch summary confirms choices above the queue.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import type { UploadBatchSettingsForm } from '@/types/upload/UploadBatchSettingsForm';
|
||||
import type { ZkUploadPrepareOptionsResult } from '@/types/upload/ZkUploadPrepareOptionsResult';
|
||||
import { resolveUploadBatchExpiresAt } from '@/utils/upload/resolveUploadBatchExpiresAt';
|
||||
import { resolveUploadBatchMaxViews } from '@/utils/upload/resolveUploadBatchMaxViews';
|
||||
import { validateUploadBatchSettings } from '@/utils/upload/validateUploadBatchSettings';
|
||||
|
||||
export const buildZkUploadPrepareOptionsFromBatchSettings = (
|
||||
settings: UploadBatchSettingsForm
|
||||
): ZkUploadPrepareOptionsResult => {
|
||||
const validationError = validateUploadBatchSettings(settings);
|
||||
|
||||
if (validationError) {
|
||||
return { ok: false, error: validationError };
|
||||
}
|
||||
|
||||
const uploadOptions = {
|
||||
expiresAt: resolveUploadBatchExpiresAt(settings.expiryPreset),
|
||||
maxViews: resolveUploadBatchMaxViews(settings.maxViewsPreset)
|
||||
};
|
||||
|
||||
if (settings.passwordEnabled) {
|
||||
return {
|
||||
ok: true,
|
||||
options: {
|
||||
...uploadOptions,
|
||||
passwordProtected: true,
|
||||
password: settings.password
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
options: {
|
||||
...uploadOptions,
|
||||
passwordProtected: false
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user