2024-06-07 20:17:03 +03:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
import { ErrorData } from '@/components/info/InfoError';
|
2024-07-30 15:59:37 +03:00
|
|
|
import PickSubstitutions from '@/components/select/PickSubstitutions';
|
2024-06-07 20:17:03 +03:00
|
|
|
import DataLoader from '@/components/wrap/DataLoader';
|
2024-07-30 15:59:37 +03:00
|
|
|
import { ICstSubstitute } from '@/models/oss';
|
2024-12-13 21:30:49 +03:00
|
|
|
import { ConstituentaID, IRSForm } from '@/models/rsform';
|
2024-06-07 20:17:03 +03:00
|
|
|
import { prefixes } from '@/utils/constants';
|
|
|
|
|
2024-06-26 19:47:05 +03:00
|
|
|
interface TabSubstitutionsProps {
|
2024-06-07 20:17:03 +03:00
|
|
|
receiver?: IRSForm;
|
|
|
|
source?: IRSForm;
|
|
|
|
selected: ConstituentaID[];
|
|
|
|
|
|
|
|
loading?: boolean;
|
|
|
|
error?: ErrorData;
|
|
|
|
|
2024-07-30 15:59:37 +03:00
|
|
|
substitutions: ICstSubstitute[];
|
|
|
|
setSubstitutions: React.Dispatch<React.SetStateAction<ICstSubstitute[]>>;
|
2024-06-07 20:17:03 +03:00
|
|
|
}
|
|
|
|
|
2024-06-26 19:47:05 +03:00
|
|
|
function TabSubstitutions({
|
2024-06-07 20:17:03 +03:00
|
|
|
source,
|
|
|
|
receiver,
|
|
|
|
selected,
|
|
|
|
|
|
|
|
error,
|
|
|
|
loading,
|
|
|
|
|
|
|
|
substitutions,
|
|
|
|
setSubstitutions
|
2024-06-26 19:47:05 +03:00
|
|
|
}: TabSubstitutionsProps) {
|
2024-12-13 21:30:49 +03:00
|
|
|
const schemas = [...(source ? [source] : []), ...(receiver ? [receiver] : [])];
|
2024-07-30 15:59:37 +03:00
|
|
|
|
2024-06-07 20:17:03 +03:00
|
|
|
return (
|
2024-12-12 13:17:24 +03:00
|
|
|
<DataLoader isLoading={loading} error={error} hasNoData={!source}>
|
2024-07-30 15:59:37 +03:00
|
|
|
<PickSubstitutions
|
|
|
|
substitutions={substitutions}
|
|
|
|
setSubstitutions={setSubstitutions}
|
2024-06-07 20:17:03 +03:00
|
|
|
rows={10}
|
|
|
|
prefixID={prefixes.cst_inline_synth_substitutes}
|
2024-07-30 15:59:37 +03:00
|
|
|
schemas={schemas}
|
2024-12-13 21:30:49 +03:00
|
|
|
filter={cst => cst.id !== source?.id || selected.includes(cst.id)}
|
2024-06-07 20:17:03 +03:00
|
|
|
/>
|
|
|
|
</DataLoader>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-26 19:47:05 +03:00
|
|
|
export default TabSubstitutions;
|