Add flexible date pickers and export options to stock dashboard
Introduces a reusable date picker component with support for single date, date range, and month selection. Updates the stock management page to allow exporting reports by daily, weekly, monthly, or custom date ranges using the new pickers. Refactors promotion form to use the new date picker for start and end dates. Adds more business quotes to the quotes config.
This commit is contained in:
@@ -22,6 +22,7 @@ import { Textarea } from '@/components/ui/textarea';
|
||||
import { toast } from '@/components/ui/use-toast';
|
||||
import { PromotionFormData } from '@/lib/types/promotion';
|
||||
import { fetchClient } from '@/lib/api';
|
||||
import { DatePicker } from '@/components/ui/date-picker';
|
||||
|
||||
// Form schema validation with Zod
|
||||
const formSchema = z.object({
|
||||
@@ -246,7 +247,12 @@ export default function NewPromotionForm({ onSuccess, onCancel }: NewPromotionFo
|
||||
<FormItem>
|
||||
<FormLabel className="text-sm font-medium">Start Date</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="date" className="h-10" {...field} />
|
||||
<DatePicker
|
||||
date={field.value ? new Date(field.value) : undefined}
|
||||
onDateChange={(date) => field.onChange(date ? date.toISOString().split('T')[0] : '')}
|
||||
placeholder="Select start date"
|
||||
className="h-10"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -260,15 +266,11 @@ export default function NewPromotionForm({ onSuccess, onCancel }: NewPromotionFo
|
||||
<FormItem>
|
||||
<FormLabel className="text-sm font-medium">End Date (Optional)</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="date"
|
||||
<DatePicker
|
||||
date={field.value ? new Date(field.value) : undefined}
|
||||
onDateChange={(date) => field.onChange(date ? date.toISOString().split('T')[0] : null)}
|
||||
placeholder="Select end date (optional)"
|
||||
className="h-10"
|
||||
{...field}
|
||||
value={field.value || ''}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
field.onChange(value === '' ? null : value);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription className="text-xs">
|
||||
|
||||
Reference in New Issue
Block a user