fitlers fixes
This commit is contained in:
@@ -282,8 +282,15 @@ export const createClustersPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Status' },
|
||||
{ value: 'new', label: 'New' },
|
||||
{ value: 'mapped', label: 'Mapped' },
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if statusOptions is undefined (not loaded yet)
|
||||
...(handlers.statusOptions !== undefined
|
||||
? handlers.statusOptions
|
||||
: [
|
||||
{ value: 'new', label: 'New' },
|
||||
{ value: 'mapped', label: 'Mapped' },
|
||||
]
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -292,11 +299,18 @@ export const createClustersPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Difficulty' },
|
||||
{ value: '1', label: '1 - Very Easy' },
|
||||
{ value: '2', label: '2 - Easy' },
|
||||
{ value: '3', label: '3 - Medium' },
|
||||
{ value: '4', label: '4 - Hard' },
|
||||
{ value: '5', label: '5 - Very Hard' },
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if difficultyOptions is undefined (not loaded yet)
|
||||
...(handlers.difficultyOptions !== undefined
|
||||
? handlers.difficultyOptions
|
||||
: [
|
||||
{ value: '1', label: '1 - Very Easy' },
|
||||
{ value: '2', label: '2 - Easy' },
|
||||
{ value: '3', label: '3 - Medium' },
|
||||
{ value: '4', label: '4 - Hard' },
|
||||
{ value: '5', label: '5 - Very Hard' },
|
||||
]
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -304,7 +318,7 @@ export const createClustersPageConfig = (
|
||||
label: 'Volume Range',
|
||||
type: 'custom',
|
||||
customRender: () => (
|
||||
<div className="relative flex-1 min-w-[140px]">
|
||||
<div className="relative" style={{ minWidth: '180px' }}>
|
||||
<button
|
||||
ref={handlers.volumeButtonRef}
|
||||
type="button"
|
||||
@@ -323,7 +337,7 @@ export const createClustersPageConfig = (
|
||||
: ""
|
||||
}`}
|
||||
>
|
||||
<span className="block text-left truncate">
|
||||
<span className="block text-left truncate whitespace-nowrap">
|
||||
{handlers.volumeMin || handlers.volumeMax
|
||||
? `Vol: ${handlers.volumeMin || 'Min'} - ${handlers.volumeMax || 'Max'}`
|
||||
: 'Volume Range'}
|
||||
@@ -384,16 +398,14 @@ export const createClustersPageConfig = (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
onClick={async () => {
|
||||
onClick={() => {
|
||||
const newMin = handlers.tempVolumeMin === '' ? '' : Number(handlers.tempVolumeMin);
|
||||
const newMax = handlers.tempVolumeMax === '' ? '' : Number(handlers.tempVolumeMax);
|
||||
handlers.setIsVolumeDropdownOpen(false);
|
||||
handlers.setVolumeMin(newMin);
|
||||
handlers.setVolumeMax(newMax);
|
||||
handlers.setCurrentPage(1);
|
||||
setTimeout(() => {
|
||||
handlers.loadClusters();
|
||||
}, 0);
|
||||
// Remove manual loadClusters call - let useEffect handle it automatically
|
||||
}}
|
||||
className="flex-1"
|
||||
>
|
||||
|
||||
@@ -83,6 +83,18 @@ export const createContentPageConfig = (
|
||||
setStatusFilter: (value: string) => void;
|
||||
setCurrentPage: (page: number) => void;
|
||||
onRowClick?: (row: Content) => void;
|
||||
// Dynamic filter options
|
||||
statusOptions?: Array<{ value: string; label: string }>;
|
||||
sourceOptions?: Array<{ value: string; label: string }>;
|
||||
contentTypeOptions?: Array<{ value: string; label: string }>;
|
||||
contentStructureOptions?: Array<{ value: string; label: string }>;
|
||||
// New filter setters
|
||||
contentTypeFilter?: string;
|
||||
setContentTypeFilter?: (value: string) => void;
|
||||
contentStructureFilter?: string;
|
||||
setContentStructureFilter?: (value: string) => void;
|
||||
sourceFilter?: string;
|
||||
setSourceFilter?: (value: string) => void;
|
||||
}
|
||||
): ContentPageConfig => {
|
||||
const showSectorColumn = !handlers.activeSector;
|
||||
@@ -404,8 +416,15 @@ export const createContentPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Status' },
|
||||
{ value: 'draft', label: 'Draft' },
|
||||
{ value: 'published', label: 'Published' },
|
||||
...(handlers.statusOptions !== undefined
|
||||
? handlers.statusOptions
|
||||
: [
|
||||
{ value: 'draft', label: 'Draft' },
|
||||
{ value: 'review', label: 'Review' },
|
||||
{ value: 'approved', label: 'Approved' },
|
||||
{ value: 'published', label: 'Published' },
|
||||
]
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -445,10 +464,16 @@ export const createContentPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Sources' },
|
||||
{ value: 'igny8', label: 'IGNY8' },
|
||||
{ value: 'wordpress', label: 'WordPress' },
|
||||
...(handlers.sourceOptions !== undefined
|
||||
? handlers.sourceOptions
|
||||
: [
|
||||
{ value: 'igny8', label: 'IGNY8' },
|
||||
{ value: 'wordpress', label: 'WordPress' },
|
||||
]
|
||||
),
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
headerMetrics: [
|
||||
{
|
||||
|
||||
@@ -238,7 +238,9 @@ export const createIdeasPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Status' },
|
||||
...(handlers.statusOptions && handlers.statusOptions.length > 0
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if statusOptions is undefined (not loaded yet)
|
||||
...(handlers.statusOptions !== undefined
|
||||
? handlers.statusOptions
|
||||
: [
|
||||
{ value: 'new', label: 'New' },
|
||||
@@ -254,7 +256,9 @@ export const createIdeasPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Structures' },
|
||||
...(handlers.contentStructureOptions && handlers.contentStructureOptions.length > 0
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if contentStructureOptions is undefined (not loaded yet)
|
||||
...(handlers.contentStructureOptions !== undefined
|
||||
? handlers.contentStructureOptions
|
||||
: [
|
||||
{ value: 'article', label: 'Article' },
|
||||
@@ -281,7 +285,9 @@ export const createIdeasPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Types' },
|
||||
...(handlers.contentTypeOptions && handlers.contentTypeOptions.length > 0
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if contentTypeOptions is undefined (not loaded yet)
|
||||
...(handlers.contentTypeOptions !== undefined
|
||||
? handlers.contentTypeOptions
|
||||
: [
|
||||
{ value: 'post', label: 'Post' },
|
||||
@@ -299,7 +305,9 @@ export const createIdeasPageConfig = (
|
||||
dynamicOptions: 'clusters',
|
||||
options: [
|
||||
{ value: '', label: 'All Clusters' },
|
||||
...(handlers.clusterOptions && handlers.clusterOptions.length > 0
|
||||
// Use dynamic cluster options if loaded (even if empty array)
|
||||
// Only fall back to full clusters list if clusterOptions is undefined (not loaded yet)
|
||||
...(handlers.clusterOptions !== undefined
|
||||
? handlers.clusterOptions
|
||||
: handlers.clusters.map((c) => ({ value: c.id.toString(), label: c.name }))
|
||||
),
|
||||
|
||||
@@ -272,8 +272,9 @@ export const createKeywordsPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Status' },
|
||||
// Use dynamic options if available, otherwise show default options
|
||||
...(handlers.statusOptions && handlers.statusOptions.length > 0
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if statusOptions is undefined (not loaded yet)
|
||||
...(handlers.statusOptions !== undefined
|
||||
? handlers.statusOptions
|
||||
: [
|
||||
{ value: 'new', label: 'New' },
|
||||
@@ -288,8 +289,9 @@ export const createKeywordsPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Countries' },
|
||||
// Use dynamic options if available, otherwise show default options
|
||||
...(handlers.countryOptions && handlers.countryOptions.length > 0
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if countryOptions is undefined (not loaded yet)
|
||||
...(handlers.countryOptions !== undefined
|
||||
? handlers.countryOptions
|
||||
: [
|
||||
{ value: 'US', label: 'United States' },
|
||||
@@ -309,7 +311,9 @@ export const createKeywordsPageConfig = (
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: '', label: 'All Difficulty' },
|
||||
...(handlers.difficultyOptions && handlers.difficultyOptions.length > 0
|
||||
// Use dynamic options if loaded (even if empty array)
|
||||
// Only fall back to defaults if difficultyOptions is undefined (not loaded yet)
|
||||
...(handlers.difficultyOptions !== undefined
|
||||
? handlers.difficultyOptions
|
||||
: [
|
||||
{ value: '1', label: '1 - Very Easy' },
|
||||
@@ -328,8 +332,9 @@ export const createKeywordsPageConfig = (
|
||||
dynamicOptions: 'clusters', // Flag for dynamic option loading
|
||||
options: [
|
||||
{ value: '', label: 'All Clusters' },
|
||||
// Use dynamic cluster options if available
|
||||
...(handlers.clusterOptions && handlers.clusterOptions.length > 0
|
||||
// Use dynamic cluster options if loaded (even if empty array)
|
||||
// Only fall back to full clusters list if clusterOptions is undefined (not loaded yet)
|
||||
...(handlers.clusterOptions !== undefined
|
||||
? handlers.clusterOptions
|
||||
: handlers.clusters.map(c => ({ value: String(c.id), label: c.name }))
|
||||
),
|
||||
@@ -340,7 +345,7 @@ export const createKeywordsPageConfig = (
|
||||
label: 'Volume Range',
|
||||
type: 'custom',
|
||||
customRender: () => (
|
||||
<div className="relative flex-1 min-w-[140px]">
|
||||
<div className="relative" style={{ minWidth: '180px' }}>
|
||||
<button
|
||||
ref={handlers.volumeButtonRef}
|
||||
type="button"
|
||||
@@ -359,7 +364,7 @@ export const createKeywordsPageConfig = (
|
||||
: ""
|
||||
}`}
|
||||
>
|
||||
<span className="block text-left truncate">
|
||||
<span className="block text-left truncate whitespace-nowrap">
|
||||
{handlers.volumeMin || handlers.volumeMax
|
||||
? `Vol: ${handlers.volumeMin || 'Min'} - ${handlers.volumeMax || 'Max'}`
|
||||
: 'Volume Range'}
|
||||
@@ -420,16 +425,14 @@ export const createKeywordsPageConfig = (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
onClick={async () => {
|
||||
onClick={() => {
|
||||
const newMin = handlers.tempVolumeMin === '' ? '' : Number(handlers.tempVolumeMin);
|
||||
const newMax = handlers.tempVolumeMax === '' ? '' : Number(handlers.tempVolumeMax);
|
||||
handlers.setIsVolumeDropdownOpen(false);
|
||||
handlers.setVolumeMin(newMin);
|
||||
handlers.setVolumeMax(newMax);
|
||||
handlers.setCurrentPage(1);
|
||||
setTimeout(() => {
|
||||
handlers.loadKeywords();
|
||||
}, 0);
|
||||
// Remove manual loadKeywords call - let useEffect handle it automatically
|
||||
}}
|
||||
className="flex-1"
|
||||
>
|
||||
|
||||
@@ -53,6 +53,18 @@ export function createReviewPageConfig(params: {
|
||||
setCurrentPage: (page: number) => void;
|
||||
activeSector: { id: number; name: string } | null;
|
||||
onRowClick?: (row: Content) => void;
|
||||
// Dynamic filter options
|
||||
statusOptions?: Array<{ value: string; label: string }>;
|
||||
siteStatusOptions?: Array<{ value: string; label: string }>;
|
||||
contentTypeOptions?: Array<{ value: string; label: string }>;
|
||||
contentStructureOptions?: Array<{ value: string; label: string }>;
|
||||
// Filter values and setters
|
||||
siteStatusFilter?: string;
|
||||
setSiteStatusFilter?: (value: string) => void;
|
||||
contentTypeFilter?: string;
|
||||
setContentTypeFilter?: (value: string) => void;
|
||||
contentStructureFilter?: string;
|
||||
setContentStructureFilter?: (value: string) => void;
|
||||
}): ReviewPageConfig {
|
||||
const showSectorColumn = !params.activeSector;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user