update download csv in notification prod

This commit is contained in:
rajaoktf
2025-10-14 17:05:59 +07:00
parent 593ac48a32
commit 820a293b97
5 changed files with 341 additions and 187 deletions

View File

@ -56,3 +56,7 @@ export function deepMerge(obj1: any, obj2: any): any {
export function uniqueID(): string {
return (Date.now() + Math.floor(Math.random() * 1000)).toString();
}
const baseUrl = import.meta.env?.VITE_BASE_URL || '/';
export const TEMPLATE_CSV_URL = `${baseUrl}template_notification.csv`;

View File

@ -30,6 +30,7 @@ import { Check, ChevronDown, X } from 'lucide-react';
import { initialStateNotification, selectedNotification, validateFormNotification } from './Types';
import { useDebounce } from './useDebounce';
import Papa from 'papaparse';
import { TEMPLATE_CSV_URL } from '@/lib/helpers';
const API_URL_CUSTOMER = apiConfig.service_customer;
const API_URL_NOTIFICATION = apiConfig.service_notification;
@ -469,14 +470,27 @@ const AddDialog = () => {
<label className="form-label flex items-center gap-1 max-w-56">
Upload MSISDN CSV
</label>
<div className="flex-1 flex flex-col gap-2">
<Input
ref={fileInputRef}
type="file"
accept=".csv"
onChange={handleFileUpload}
className="input col-span-6"
/>
<div className="flex flex-col gap-2 flex-1">
{/* Baris upload + button */}
<div className="flex items-center gap-3">
<Input
ref={fileInputRef}
type="file"
accept=".csv"
onChange={handleFileUpload}
className="input flex-1"
/>
<a
href={TEMPLATE_CSV_URL}
download
className="px-3 py-2 rounded-md bg-blue-600 text-white text-sm font-medium hover:bg-blue-700"
>
Download Template CSV
</a>
</div>
{/* Info file yang sudah diupload */}
{uploadedFileName && formField.customer_phone.length > 0 && (
<div className="flex items-center gap-2 text-sm text-green-600 bg-green-50 px-3 py-2 rounded-md">
<Check className="w-4 h-4" />