-
{`Вы вошли в систему как ${user?.username ?? ''}`}
-
-
-
|
-
-
|
-
-
|
-
- Выйти
-
+
+
{`Вы вошли в систему как ${user?.username ?? ''}`}
+
+
+ |
+
+ |
+
+ |
+
+ Выйти
+
+
-
);
+ );
}
-export default ExpectedAnonymous;
\ No newline at end of file
+export default ExpectedAnonymous;
diff --git a/rsconcept/frontend/src/components/Footer.tsx b/rsconcept/frontend/src/components/Footer.tsx
index bec94d15..621a9212 100644
--- a/rsconcept/frontend/src/components/Footer.tsx
+++ b/rsconcept/frontend/src/components/Footer.tsx
@@ -11,23 +11,25 @@ function Footer() {
return null;
}
return (
-
);
+
+ );
}
-export default Footer;
\ No newline at end of file
+export default Footer;
diff --git a/rsconcept/frontend/src/components/Help/ConstituentaTooltip.tsx b/rsconcept/frontend/src/components/Help/ConstituentaTooltip.tsx
index 265cb17c..ed862da6 100644
--- a/rsconcept/frontend/src/components/Help/ConstituentaTooltip.tsx
+++ b/rsconcept/frontend/src/components/Help/ConstituentaTooltip.tsx
@@ -3,18 +3,16 @@ import InfoConstituenta from '@/components/Shared/InfoConstituenta';
import { IConstituenta } from '@/models/rsform';
interface ConstituentaTooltipProps {
- data: IConstituenta
- anchor: string
+ data: IConstituenta;
+ anchor: string;
}
function ConstituentaTooltip({ data, anchor }: ConstituentaTooltipProps) {
return (
-
-
- );
+
+
+
+ );
}
-export default ConstituentaTooltip;
\ No newline at end of file
+export default ConstituentaTooltip;
diff --git a/rsconcept/frontend/src/components/Help/HelpButton.tsx b/rsconcept/frontend/src/components/Help/HelpButton.tsx
index a2053e45..64f66210 100644
--- a/rsconcept/frontend/src/components/Help/HelpButton.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpButton.tsx
@@ -7,32 +7,25 @@ import { HelpTopic } from '@/models/miscellaneous';
import { CProps } from '../props';
import InfoTopic from './InfoTopic';
-interface HelpButtonProps
-extends CProps.Styling {
- topic: HelpTopic
- offset?: number
+interface HelpButtonProps extends CProps.Styling {
+ topic: HelpTopic;
+ offset?: number;
}
function HelpButton({ topic, ...restProps }: HelpButtonProps) {
return (
-
);
+
+ );
}
-export default HelpButton;
\ No newline at end of file
+export default HelpButton;
diff --git a/rsconcept/frontend/src/components/Help/HelpConstituenta.tsx b/rsconcept/frontend/src/components/Help/HelpConstituenta.tsx
index 647b4089..6a187afd 100644
--- a/rsconcept/frontend/src/components/Help/HelpConstituenta.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpConstituenta.tsx
@@ -2,6 +2,7 @@ import Divider from '@/components/Common/Divider';
import InfoCstStatus from '@/components/Shared/InfoCstStatus';
function HelpConstituenta() {
+ // prettier-ignore
return (
Редактор конституент
@@ -22,4 +23,4 @@ function HelpConstituenta() {
);
}
-export default HelpConstituenta;
\ No newline at end of file
+export default HelpConstituenta;
diff --git a/rsconcept/frontend/src/components/Help/HelpExteor.tsx b/rsconcept/frontend/src/components/Help/HelpExteor.tsx
index dd31db0d..f993c7d0 100644
--- a/rsconcept/frontend/src/components/Help/HelpExteor.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpExteor.tsx
@@ -2,6 +2,7 @@ import TextURL from '@/components/Common/TextURL';
import { urls } from '@/utils/constants';
function HelpExteor() {
+ // prettier-ignore
return (
Экстеор
@@ -24,4 +25,4 @@ function HelpExteor() {
);
}
-export default HelpExteor;
\ No newline at end of file
+export default HelpExteor;
diff --git a/rsconcept/frontend/src/components/Help/HelpLibrary.tsx b/rsconcept/frontend/src/components/Help/HelpLibrary.tsx
index 7bd870c8..1846e387 100644
--- a/rsconcept/frontend/src/components/Help/HelpLibrary.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpLibrary.tsx
@@ -2,6 +2,7 @@ import { BiCheckShield, BiShareAlt } from 'react-icons/bi';
import { FiBell } from 'react-icons/fi';
function HelpLibrary() {
+ // prettier-ignore
return (
Библиотека концептуальных схем
@@ -24,4 +25,4 @@ function HelpLibrary() {
);
}
-export default HelpLibrary;
\ No newline at end of file
+export default HelpLibrary;
diff --git a/rsconcept/frontend/src/components/Help/HelpMain.tsx b/rsconcept/frontend/src/components/Help/HelpMain.tsx
index b18f6169..49754311 100644
--- a/rsconcept/frontend/src/components/Help/HelpMain.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpMain.tsx
@@ -2,6 +2,7 @@ import TextURL from '@/components/Common/TextURL';
import { urls } from '@/utils/constants';
function HelpMain() {
+ // prettier-ignore
return (
Портал
@@ -20,4 +21,4 @@ function HelpMain() {
);
}
-export default HelpMain;
\ No newline at end of file
+export default HelpMain;
diff --git a/rsconcept/frontend/src/components/Help/HelpPrivacy.tsx b/rsconcept/frontend/src/components/Help/HelpPrivacy.tsx
index edd5dbea..2b272b4e 100644
--- a/rsconcept/frontend/src/components/Help/HelpPrivacy.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpPrivacy.tsx
@@ -1,11 +1,8 @@
-import PDFViewer from '@/components/Common/PDFViewer';
+import PDFViewer from '@/components/PDFViewer';
import { resources } from '@/utils/constants';
function HelpPrivacy() {
- return (
-
);
+ return
;
}
-export default HelpPrivacy;
\ No newline at end of file
+export default HelpPrivacy;
diff --git a/rsconcept/frontend/src/components/Help/HelpRSFormItems.tsx b/rsconcept/frontend/src/components/Help/HelpRSFormItems.tsx
index 02f0f3ab..80d32f7f 100644
--- a/rsconcept/frontend/src/components/Help/HelpRSFormItems.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpRSFormItems.tsx
@@ -2,6 +2,7 @@ import Divider from '@/components/Common/Divider';
import InfoCstStatus from '@/components/Shared/InfoCstStatus';
function HelpRSFormItems() {
+ // prettier-ignore
return (
Горячие клавиши
@@ -15,4 +16,4 @@ function HelpRSFormItems() {
);
}
-export default HelpRSFormItems;
\ No newline at end of file
+export default HelpRSFormItems;
diff --git a/rsconcept/frontend/src/components/Help/HelpRSFormMeta.tsx b/rsconcept/frontend/src/components/Help/HelpRSFormMeta.tsx
index 787a44fa..48306340 100644
--- a/rsconcept/frontend/src/components/Help/HelpRSFormMeta.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpRSFormMeta.tsx
@@ -1,4 +1,5 @@
function HelpRSFormMeta() {
+ // prettier-ignore
return (
Паспорт схемы
@@ -12,4 +13,4 @@ function HelpRSFormMeta() {
);
}
-export default HelpRSFormMeta;
\ No newline at end of file
+export default HelpRSFormMeta;
diff --git a/rsconcept/frontend/src/components/Help/HelpRSLang.tsx b/rsconcept/frontend/src/components/Help/HelpRSLang.tsx
index 1ea36b6a..30015ff9 100644
--- a/rsconcept/frontend/src/components/Help/HelpRSLang.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpRSLang.tsx
@@ -9,13 +9,13 @@ const OPT_VIDEO_H = 1080;
function HelpRSLang() {
const windowSize = useWindowSize();
- const videoHeight = useMemo(
- () => {
+ const videoHeight = useMemo(() => {
const viewH = windowSize.height ?? 0;
const viewW = windowSize.width ?? 0;
- return Math.min(OPT_VIDEO_H, viewH - 320, Math.floor((viewW - 290)*9/16));
+ return Math.min(OPT_VIDEO_H, viewH - 320, Math.floor(((viewW - 290) * 9) / 16));
}, [windowSize]);
+ // prettier-ignore
return (
@@ -38,4 +38,4 @@ function HelpRSLang() {
);
}
-export default HelpRSLang;
\ No newline at end of file
+export default HelpRSLang;
diff --git a/rsconcept/frontend/src/components/Help/HelpRSTemplates.tsx b/rsconcept/frontend/src/components/Help/HelpRSTemplates.tsx
index 1284ba1e..8822bb98 100644
--- a/rsconcept/frontend/src/components/Help/HelpRSTemplates.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpRSTemplates.tsx
@@ -1,4 +1,5 @@
function HelpRSTemplates() {
+ // prettier-ignore
return (
Банк выражений
@@ -13,4 +14,4 @@ function HelpRSTemplates() {
);
}
-export default HelpRSTemplates;
\ No newline at end of file
+export default HelpRSTemplates;
diff --git a/rsconcept/frontend/src/components/Help/HelpTermGraph.tsx b/rsconcept/frontend/src/components/Help/HelpTermGraph.tsx
index 992cdbac..9f694971 100644
--- a/rsconcept/frontend/src/components/Help/HelpTermGraph.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpTermGraph.tsx
@@ -3,6 +3,7 @@ import InfoCstClass from '@/components/Shared/InfoCstClass';
import InfoCstStatus from '@/components/Shared/InfoCstStatus';
function HelpTermGraph() {
+ // prettier-ignore
return (
@@ -33,4 +34,4 @@ function HelpTermGraph() {
);
}
-export default HelpTermGraph;
\ No newline at end of file
+export default HelpTermGraph;
diff --git a/rsconcept/frontend/src/components/Help/HelpTerminologyControl.tsx b/rsconcept/frontend/src/components/Help/HelpTerminologyControl.tsx
index 83b0dfca..2d0d8c2c 100644
--- a/rsconcept/frontend/src/components/Help/HelpTerminologyControl.tsx
+++ b/rsconcept/frontend/src/components/Help/HelpTerminologyControl.tsx
@@ -1,5 +1,5 @@
-
function HelpTerminologyControl() {
+ // prettier-ignore
return (
Терминологизация
@@ -13,4 +13,4 @@ function HelpTerminologyControl() {
);
}
-export default HelpTerminologyControl;
\ No newline at end of file
+export default HelpTerminologyControl;
diff --git a/rsconcept/frontend/src/components/Help/InfoTopic.tsx b/rsconcept/frontend/src/components/Help/InfoTopic.tsx
index ae04f41d..af28e922 100644
--- a/rsconcept/frontend/src/components/Help/InfoTopic.tsx
+++ b/rsconcept/frontend/src/components/Help/InfoTopic.tsx
@@ -14,7 +14,7 @@ import HelpTermGraph from './HelpTermGraph';
import HelpTerminologyControl from './HelpTerminologyControl';
interface InfoTopicProps {
- topic: HelpTopic
+ topic: HelpTopic;
}
function InfoTopic({ topic }: InfoTopicProps) {
@@ -33,4 +33,4 @@ function InfoTopic({ topic }: InfoTopicProps) {
return null;
}
-export default InfoTopic;
\ No newline at end of file
+export default InfoTopic;
diff --git a/rsconcept/frontend/src/components/Icons.tsx b/rsconcept/frontend/src/components/Icons.tsx
index 256a14dd..946b3ca7 100644
--- a/rsconcept/frontend/src/components/Icons.tsx
+++ b/rsconcept/frontend/src/components/Icons.tsx
@@ -1,30 +1,31 @@
// Search new icons at https://reactsvgicons.com/
interface IconSVGProps {
- viewBox: string
- size?: string
- className?: string
- props?: React.SVGProps
- children: React.ReactNode
+ viewBox: string;
+ size?: string;
+ className?: string;
+ props?: React.SVGProps;
+ children: React.ReactNode;
}
export interface IconProps {
- size?: string
- className?: string
+ size?: string;
+ className?: string;
}
function IconSVG({ viewBox, size = '1.5rem', className, props, children }: IconSVGProps) {
return (
- );
+
+ );
}
export function EducationIcon(props: IconProps) {
@@ -46,11 +47,7 @@ export function InDoorIcon(props: IconProps) {
export function CheckboxCheckedIcon() {
return (
-
+ );
}
-export default ConstituentaBadge;
\ No newline at end of file
+export default ConstituentaBadge;
diff --git a/rsconcept/frontend/src/components/Shared/ConstituentaPicker.tsx b/rsconcept/frontend/src/components/Shared/ConstituentaPicker.tsx
index 5748b1ff..aea610b6 100644
--- a/rsconcept/frontend/src/components/Shared/ConstituentaPicker.tsx
+++ b/rsconcept/frontend/src/components/Shared/ConstituentaPicker.tsx
@@ -12,35 +12,35 @@ import { describeConstituenta } from '@/utils/labels';
import ConstituentaBadge from './ConstituentaBadge';
interface ConstituentaPickerProps {
- prefixID?: string
- data?: IConstituenta[]
- rows?: number
-
- onBeginFilter?: (cst: IConstituenta) => boolean
- describeFunc?: (cst: IConstituenta) => string
- matchFunc?: (cst: IConstituenta, filter: string) => boolean
-
- value?: IConstituenta
- onSelectValue: (newValue: IConstituenta) => void
+ prefixID?: string;
+ data?: IConstituenta[];
+ rows?: number;
+
+ onBeginFilter?: (cst: IConstituenta) => boolean;
+ describeFunc?: (cst: IConstituenta) => string;
+ matchFunc?: (cst: IConstituenta, filter: string) => boolean;
+
+ value?: IConstituenta;
+ onSelectValue: (newValue: IConstituenta) => void;
}
const columnHelper = createColumnHelper
();
function ConstituentaPicker({
- data, value,
+ data,
+ value,
rows = 4,
prefixID = prefixes.cst_list,
describeFunc = describeConstituenta,
matchFunc = (cst, filter) => matchConstituenta(cst, filter, CstMatchMode.ALL),
onBeginFilter,
onSelectValue
-} : ConstituentaPickerProps) {
+}: ConstituentaPickerProps) {
const { colors } = useConceptTheme();
const [filteredData, setFilteredData] = useState([]);
const [filterText, setFilterText] = useState('');
- useEffect(
- () => {
+ useEffect(() => {
if (!data) {
setFilteredData([]);
} else {
@@ -51,57 +51,58 @@ function ConstituentaPicker({
setFilteredData(newData);
}
}
-
}, [data, filterText, matchFunc, onBeginFilter]);
const columns = useMemo(
- () => [
- columnHelper.accessor('alias', {
- id: 'alias',
- size: 65,
- minSize: 65,
- maxSize: 65,
- cell: props =>
-
- }),
- columnHelper.accessor(cst => describeFunc(cst), {
- id: 'description'
- })
- ], [colors, prefixID, describeFunc]);
+ () => [
+ columnHelper.accessor('alias', {
+ id: 'alias',
+ size: 65,
+ minSize: 65,
+ maxSize: 65,
+ cell: props =>
+ }),
+ columnHelper.accessor(cst => describeFunc(cst), {
+ id: 'description'
+ })
+ ],
+ [colors, prefixID, describeFunc]
+ );
- const size = useMemo(() => (`calc(2px + (2px + 1.8rem)*${rows})`), [rows]);
+ const size = useMemo(() => `calc(2px + (2px + 1.8rem)*${rows})`, [rows]);
const conditionalRowStyles = useMemo(
- (): IConditionalStyle[] => [{
- when: (cst: IConstituenta) => cst.id === value?.id,
- style: { backgroundColor: colors.bgSelected },
- }], [value, colors]);
+ (): IConditionalStyle[] => [
+ {
+ when: (cst: IConstituenta) => cst.id === value?.id,
+ style: { backgroundColor: colors.bgSelected }
+ }
+ ],
+ [value, colors]
+ );
return (
-
-
setFilterText(newValue)}
- />
-
- Список конституент пуст
- Измените параметры фильтра
-
- }
- onRowClicked={onSelectValue}
- />
- );
+
+
setFilterText(newValue)} />
+
+ Список конституент пуст
+ Измените параметры фильтра
+
+ }
+ onRowClicked={onSelectValue}
+ />
+
+ );
}
-export default ConstituentaPicker;
\ No newline at end of file
+export default ConstituentaPicker;
diff --git a/rsconcept/frontend/src/components/Shared/GrammemeBadge.tsx b/rsconcept/frontend/src/components/Shared/GrammemeBadge.tsx
index dc9b389f..f4c25169 100644
--- a/rsconcept/frontend/src/components/Shared/GrammemeBadge.tsx
+++ b/rsconcept/frontend/src/components/Shared/GrammemeBadge.tsx
@@ -6,29 +6,30 @@ import { colorFgGrammeme } from '@/utils/color';
import { labelGrammeme } from '@/utils/labels';
interface GrammemeBadgeProps {
- key?: string
- grammeme: GramData
+ key?: string;
+ grammeme: GramData;
}
function GrammemeBadge({ key, grammeme }: GrammemeBadgeProps) {
const { colors } = useConceptTheme();
return (
-
- {labelGrammeme(grammeme)}
-
);
+
+ {labelGrammeme(grammeme)}
+
+ );
}
-export default GrammemeBadge;
\ No newline at end of file
+export default GrammemeBadge;
diff --git a/rsconcept/frontend/src/components/Shared/InfoConstituenta.tsx b/rsconcept/frontend/src/components/Shared/InfoConstituenta.tsx
index 4acaae16..30cd7416 100644
--- a/rsconcept/frontend/src/components/Shared/InfoConstituenta.tsx
+++ b/rsconcept/frontend/src/components/Shared/InfoConstituenta.tsx
@@ -1,39 +1,42 @@
import { IConstituenta } from '@/models/rsform';
import { labelCstTypification } from '@/utils/labels';
-interface InfoConstituentaProps
-extends React.HTMLAttributes {
- data: IConstituenta
+interface InfoConstituentaProps extends React.HTMLAttributes {
+ data: IConstituenta;
}
function InfoConstituenta({ data, ...restProps }: InfoConstituentaProps) {
return (
-
-
Конституента {data.alias}
-
- Типизация:
- {labelCstTypification(data)}
-
-
- Термин:
- {data.term_resolved || data.term_raw}
-
- {data.definition_formal ?
-
- Выражение:
- {data.definition_formal}
-
: null}
- {data.definition_resolved ?
-
- Определение:
- {data.definition_resolved}
-
: null}
- {data.convention ?
-
- Конвенция:
- {data.convention}
-
: null}
-
);
+
+
Конституента {data.alias}
+
+ Типизация:
+ {labelCstTypification(data)}
+
+
+ Термин:
+ {data.term_resolved || data.term_raw}
+
+ {data.definition_formal ? (
+
+ Выражение:
+ {data.definition_formal}
+
+ ) : null}
+ {data.definition_resolved ? (
+
+ Определение:
+ {data.definition_resolved}
+
+ ) : null}
+ {data.convention ? (
+
+ Конвенция:
+ {data.convention}
+
+ ) : null}
+
+ );
}
-export default InfoConstituenta;
\ No newline at end of file
+export default InfoConstituenta;
diff --git a/rsconcept/frontend/src/components/Shared/InfoCstClass.tsx b/rsconcept/frontend/src/components/Shared/InfoCstClass.tsx
index 61a8c88c..78f27d55 100644
--- a/rsconcept/frontend/src/components/Shared/InfoCstClass.tsx
+++ b/rsconcept/frontend/src/components/Shared/InfoCstClass.tsx
@@ -7,38 +7,37 @@ import { prefixes } from '@/utils/constants';
import { describeCstClass, labelCstClass } from '@/utils/labels';
interface InfoCstClassProps {
- header?: string
+ header?: string;
}
function InfoCstClass({ header }: InfoCstClassProps) {
const { colors } = useConceptTheme();
return (
-
- {header ?
{header}
: null}
- {Object.values(CstClass).map(
- (cclass, index) => {
- return (
-
-
- {labelCstClass(cclass)}
-
- -
-
- {describeCstClass(cclass)}
-
-
);
- })}
-
);
+
+ {header ?
{header}
: null}
+ {Object.values(CstClass).map((cstClass, index) => {
+ return (
+
+
+ {labelCstClass(cstClass)}
+
+ -
+ {describeCstClass(cstClass)}
+
+ );
+ })}
+
+ );
}
-export default InfoCstClass;
\ No newline at end of file
+export default InfoCstClass;
diff --git a/rsconcept/frontend/src/components/Shared/InfoCstStatus.tsx b/rsconcept/frontend/src/components/Shared/InfoCstStatus.tsx
index e25c5675..429e4600 100644
--- a/rsconcept/frontend/src/components/Shared/InfoCstStatus.tsx
+++ b/rsconcept/frontend/src/components/Shared/InfoCstStatus.tsx
@@ -7,39 +7,37 @@ import { prefixes } from '@/utils/constants';
import { describeExpressionStatus, labelExpressionStatus } from '@/utils/labels';
interface InfoCstStatusProps {
- title?: string
+ title?: string;
}
function InfoCstStatus({ title }: InfoCstStatusProps) {
const { colors } = useConceptTheme();
return (
-
- {title ?
{title}
: null}
- {Object.values(ExpressionStatus)
- .filter(status => status !== ExpressionStatus.UNDEFINED)
- .map(
- (status, index) =>
-
-
- {labelExpressionStatus(status)}
-
- -
-
- {describeExpressionStatus(status)}
-
-
- )}
-
);
+
+ {title ?
{title}
: null}
+ {Object.values(ExpressionStatus)
+ .filter(status => status !== ExpressionStatus.UNDEFINED)
+ .map((status, index) => (
+
+
+ {labelExpressionStatus(status)}
+
+ -
+ {describeExpressionStatus(status)}
+
+ ))}
+
+ );
}
-export default InfoCstStatus;
\ No newline at end of file
+export default InfoCstStatus;
diff --git a/rsconcept/frontend/src/components/Shared/InfoLibraryItem.tsx b/rsconcept/frontend/src/components/Shared/InfoLibraryItem.tsx
index f515fe01..4de76afa 100644
--- a/rsconcept/frontend/src/components/Shared/InfoLibraryItem.tsx
+++ b/rsconcept/frontend/src/components/Shared/InfoLibraryItem.tsx
@@ -4,35 +4,36 @@ import { useUsers } from '@/context/UsersContext';
import { ILibraryItemEx } from '@/models/library';
interface InfoLibraryItemProps {
- item?: ILibraryItemEx
+ item?: ILibraryItemEx;
}
function InfoLibraryItem({ item }: InfoLibraryItemProps) {
const { getUserLabel } = useUsers();
const intl = useIntl();
return (
-
-
-
-
- {getUserLabel(item?.owner ?? null)}
-
+
+
+
+
+ {getUserLabel(item?.owner ?? null)}
+
+
+
+
+
+ {item?.subscribers.length ?? 0}
+
+
+
+
+ {item && new Date(item?.time_update).toLocaleString(intl.locale)}
+
+
+
+ {item && new Date(item?.time_create).toLocaleString(intl.locale)}
+
-
-
-
- { item?.subscribers.length ?? 0 }
-
-
-
-
- {item && new Date(item?.time_update).toLocaleString(intl.locale)}
-
-
-
- {item && new Date(item?.time_create).toLocaleString(intl.locale)}
-
-
);
+ );
}
export default InfoLibraryItem;
diff --git a/rsconcept/frontend/src/components/Shared/SelectGrammeme.tsx b/rsconcept/frontend/src/components/Shared/SelectGrammeme.tsx
index f46a9d95..18956c37 100644
--- a/rsconcept/frontend/src/components/Shared/SelectGrammeme.tsx
+++ b/rsconcept/frontend/src/components/Shared/SelectGrammeme.tsx
@@ -3,39 +3,33 @@ import { useEffect, useState } from 'react';
import SelectMulti, { SelectMultiProps } from '@/components/Common/SelectMulti';
import { Grammeme } from '@/models/language';
import { getCompatibleGrams } from '@/models/languageAPI';
-import { compareGrammemeOptions,IGrammemeOption, SelectorGrammemes } from '@/utils/selectors';
+import { compareGrammemeOptions, IGrammemeOption, SelectorGrammemes } from '@/utils/selectors';
-interface SelectGrammemeProps extends
-Omit
, 'value' | 'onChange'> {
- value: IGrammemeOption[]
- setValue: React.Dispatch>
- className?: string
- placeholder?: string
+interface SelectGrammemeProps extends Omit, 'value' | 'onChange'> {
+ value: IGrammemeOption[];
+ setValue: React.Dispatch>;
+ className?: string;
+ placeholder?: string;
}
-function SelectGrammeme({
- value, setValue,
- ...restProps
-}: SelectGrammemeProps) {
+function SelectGrammeme({ value, setValue, ...restProps }: SelectGrammemeProps) {
const [options, setOptions] = useState([]);
- useEffect(
- () => {
+ useEffect(() => {
const compatible = getCompatibleGrams(
- value
- .filter(data => Object.values(Grammeme).includes(data.value as Grammeme))
- .map(data => data.value as Grammeme)
+ value.filter(data => Object.values(Grammeme).includes(data.value as Grammeme)).map(data => data.value as Grammeme)
);
- setOptions(SelectorGrammemes.filter(({value}) => compatible.includes(value as Grammeme)));
+ setOptions(SelectorGrammemes.filter(({ value }) => compatible.includes(value as Grammeme)));
}, [value]);
return (
- setValue([...newValue].sort(compareGrammemeOptions))}
- {...restProps}
- />);
+ setValue([...newValue].sort(compareGrammemeOptions))}
+ {...restProps}
+ />
+ );
}
-export default SelectGrammeme;
\ No newline at end of file
+export default SelectGrammeme;
diff --git a/rsconcept/frontend/src/components/Shared/SelectedCounter.tsx b/rsconcept/frontend/src/components/Shared/SelectedCounter.tsx
index 144213a2..725d2838 100644
--- a/rsconcept/frontend/src/components/Shared/SelectedCounter.tsx
+++ b/rsconcept/frontend/src/components/Shared/SelectedCounter.tsx
@@ -1,26 +1,21 @@
import Overlay from '@/components/Common/Overlay';
interface SelectedCounterProps {
- total: number
- selected: number
- position?: string
- hideZero?: boolean
+ total: number;
+ selected: number;
+ position?: string;
+ hideZero?: boolean;
}
-function SelectedCounter({
- total, selected, hideZero,
- position = 'top-0 left-0',
-} : SelectedCounterProps) {
+function SelectedCounter({ total, selected, hideZero, position = 'top-0 left-0' }: SelectedCounterProps) {
if (selected === 0 && hideZero) {
return null;
}
return (
-
- Выбор {selected} из {total}
- );
+
+ Выбор {selected} из {total}
+
+ );
}
-export default SelectedCounter;
\ No newline at end of file
+export default SelectedCounter;
diff --git a/rsconcept/frontend/src/components/Shared/WordFormBadge.tsx b/rsconcept/frontend/src/components/Shared/WordFormBadge.tsx
index a5b04f48..893cf4fb 100644
--- a/rsconcept/frontend/src/components/Shared/WordFormBadge.tsx
+++ b/rsconcept/frontend/src/components/Shared/WordFormBadge.tsx
@@ -3,21 +3,18 @@ import { IWordForm } from '@/models/language';
import GrammemeBadge from './GrammemeBadge';
interface WordFormBadgeProps {
- keyPrefix?: string
- form: IWordForm
+ keyPrefix?: string;
+ form: IWordForm;
}
function WordFormBadge({ keyPrefix, form }: WordFormBadgeProps) {
return (
-
- {form.grams.map(
- (gram) =>
-
- )}
-
);
+
+ {form.grams.map(gram => (
+
+ ))}
+
+ );
}
-export default WordFormBadge;
\ No newline at end of file
+export default WordFormBadge;
diff --git a/rsconcept/frontend/src/components/props.d.ts b/rsconcept/frontend/src/components/props.d.ts
index fa623971..cd304092 100644
--- a/rsconcept/frontend/src/components/props.d.ts
+++ b/rsconcept/frontend/src/components/props.d.ts
@@ -2,39 +2,40 @@
import { HTMLMotionProps } from 'framer-motion';
export namespace CProps {
+ export type Control = {
+ title?: string;
+ disabled?: boolean;
+ noBorder?: boolean;
+ noOutline?: boolean;
+ };
-export type Control = {
- title?: string
- disabled?: boolean
- noBorder?: boolean
- noOutline?: boolean
+ export type Styling = {
+ style?: React.CSSProperties;
+ className?: string;
+ };
+
+ export type Editor = Control & {
+ label?: string;
+ };
+
+ export type Colors = {
+ colors?: string;
+ };
+
+ export type Div = React.DetailedHTMLProps, HTMLDivElement>;
+ export type Button = Omit<
+ React.DetailedHTMLProps, HTMLButtonElement>,
+ 'children' | 'type'
+ >;
+ export type Label = Omit<
+ React.DetailedHTMLProps, HTMLLabelElement>,
+ 'children'
+ >;
+ export type TextArea = React.DetailedHTMLProps<
+ React.TextareaHTMLAttributes,
+ HTMLTextAreaElement
+ >;
+ export type Input = React.DetailedHTMLProps, HTMLInputElement>;
+
+ export type AnimatedButton = Omit, 'type'>;
}
-
-export type Styling = {
- style?: React.CSSProperties
- className?: string
-}
-
-export type Editor = Control & {
- label?: string
-}
-
-export type Colors = {
- colors?: string
-}
-
-export type Div = React.DetailedHTMLProps, HTMLDivElement>;
-export type Button = Omit<
- React.DetailedHTMLProps, HTMLButtonElement>,
- 'children' | 'type'
->;
-export type Label = Omit<
- React.DetailedHTMLProps, HTMLLabelElement>,
- 'children'
->;
-export type TextArea = React.DetailedHTMLProps, HTMLTextAreaElement>;
-export type Input = React.DetailedHTMLProps, HTMLInputElement>;
-
-export type AnimatedButton = Omit, 'type'>;
-
-}
\ No newline at end of file
diff --git a/rsconcept/frontend/src/context/AccessModeContext.tsx b/rsconcept/frontend/src/context/AccessModeContext.tsx
index 94cb6136..96d70bd2 100644
--- a/rsconcept/frontend/src/context/AccessModeContext.tsx
+++ b/rsconcept/frontend/src/context/AccessModeContext.tsx
@@ -5,32 +5,25 @@ import { createContext, useContext, useState } from 'react';
import { UserAccessMode } from '@/models/miscellaneous';
interface IAccessModeContext {
- mode: UserAccessMode
- setMode: React.Dispatch>
+ mode: UserAccessMode;
+ setMode: React.Dispatch>;
}
const AccessContext = createContext(null);
export const useAccessMode = () => {
const context = useContext(AccessContext);
if (!context) {
- throw new Error(
- 'useAccessMode has to be used within '
- );
+ throw new Error('useAccessMode has to be used within ');
}
return context;
-}
+};
interface AccessModeStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const AccessModeState = ({ children }: AccessModeStateProps) => {
const [mode, setMode] = useState(UserAccessMode.READER);
- return (
-
- {children}
- );
-};
\ No newline at end of file
+ return {children};
+};
diff --git a/rsconcept/frontend/src/context/AuthContext.tsx b/rsconcept/frontend/src/context/AuthContext.tsx
index 9c0d05eb..f7131dca 100644
--- a/rsconcept/frontend/src/context/AuthContext.tsx
+++ b/rsconcept/frontend/src/context/AuthContext.tsx
@@ -10,34 +10,32 @@ import { IUserSignupData } from '@/models/library';
import { IUserProfile } from '@/models/library';
import { IUserInfo } from '@/models/library';
import { IUserUpdatePassword } from '@/models/library';
-import { type DataCallback, getAuth, patchPassword,postLogin, postLogout, postSignup } from '@/utils/backendAPI';
+import { type DataCallback, getAuth, patchPassword, postLogin, postLogout, postSignup } from '@/utils/backendAPI';
import { useUsers } from './UsersContext';
interface IAuthContext {
- user: ICurrentUser | undefined
- login: (data: IUserLoginData, callback?: DataCallback) => void
- logout: (callback?: DataCallback) => void
- signup: (data: IUserSignupData, callback?: DataCallback) => void
- updatePassword: (data: IUserUpdatePassword, callback?: () => void) => void
- loading: boolean
- error: ErrorData
- setError: (error: ErrorData) => void
+ user: ICurrentUser | undefined;
+ login: (data: IUserLoginData, callback?: DataCallback) => void;
+ logout: (callback?: DataCallback) => void;
+ signup: (data: IUserSignupData, callback?: DataCallback) => void;
+ updatePassword: (data: IUserUpdatePassword, callback?: () => void) => void;
+ loading: boolean;
+ error: ErrorData;
+ setError: (error: ErrorData) => void;
}
const AuthContext = createContext(null);
export const useAuth = () => {
const context = useContext(AuthContext);
if (!context) {
- throw new Error(
- 'useAuth has to be used within '
- );
+ throw new Error('useAuth has to be used within ');
}
return context;
-}
+};
interface AuthStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const AuthState = ({ children }: AuthStateProps) => {
@@ -47,19 +45,21 @@ export const AuthState = ({ children }: AuthStateProps) => {
const [error, setError] = useState(undefined);
const reload = useCallback(
- (callback?: () => void) => {
- getAuth({
- onError: () => setUser(undefined),
- onSuccess: currentUser => {
- if (currentUser.id) {
- setUser(currentUser);
- } else {
- setUser(undefined);
+ (callback?: () => void) => {
+ getAuth({
+ onError: () => setUser(undefined),
+ onSuccess: currentUser => {
+ if (currentUser.id) {
+ setUser(currentUser);
+ } else {
+ setUser(undefined);
+ }
+ if (callback) callback();
}
- if (callback) callback();
- }
- });
- }, [setUser]);
+ });
+ },
+ [setUser]
+ );
function login(data: IUserLoginData, callback?: DataCallback) {
setError(undefined);
@@ -68,9 +68,10 @@ export const AuthState = ({ children }: AuthStateProps) => {
showError: true,
setLoading: setLoading,
onError: error => setError(error),
- onSuccess: newData => reload(() => {
- if (callback) callback(newData);
- })
+ onSuccess: newData =>
+ reload(() => {
+ if (callback) callback(newData);
+ })
});
}
@@ -78,9 +79,10 @@ export const AuthState = ({ children }: AuthStateProps) => {
setError(undefined);
postLogout({
showError: true,
- onSuccess: newData => reload(() => {
- if (callback) callback(newData);
- })
+ onSuccess: newData =>
+ reload(() => {
+ if (callback) callback(newData);
+ })
});
}
@@ -91,35 +93,38 @@ export const AuthState = ({ children }: AuthStateProps) => {
showError: true,
setLoading: setLoading,
onError: error => setError(error),
- onSuccess: newData => reload(() => {
- users.push(newData as IUserInfo);
- if (callback) callback(newData);
- })
+ onSuccess: newData =>
+ reload(() => {
+ users.push(newData as IUserInfo);
+ if (callback) callback(newData);
+ })
});
}
const updatePassword = useCallback(
- (data: IUserUpdatePassword, callback?: () => void) => {
- setError(undefined);
- patchPassword({
- data: data,
- showError: true,
- setLoading: setLoading,
- onError: error => setError(error),
- onSuccess: () => reload(() => {
- if (callback) callback();
- })
- });
- }, [reload]);
+ (data: IUserUpdatePassword, callback?: () => void) => {
+ setError(undefined);
+ patchPassword({
+ data: data,
+ showError: true,
+ setLoading: setLoading,
+ onError: error => setError(error),
+ onSuccess: () =>
+ reload(() => {
+ if (callback) callback();
+ })
+ });
+ },
+ [reload]
+ );
useLayoutEffect(() => {
reload();
- }, [reload])
+ }, [reload]);
return (
-
- {children}
- );
-};
\ No newline at end of file
+
+ {children}
+
+ );
+};
diff --git a/rsconcept/frontend/src/context/LibraryContext.tsx b/rsconcept/frontend/src/context/LibraryContext.tsx
index 5a5118ef..31716964 100644
--- a/rsconcept/frontend/src/context/LibraryContext.tsx
+++ b/rsconcept/frontend/src/context/LibraryContext.tsx
@@ -8,41 +8,47 @@ import { matchLibraryItem } from '@/models/libraryAPI';
import { ILibraryFilter } from '@/models/miscellaneous';
import { IRSForm, IRSFormCreateData, IRSFormData } from '@/models/rsform';
import { loadRSFormData } from '@/models/rsformAPI';
-import { DataCallback, deleteLibraryItem, getLibrary, getRSFormDetails, getTemplates, postCloneLibraryItem, postNewRSForm } from '@/utils/backendAPI';
+import {
+ DataCallback,
+ deleteLibraryItem,
+ getLibrary,
+ getRSFormDetails,
+ getTemplates,
+ postCloneLibraryItem,
+ postNewRSForm
+} from '@/utils/backendAPI';
import { useAuth } from './AuthContext';
interface ILibraryContext {
- items: ILibraryItem[]
- templates: ILibraryItem[]
- loading: boolean
- processing: boolean
- error: ErrorData
- setError: (error: ErrorData) => void
-
- applyFilter: (params: ILibraryFilter) => ILibraryItem[]
- retrieveTemplate: (templateID: number, callback: (schema: IRSForm) => void) => void
- createItem: (data: IRSFormCreateData, callback?: DataCallback) => void
- cloneItem: (target: number, data: IRSFormCreateData, callback: DataCallback) => void
- destroyItem: (target: number, callback?: () => void) => void
+ items: ILibraryItem[];
+ templates: ILibraryItem[];
+ loading: boolean;
+ processing: boolean;
+ error: ErrorData;
+ setError: (error: ErrorData) => void;
- localUpdateItem: (data: ILibraryItem) => void
- localUpdateTimestamp: (target: number) => void
+ applyFilter: (params: ILibraryFilter) => ILibraryItem[];
+ retrieveTemplate: (templateID: number, callback: (schema: IRSForm) => void) => void;
+ createItem: (data: IRSFormCreateData, callback?: DataCallback) => void;
+ cloneItem: (target: number, data: IRSFormCreateData, callback: DataCallback) => void;
+ destroyItem: (target: number, callback?: () => void) => void;
+
+ localUpdateItem: (data: ILibraryItem) => void;
+ localUpdateTimestamp: (target: number) => void;
}
-const LibraryContext = createContext(null)
+const LibraryContext = createContext(null);
export const useLibrary = (): ILibraryContext => {
const context = useContext(LibraryContext);
if (context === null) {
- throw new Error(
- 'useLibrary has to be used within '
- );
+ throw new Error('useLibrary has to be used within ');
}
return context;
-}
+};
interface LibraryStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const LibraryState = ({ children }: LibraryStateProps) => {
@@ -56,51 +62,54 @@ export const LibraryState = ({ children }: LibraryStateProps) => {
const [cachedTemplates, setCachedTemplates] = useState([]);
const applyFilter = useCallback(
- (params: ILibraryFilter) => {
- let result = items;
- if (params.is_owned) {
- result = result.filter(item => item.owner === user?.id);
- }
- if (params.is_common !== undefined) {
- result = result.filter(item => item.is_common === params.is_common);
- }
- if (params.is_canonical !== undefined) {
- result = result.filter(item => item.is_canonical === params.is_canonical);
- }
- if (params.is_subscribed !== undefined) {
- result = result.filter(item => user?.subscriptions.includes(item.id));
- }
- if (params.is_personal !== undefined) {
- result = result.filter(item => user?.subscriptions.includes(item.id) || item.owner === user?.id);
- }
- if (params.query) {
- result = result.filter(item => matchLibraryItem(item, params.query!));
- }
- return result;
- }, [items, user]);
+ (params: ILibraryFilter) => {
+ let result = items;
+ if (params.is_owned) {
+ result = result.filter(item => item.owner === user?.id);
+ }
+ if (params.is_common !== undefined) {
+ result = result.filter(item => item.is_common === params.is_common);
+ }
+ if (params.is_canonical !== undefined) {
+ result = result.filter(item => item.is_canonical === params.is_canonical);
+ }
+ if (params.is_subscribed !== undefined) {
+ result = result.filter(item => user?.subscriptions.includes(item.id));
+ }
+ if (params.is_personal !== undefined) {
+ result = result.filter(item => user?.subscriptions.includes(item.id) || item.owner === user?.id);
+ }
+ if (params.query) {
+ result = result.filter(item => matchLibraryItem(item, params.query!));
+ }
+ return result;
+ },
+ [items, user]
+ );
const retrieveTemplate = useCallback(
- (templateID: number, callback: (schema: IRSForm) => void) => {
- const cached = cachedTemplates.find(schema => schema.id == templateID);
- if (cached) {
- callback(cached);
- return;
- }
- setError(undefined);
- getRSFormDetails(String(templateID), {
- showError: true,
- setLoading: setLoading,
- onError: error => setError(error),
- onSuccess: data => {
- const schema = loadRSFormData(data);
- setCachedTemplates(prev => ([...prev, schema]));
- callback(schema);
+ (templateID: number, callback: (schema: IRSForm) => void) => {
+ const cached = cachedTemplates.find(schema => schema.id == templateID);
+ if (cached) {
+ callback(cached);
+ return;
}
- });
- }, [cachedTemplates]);
+ setError(undefined);
+ getRSFormDetails(String(templateID), {
+ showError: true,
+ setLoading: setLoading,
+ onError: error => setError(error),
+ onSuccess: data => {
+ const schema = loadRSFormData(data);
+ setCachedTemplates(prev => [...prev, schema]);
+ callback(schema);
+ }
+ });
+ },
+ [cachedTemplates]
+ );
- const reload = useCallback(
- (callback?: () => void) => {
+ const reload = useCallback((callback?: () => void) => {
setItems([]);
setError(undefined);
getLibrary({
@@ -125,78 +134,107 @@ export const LibraryState = ({ children }: LibraryStateProps) => {
}, [reload, user]);
const localUpdateItem = useCallback(
- (data: ILibraryItem) => {
- const libraryItem = items.find(item => item.id === data.id);
- if (libraryItem) Object.assign(libraryItem, data);
- }, [items]);
+ (data: ILibraryItem) => {
+ const libraryItem = items.find(item => item.id === data.id);
+ if (libraryItem) Object.assign(libraryItem, data);
+ },
+ [items]
+ );
const localUpdateTimestamp = useCallback(
- (target: number) => {
- const libraryItem = items.find(item => item.id === target);
- if (libraryItem) {
- libraryItem.time_update = Date();
- }
- }, [items]);
+ (target: number) => {
+ const libraryItem = items.find(item => item.id === target);
+ if (libraryItem) {
+ libraryItem.time_update = Date();
+ }
+ },
+ [items]
+ );
const createItem = useCallback(
- (data: IRSFormCreateData, callback?: DataCallback) => {
- setError(undefined);
- postNewRSForm({
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newSchema => reload(() => {
- if (user && !user.subscriptions.includes(newSchema.id)) {
- user.subscriptions.push(newSchema.id);
- }
- if (callback) callback(newSchema);
- })
- });
- }, [reload, user]);
+ (data: IRSFormCreateData, callback?: DataCallback) => {
+ setError(undefined);
+ postNewRSForm({
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newSchema =>
+ reload(() => {
+ if (user && !user.subscriptions.includes(newSchema.id)) {
+ user.subscriptions.push(newSchema.id);
+ }
+ if (callback) callback(newSchema);
+ })
+ });
+ },
+ [reload, user]
+ );
const destroyItem = useCallback(
- (target: number, callback?: () => void) => {
- setError(undefined)
- deleteLibraryItem(String(target), {
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: () => reload(() => {
- if (user && user.subscriptions.includes(target)) {
- user.subscriptions.splice(user.subscriptions.findIndex(item => item === target), 1);
- }
- if (callback) callback();
- })
- });
- }, [setError, reload, user]);
+ (target: number, callback?: () => void) => {
+ setError(undefined);
+ deleteLibraryItem(String(target), {
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: () =>
+ reload(() => {
+ if (user && user.subscriptions.includes(target)) {
+ user.subscriptions.splice(
+ user.subscriptions.findIndex(item => item === target),
+ 1
+ );
+ }
+ if (callback) callback();
+ })
+ });
+ },
+ [setError, reload, user]
+ );
const cloneItem = useCallback(
- (target: number, data: IRSFormCreateData, callback: DataCallback) => {
- if (!user) {
- return;
- }
- setError(undefined)
- postCloneLibraryItem(String(target), {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newSchema => reload(() => {
- if (user && !user.subscriptions.includes(newSchema.id)) {
- user.subscriptions.push(newSchema.id);
- }
- if (callback) callback(newSchema);
- })
- });
- }, [reload, setError, user]);
+ (target: number, data: IRSFormCreateData, callback: DataCallback) => {
+ if (!user) {
+ return;
+ }
+ setError(undefined);
+ postCloneLibraryItem(String(target), {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newSchema =>
+ reload(() => {
+ if (user && !user.subscriptions.includes(newSchema.id)) {
+ user.subscriptions.push(newSchema.id);
+ }
+ if (callback) callback(newSchema);
+ })
+ });
+ },
+ [reload, setError, user]
+ );
return (
-
- {children}
- );
-}
\ No newline at end of file
+
+ {children}
+
+ );
+};
diff --git a/rsconcept/frontend/src/context/NavigationContext.tsx b/rsconcept/frontend/src/context/NavigationContext.tsx
index aa72f0cf..d286b0b6 100644
--- a/rsconcept/frontend/src/context/NavigationContext.tsx
+++ b/rsconcept/frontend/src/context/NavigationContext.tsx
@@ -5,16 +5,16 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { globalIDs } from '@/utils/constants';
-interface INavigationContext{
- push: (path: string) => void
- replace: (path: string) => void
- back: () => void
- forward: () => void
+interface INavigationContext {
+ push: (path: string) => void;
+ replace: (path: string) => void;
+ back: () => void;
+ forward: () => void;
- canBack: () => boolean
-
- isBlocked: boolean
- setIsBlocked: (value: boolean) => void
+ canBack: () => boolean;
+
+ isBlocked: boolean;
+ setIsBlocked: (value: boolean) => void;
}
const NavigationContext = createContext(null);
@@ -24,56 +24,54 @@ export const useConceptNavigation = () => {
throw new Error('useConceptNavigation has to be used within ');
}
return context;
-}
+};
interface NavigationStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const NavigationState = ({ children }: NavigationStateProps) => {
const router = useNavigate();
const { pathname } = useLocation();
-
+
const [isBlocked, setIsBlocked] = useState(false);
- const validate = useCallback(
- () => {
- return (
- !isBlocked ||
- confirm('Изменения не сохранены. Вы уверены что хотите совершить переход?')
- );
+ const validate = useCallback(() => {
+ return !isBlocked || confirm('Изменения не сохранены. Вы уверены что хотите совершить переход?');
}, [isBlocked]);
- const canBack = useCallback(() => (!!window.history && window.history?.length !== 0), []);
+ const canBack = useCallback(() => !!window.history && window.history?.length !== 0, []);
- const scrollTop = useCallback(
- () => {
+ const scrollTop = useCallback(() => {
window.scrollTo(0, 0);
const mainScroll = document.getElementById(globalIDs.main_scroll);
if (mainScroll) {
- mainScroll.scroll(0,0);
+ mainScroll.scroll(0, 0);
}
}, []);
const push = useCallback(
- (path: string) => {
- if (validate()) {
- scrollTop();
- router(path);
- setIsBlocked(false);
- }
- }, [router, validate, scrollTop]);
+ (path: string) => {
+ if (validate()) {
+ scrollTop();
+ router(path);
+ setIsBlocked(false);
+ }
+ },
+ [router, validate, scrollTop]
+ );
const replace = useCallback(
- (path: string) => {
- if (validate()) {
- scrollTop();
- router(path, {replace: true});
- setIsBlocked(false);
- }
- }, [router, validate, scrollTop]);
+ (path: string) => {
+ if (validate()) {
+ scrollTop();
+ router(path, { replace: true });
+ setIsBlocked(false);
+ }
+ },
+ [router, validate, scrollTop]
+ );
- const back = useCallback(
- () => {
+ const back = useCallback(() => {
if (validate()) {
scrollTop();
router(-1);
@@ -81,8 +79,7 @@ export const NavigationState = ({ children }: NavigationStateProps) => {
}
}, [router, validate, scrollTop]);
- const forward = useCallback(
- () => {
+ const forward = useCallback(() => {
if (validate()) {
scrollTop();
router(1);
@@ -95,19 +92,26 @@ export const NavigationState = ({ children }: NavigationStateProps) => {
}, [pathname, scrollTop]);
return (
-
- {children}
- );
-}
+
+ {children}
+
+ );
+};
export function useBlockNavigation(isBlocked: boolean) {
const router = useConceptNavigation();
- useEffect(
- () => {
+ useEffect(() => {
router.setIsBlocked(isBlocked);
return () => router.setIsBlocked(false);
}, [router, isBlocked]);
-}
\ No newline at end of file
+}
diff --git a/rsconcept/frontend/src/context/RSFormContext.tsx b/rsconcept/frontend/src/context/RSFormContext.tsx
index 839dff60..2f13083c 100644
--- a/rsconcept/frontend/src/context/RSFormContext.tsx
+++ b/rsconcept/frontend/src/context/RSFormContext.tsx
@@ -7,61 +7,73 @@ import useRSFormDetails from '@/hooks/useRSFormDetails';
import { ILibraryItem } from '@/models/library';
import { ILibraryUpdateData } from '@/models/library';
import {
- IConstituentaList, IConstituentaMeta, ICstCreateData,
- ICstMovetoData, ICstRenameData, ICstUpdateData,
- IRSForm, IRSFormUploadData
+ IConstituentaList,
+ IConstituentaMeta,
+ ICstCreateData,
+ ICstMovetoData,
+ ICstRenameData,
+ ICstUpdateData,
+ IRSForm,
+ IRSFormUploadData
} from '@/models/rsform';
import {
- type DataCallback, deleteUnsubscribe,
+ type DataCallback,
+ deleteUnsubscribe,
getTRSFile,
- patchConstituenta, patchDeleteConstituenta,
+ patchConstituenta,
+ patchDeleteConstituenta,
patchLibraryItem,
- patchMoveConstituenta, patchRenameConstituenta,
- patchResetAliases, patchUploadTRS, postClaimLibraryItem, postNewConstituenta, postSubscribe
+ patchMoveConstituenta,
+ patchRenameConstituenta,
+ patchResetAliases,
+ patchUploadTRS,
+ postClaimLibraryItem,
+ postNewConstituenta,
+ postSubscribe
} from '@/utils/backendAPI';
import { useAuth } from './AuthContext';
import { useLibrary } from './LibraryContext';
interface IRSFormContext {
- schema?: IRSForm
+ schema?: IRSForm;
- error: ErrorData
- loading: boolean
- processing: boolean
+ error: ErrorData;
+ loading: boolean;
+ processing: boolean;
- isOwned: boolean
- isClaimable: boolean
- isSubscribed: boolean
-
- update: (data: ILibraryUpdateData, callback?: DataCallback) => void
- claim: (callback?: DataCallback) => void
- subscribe: (callback?: () => void) => void
- unsubscribe: (callback?: () => void) => void
- download: (callback: DataCallback) => void
- upload: (data: IRSFormUploadData, callback: () => void) => void
+ isOwned: boolean;
+ isClaimable: boolean;
+ isSubscribed: boolean;
- resetAliases: (callback: () => void) => void
+ update: (data: ILibraryUpdateData, callback?: DataCallback) => void;
+ claim: (callback?: DataCallback) => void;
+ subscribe: (callback?: () => void) => void;
+ unsubscribe: (callback?: () => void) => void;
+ download: (callback: DataCallback) => void;
+ upload: (data: IRSFormUploadData, callback: () => void) => void;
- cstCreate: (data: ICstCreateData, callback?: DataCallback) => void
- cstRename: (data: ICstRenameData, callback?: DataCallback) => void
- cstUpdate: (data: ICstUpdateData, callback?: DataCallback) => void
- cstDelete: (data: IConstituentaList, callback?: () => void) => void
- cstMoveTo: (data: ICstMovetoData, callback?: () => void) => void
+ resetAliases: (callback: () => void) => void;
+
+ cstCreate: (data: ICstCreateData, callback?: DataCallback) => void;
+ cstRename: (data: ICstRenameData, callback?: DataCallback) => void;
+ cstUpdate: (data: ICstUpdateData, callback?: DataCallback) => void;
+ cstDelete: (data: IConstituentaList, callback?: () => void) => void;
+ cstMoveTo: (data: ICstMovetoData, callback?: () => void) => void;
}
-const RSFormContext = createContext(null)
+const RSFormContext = createContext(null);
export const useRSForm = () => {
- const context = useContext(RSFormContext)
+ const context = useContext(RSFormContext);
if (context === null) {
throw new Error('useRSForm has to be used within ');
}
return context;
-}
+};
interface RSFormStateProps {
- schemaID: string
- children: React.ReactNode
+ schemaID: string;
+ children: React.ReactNode;
}
export const RSFormState = ({ schemaID, children }: RSFormStateProps) => {
@@ -72,247 +84,285 @@ export const RSFormState = ({ schemaID, children }: RSFormStateProps) => {
const [toggleTracking, setToggleTracking] = useState(false);
- const isOwned = useMemo(
- () => {
+ const isOwned = useMemo(() => {
return user?.id === schema?.owner || false;
}, [user, schema?.owner]);
- const isClaimable = useMemo(
- () => {
+ const isClaimable = useMemo(() => {
return (user?.id !== schema?.owner && schema?.is_common && !schema?.is_canonical) ?? false;
}, [user, schema?.owner, schema?.is_common, schema?.is_canonical]);
- const isSubscribed = useMemo(
- () => {
+ const isSubscribed = useMemo(() => {
if (!user || !schema || !user.id) {
return false;
}
return schema.subscribers.includes(user.id);
- // eslint-disable-next-line react-hooks/exhaustive-deps
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [user, schema, toggleTracking]);
const update = useCallback(
- (data: ILibraryUpdateData, callback?: DataCallback) => {
- if (!schema) {
- return;
- }
- setError(undefined)
- patchLibraryItem(schemaID, {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(Object.assign(schema, newData));
- library.localUpdateItem(newData);
- if (callback) callback(newData);
+ (data: ILibraryUpdateData, callback?: DataCallback) => {
+ if (!schema) {
+ return;
}
- });
- }, [schemaID, setError, setSchema, schema, library]);
-
+ setError(undefined);
+ patchLibraryItem(schemaID, {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(Object.assign(schema, newData));
+ library.localUpdateItem(newData);
+ if (callback) callback(newData);
+ }
+ });
+ },
+ [schemaID, setError, setSchema, schema, library]
+ );
+
const upload = useCallback(
- (data: IRSFormUploadData, callback?: () => void) => {
- if (!schema) {
- return;
- }
- setError(undefined)
- patchUploadTRS(schemaID, {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(newData);
- library.localUpdateItem(newData);
- if (callback) callback();
+ (data: IRSFormUploadData, callback?: () => void) => {
+ if (!schema) {
+ return;
}
- });
- }, [schemaID, setError, setSchema, schema, library]);
+ setError(undefined);
+ patchUploadTRS(schemaID, {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(newData);
+ library.localUpdateItem(newData);
+ if (callback) callback();
+ }
+ });
+ },
+ [schemaID, setError, setSchema, schema, library]
+ );
const claim = useCallback(
- (callback?: DataCallback) => {
- if (!schema || !user) {
- return;
- }
- setError(undefined)
- postClaimLibraryItem(schemaID, {
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(Object.assign(schema, newData));
- library.localUpdateItem(newData);
- if (!user.subscriptions.includes(newData.id)) {
- user.subscriptions.push(newData.id);
- }
- if (callback) callback(newData);
+ (callback?: DataCallback) => {
+ if (!schema || !user) {
+ return;
}
- });
- }, [schemaID, setError, schema, user, setSchema, library]);
-
+ setError(undefined);
+ postClaimLibraryItem(schemaID, {
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(Object.assign(schema, newData));
+ library.localUpdateItem(newData);
+ if (!user.subscriptions.includes(newData.id)) {
+ user.subscriptions.push(newData.id);
+ }
+ if (callback) callback(newData);
+ }
+ });
+ },
+ [schemaID, setError, schema, user, setSchema, library]
+ );
+
const subscribe = useCallback(
- (callback?: () => void) => {
- if (!schema || !user) {
- return;
- }
- setError(undefined)
- postSubscribe(schemaID, {
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: () => {
- if (user.id && !schema.subscribers.includes(user.id)) {
- schema.subscribers.push(user.id);
- }
- if (!user.subscriptions.includes(schema.id)) {
- user.subscriptions.push(schema.id);
- }
- setToggleTracking(prev => !prev);
- if (callback) callback();
+ (callback?: () => void) => {
+ if (!schema || !user) {
+ return;
}
- });
- }, [schemaID, setError, schema, user]);
+ setError(undefined);
+ postSubscribe(schemaID, {
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: () => {
+ if (user.id && !schema.subscribers.includes(user.id)) {
+ schema.subscribers.push(user.id);
+ }
+ if (!user.subscriptions.includes(schema.id)) {
+ user.subscriptions.push(schema.id);
+ }
+ setToggleTracking(prev => !prev);
+ if (callback) callback();
+ }
+ });
+ },
+ [schemaID, setError, schema, user]
+ );
const unsubscribe = useCallback(
- (callback?: () => void) => {
- if (!schema || !user) {
- return;
- }
- setError(undefined)
- deleteUnsubscribe(schemaID, {
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: () => {
- if (user.id && schema.subscribers.includes(user.id)) {
- schema.subscribers.splice(schema.subscribers.indexOf(user.id), 1);
- }
- if (user.subscriptions.includes(schema.id)) {
- user.subscriptions.splice(user.subscriptions.indexOf(schema.id), 1);
- }
- setToggleTracking(prev => !prev);
- if (callback) callback();
+ (callback?: () => void) => {
+ if (!schema || !user) {
+ return;
}
- });
- }, [schemaID, setError, schema, user]);
+ setError(undefined);
+ deleteUnsubscribe(schemaID, {
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: () => {
+ if (user.id && schema.subscribers.includes(user.id)) {
+ schema.subscribers.splice(schema.subscribers.indexOf(user.id), 1);
+ }
+ if (user.subscriptions.includes(schema.id)) {
+ user.subscriptions.splice(user.subscriptions.indexOf(schema.id), 1);
+ }
+ setToggleTracking(prev => !prev);
+ if (callback) callback();
+ }
+ });
+ },
+ [schemaID, setError, schema, user]
+ );
const resetAliases = useCallback(
- (callback?: () => void) => {
- if (!schema || !user) {
- return;
- }
- setError(undefined)
- patchResetAliases(schemaID, {
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(Object.assign(schema, newData));
- library.localUpdateTimestamp(newData.id);
- if (callback) callback();
+ (callback?: () => void) => {
+ if (!schema || !user) {
+ return;
}
- });
- }, [schemaID, setError, schema, library, user, setSchema]);
+ setError(undefined);
+ patchResetAliases(schemaID, {
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(Object.assign(schema, newData));
+ library.localUpdateTimestamp(newData.id);
+ if (callback) callback();
+ }
+ });
+ },
+ [schemaID, setError, schema, library, user, setSchema]
+ );
const download = useCallback(
- (callback: DataCallback) => {
- setError(undefined)
- getTRSFile(schemaID, {
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: callback
- });
- }, [schemaID, setError]);
+ (callback: DataCallback) => {
+ setError(undefined);
+ getTRSFile(schemaID, {
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: callback
+ });
+ },
+ [schemaID, setError]
+ );
const cstCreate = useCallback(
- (data: ICstCreateData, callback?: DataCallback) => {
- setError(undefined)
- postNewConstituenta(schemaID, {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(newData.schema);
- library.localUpdateTimestamp(newData.schema.id);
- if (callback) callback(newData.new_cst);
- }
- });
- }, [schemaID, setError, library, setSchema]);
+ (data: ICstCreateData, callback?: DataCallback) => {
+ setError(undefined);
+ postNewConstituenta(schemaID, {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(newData.schema);
+ library.localUpdateTimestamp(newData.schema.id);
+ if (callback) callback(newData.new_cst);
+ }
+ });
+ },
+ [schemaID, setError, library, setSchema]
+ );
const cstDelete = useCallback(
- (data: IConstituentaList, callback?: () => void) => {
- setError(undefined)
- patchDeleteConstituenta(schemaID, {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(newData);
- library.localUpdateTimestamp(newData.id);
- if (callback) callback();
- }
- });
- }, [schemaID, setError, library, setSchema]);
+ (data: IConstituentaList, callback?: () => void) => {
+ setError(undefined);
+ patchDeleteConstituenta(schemaID, {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(newData);
+ library.localUpdateTimestamp(newData.id);
+ if (callback) callback();
+ }
+ });
+ },
+ [schemaID, setError, library, setSchema]
+ );
const cstUpdate = useCallback(
- (data: ICstUpdateData, callback?: DataCallback) => {
- setError(undefined)
- patchConstituenta(String(data.id), {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => reload(setProcessing, () => {
- library.localUpdateTimestamp(Number(schemaID));
- if (callback) callback(newData);
- })
- });
- }, [setError, schemaID, library, reload]);
+ (data: ICstUpdateData, callback?: DataCallback) => {
+ setError(undefined);
+ patchConstituenta(String(data.id), {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData =>
+ reload(setProcessing, () => {
+ library.localUpdateTimestamp(Number(schemaID));
+ if (callback) callback(newData);
+ })
+ });
+ },
+ [setError, schemaID, library, reload]
+ );
const cstRename = useCallback(
- (data: ICstRenameData, callback?: DataCallback) => {
- setError(undefined)
- patchRenameConstituenta(schemaID, {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(newData.schema);
- library.localUpdateTimestamp(newData.schema.id);
- if (callback) callback(newData.new_cst);
- }
- });
- }, [setError, setSchema, library, schemaID]);
+ (data: ICstRenameData, callback?: DataCallback) => {
+ setError(undefined);
+ patchRenameConstituenta(schemaID, {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(newData.schema);
+ library.localUpdateTimestamp(newData.schema.id);
+ if (callback) callback(newData.new_cst);
+ }
+ });
+ },
+ [setError, setSchema, library, schemaID]
+ );
const cstMoveTo = useCallback(
- (data: ICstMovetoData, callback?: () => void) => {
- setError(undefined)
- patchMoveConstituenta(schemaID, {
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setSchema(newData);
- library.localUpdateTimestamp(Number(schemaID));
- if (callback) callback();
- }
- });
- }, [schemaID, setError, library, setSchema]);
+ (data: ICstMovetoData, callback?: () => void) => {
+ setError(undefined);
+ patchMoveConstituenta(schemaID, {
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setSchema(newData);
+ library.localUpdateTimestamp(Number(schemaID));
+ if (callback) callback();
+ }
+ });
+ },
+ [schemaID, setError, library, setSchema]
+ );
return (
-
- { children }
- );
-}
\ No newline at end of file
+
+ {children}
+
+ );
+};
diff --git a/rsconcept/frontend/src/context/ThemeContext.tsx b/rsconcept/frontend/src/context/ThemeContext.tsx
index 873b41a4..285aaccf 100644
--- a/rsconcept/frontend/src/context/ThemeContext.tsx
+++ b/rsconcept/frontend/src/context/ThemeContext.tsx
@@ -10,23 +10,23 @@ import { darkT, IColorTheme, lightT } from '@/utils/color';
import { globalIDs } from '@/utils/constants';
interface IThemeContext {
- viewportHeight: string
- mainHeight: string
-
- colors: IColorTheme
-
- darkMode: boolean
- toggleDarkMode: () => void
+ viewportHeight: string;
+ mainHeight: string;
- noNavigationAnimation: boolean
- noNavigation: boolean
- toggleNoNavigation: () => void
+ colors: IColorTheme;
- noFooter: boolean
- setNoFooter: (value: boolean) => void
+ darkMode: boolean;
+ toggleDarkMode: () => void;
- showScroll: boolean
- setShowScroll: (value: boolean) => void
+ noNavigationAnimation: boolean;
+ noNavigation: boolean;
+ toggleNoNavigation: () => void;
+
+ noFooter: boolean;
+ setNoFooter: (value: boolean) => void;
+
+ showScroll: boolean;
+ setShowScroll: (value: boolean) => void;
}
const ThemeContext = createContext(null);
@@ -36,10 +36,10 @@ export const useConceptTheme = () => {
throw new Error('useConceptTheme has to be used within ');
}
return context;
-}
+};
interface ThemeStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const ThemeState = ({ children }: ThemeStateProps) => {
@@ -65,11 +65,10 @@ export const ThemeState = ({ children }: ThemeStateProps) => {
}, [darkMode]);
useLayoutEffect(() => {
- setColors(darkMode ? darkT : lightT)
+ setColors(darkMode ? darkT : lightT);
}, [darkMode, setColors]);
- const toggleNoNavigation = useCallback(
- () => {
+ const toggleNoNavigation = useCallback(() => {
if (noNavigation) {
setNoNavigationAnimation(false);
setNoNavigation(false);
@@ -79,40 +78,41 @@ export const ThemeState = ({ children }: ThemeStateProps) => {
}
}, [noNavigation]);
- const mainHeight = useMemo(
- () => {
- return !noNavigation ?
- 'calc(100vh - 7rem - 2px)'
- : '100vh';
+ const mainHeight = useMemo(() => {
+ return !noNavigation ? 'calc(100vh - 7rem - 2px)' : '100vh';
}, [noNavigation]);
- const viewportHeight = useMemo(
- () => {
- return !noNavigation ?
- 'calc(100vh - 3rem - 2px)'
- : '100vh';
+ const viewportHeight = useMemo(() => {
+ return !noNavigation ? 'calc(100vh - 3rem - 2px)' : '100vh';
}, [noNavigation]);
return (
- setDarkMode(prev => !prev),
- toggleNoNavigation: toggleNoNavigation,
- setNoFooter, setShowScroll,
- viewportHeight, mainHeight
- }}>
- <>
-
- {children}
- >
- );
-}
\ No newline at end of file
+ setDarkMode(prev => !prev),
+ toggleNoNavigation: toggleNoNavigation,
+ setNoFooter,
+ setShowScroll,
+ viewportHeight,
+ mainHeight
+ }}
+ >
+ <>
+
+ {children}
+ >
+
+ );
+};
diff --git a/rsconcept/frontend/src/context/UserProfileContext.tsx b/rsconcept/frontend/src/context/UserProfileContext.tsx
index 20cc0412..931081b7 100644
--- a/rsconcept/frontend/src/context/UserProfileContext.tsx
+++ b/rsconcept/frontend/src/context/UserProfileContext.tsx
@@ -10,12 +10,12 @@ import { DataCallback, getProfile, patchProfile } from '@/utils/backendAPI';
import { useUsers } from './UsersContext';
interface IUserProfileContext {
- user: IUserProfile | undefined
- loading: boolean
- processing: boolean
- error: ErrorData
- setError: (error: ErrorData) => void
- updateUser: (data: IUserUpdateData, callback?: DataCallback) => void
+ user: IUserProfile | undefined;
+ loading: boolean;
+ processing: boolean;
+ error: ErrorData;
+ setError: (error: ErrorData) => void;
+ updateUser: (data: IUserUpdateData, callback?: DataCallback) => void;
}
const ProfileContext = createContext(null);
@@ -23,15 +23,13 @@ const ProfileContext = createContext(null);
export const useUserProfile = () => {
const context = useContext(ProfileContext);
if (!context) {
- throw new Error(
- 'useUserProfile has to be used within '
- );
+ throw new Error('useUserProfile has to be used within ');
}
return context;
-}
+};
interface UserProfileStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const UserProfileState = ({ children }: UserProfileStateProps) => {
@@ -41,8 +39,7 @@ export const UserProfileState = ({ children }: UserProfileStateProps) => {
const [processing, setProcessing] = useState(false);
const [error, setError] = useState(undefined);
- const reload = useCallback(
- () => {
+ const reload = useCallback(() => {
setError(undefined);
setUser(undefined);
getProfile({
@@ -52,36 +49,36 @@ export const UserProfileState = ({ children }: UserProfileStateProps) => {
onSuccess: newData => setUser(newData)
});
}, [setUser]);
-
+
const updateUser = useCallback(
- (data: IUserUpdateData, callback?: DataCallback) => {
- setError(undefined);
- patchProfile({
- data: data,
- showError: true,
- setLoading: setProcessing,
- onError: error => setError(error),
- onSuccess: newData => {
- setUser(newData);
- const libraryUser = users.find(item => item.id === user?.id);
- if (libraryUser) {
- libraryUser.first_name = newData.first_name;
- libraryUser.last_name = newData.last_name;
+ (data: IUserUpdateData, callback?: DataCallback) => {
+ setError(undefined);
+ patchProfile({
+ data: data,
+ showError: true,
+ setLoading: setProcessing,
+ onError: error => setError(error),
+ onSuccess: newData => {
+ setUser(newData);
+ const libraryUser = users.find(item => item.id === user?.id);
+ if (libraryUser) {
+ libraryUser.first_name = newData.first_name;
+ libraryUser.last_name = newData.last_name;
+ }
+ if (callback) callback(newData);
}
- if (callback) callback(newData);
- }
- });
- }, [setUser, users, user?.id]);
+ });
+ },
+ [setUser, users, user?.id]
+ );
useEffect(() => {
reload();
}, [reload]);
return (
-
+
{children}
);
-};
\ No newline at end of file
+};
diff --git a/rsconcept/frontend/src/context/UsersContext.tsx b/rsconcept/frontend/src/context/UsersContext.tsx
index 06f8e950..98c64669 100644
--- a/rsconcept/frontend/src/context/UsersContext.tsx
+++ b/rsconcept/frontend/src/context/UsersContext.tsx
@@ -6,31 +6,31 @@ import { type IUserInfo } from '@/models/library';
import { getActiveUsers } from '@/utils/backendAPI';
interface IUsersContext {
- users: IUserInfo[]
- reload: (callback?: () => void) => void
- getUserLabel: (userID: number | null) => string
+ users: IUserInfo[];
+ reload: (callback?: () => void) => void;
+ getUserLabel: (userID: number | null) => string;
}
-const UsersContext = createContext(null)
+const UsersContext = createContext(null);
export const useUsers = (): IUsersContext => {
const context = useContext(UsersContext);
if (context === null) {
throw new Error('useUsers has to be used within ');
}
return context;
-}
+};
interface UsersStateProps {
- children: React.ReactNode
+ children: React.ReactNode;
}
export const UsersState = ({ children }: UsersStateProps) => {
- const [users, setUsers] = useState([])
+ const [users, setUsers] = useState([]);
function getUserLabel(userID: number | null) {
- const user = users.find(({ id }) => id === userID)
+ const user = users.find(({ id }) => id === userID);
if (!user) {
- return (userID ? userID.toString() : 'Отсутствует');
+ return userID ? userID.toString() : 'Отсутствует';
}
const hasFirstName = user.first_name !== '';
const hasLastName = user.last_name !== '';
@@ -47,27 +47,32 @@ export const UsersState = ({ children }: UsersStateProps) => {
}
const reload = useCallback(
- (callback?: () => void) => {
- getActiveUsers({
- showError: true,
- onError: () => setUsers([]),
- onSuccess: newData => {
- setUsers(newData);
- if (callback) callback();
- }
- });
- }, [setUsers]);
+ (callback?: () => void) => {
+ getActiveUsers({
+ showError: true,
+ onError: () => setUsers([]),
+ onSuccess: newData => {
+ setUsers(newData);
+ if (callback) callback();
+ }
+ });
+ },
+ [setUsers]
+ );
useEffect(() => {
reload();
}, [reload]);
return (
-
- { children }
- );
-}
\ No newline at end of file
+
+ {children}
+
+ );
+};
diff --git a/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx b/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx
index 27a19db9..0f17cfaf 100644
--- a/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx
+++ b/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx
@@ -15,9 +15,8 @@ import { IRSFormCreateData } from '@/models/rsform';
import { classnames } from '@/utils/constants';
import { cloneTitle } from '@/utils/misc';
-interface DlgCloneLibraryItemProps
-extends Pick {
- base: ILibraryItem
+interface DlgCloneLibraryItemProps extends Pick {
+ base: ILibraryItem;
}
function DlgCloneLibraryItem({ hideWindow, base }: DlgCloneLibraryItemProps) {
@@ -30,7 +29,7 @@ function DlgCloneLibraryItem({ hideWindow, base }: DlgCloneLibraryItemProps) {
const { cloneItem } = useLibrary();
- const canSubmit = useMemo(() => (title !== '' && alias !== ''), [title, alias]);
+ const canSubmit = useMemo(() => title !== '' && alias !== '', [title, alias]);
useEffect(() => {
if (base) {
@@ -58,36 +57,25 @@ function DlgCloneLibraryItem({ hideWindow, base }: DlgCloneLibraryItemProps) {
}
return (
-
- setTitle(event.target.value)}
- />
- setAlias(event.target.value)}
- />
- );
+
+ setTitle(event.target.value)} />
+ setAlias(event.target.value)}
+ />
+
+ );
}
-export default DlgCloneLibraryItem;
\ No newline at end of file
+export default DlgCloneLibraryItem;
diff --git a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ArgumentsTab.tsx b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ArgumentsTab.tsx
index 85980cc1..a3eebf14 100644
--- a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ArgumentsTab.tsx
+++ b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ArgumentsTab.tsx
@@ -15,217 +15,208 @@ import { IArgumentValue } from '@/models/rslang';
import { prefixes } from '@/utils/constants';
interface ArgumentsTabProps {
- state: IArgumentsState
- schema: IRSForm
- partialUpdate: Dispatch>
+ state: IArgumentsState;
+ schema: IRSForm;
+ partialUpdate: Dispatch>;
}
export interface IArgumentsState {
- arguments: IArgumentValue[]
- definition: string
+ arguments: IArgumentValue[];
+ definition: string;
}
const argumentsHelper = createColumnHelper();
-function ArgumentsTab({ state, schema, partialUpdate }: ArgumentsTabProps) {
+function ArgumentsTab({ state, schema, partialUpdate }: ArgumentsTabProps) {
const { colors } = useConceptTheme();
-
+
const [selectedCst, setSelectedCst] = useState(undefined);
const [selectedArgument, setSelectedArgument] = useState(undefined);
const [argumentValue, setArgumentValue] = useState('');
- const selectedClearable = useMemo(
- () => {
+ const selectedClearable = useMemo(() => {
return argumentValue && !!selectedArgument && !!selectedArgument.value;
}, [argumentValue, selectedArgument]);
const isModified = useMemo(
- () => (selectedArgument && argumentValue !== selectedArgument.value),
- [selectedArgument, argumentValue]);
+ () => selectedArgument && argumentValue !== selectedArgument.value,
+ [selectedArgument, argumentValue]
+ );
- useEffect(
- () => {
+ useEffect(() => {
if (!selectedArgument && state.arguments.length > 0) {
setSelectedArgument(state.arguments[0]);
}
}, [state.arguments, selectedArgument]);
- const handleSelectArgument = useCallback(
- (arg: IArgumentValue) => {
+ const handleSelectArgument = useCallback((arg: IArgumentValue) => {
setSelectedArgument(arg);
if (arg.value) {
setArgumentValue(arg.value);
}
}, []);
- const handleSelectConstituenta = useCallback(
- (cst: IConstituenta) => {
+ const handleSelectConstituenta = useCallback((cst: IConstituenta) => {
setSelectedCst(cst);
setArgumentValue(cst.alias);
}, []);
const handleClearArgument = useCallback(
- (target: IArgumentValue) => {
- const newArg = { ...target, value: '' }
- partialUpdate({
- arguments: state.arguments.map((arg) => (arg.alias !== target.alias ? arg : newArg))
- });
- setSelectedArgument(newArg);
- }, [partialUpdate, state.arguments]);
+ (target: IArgumentValue) => {
+ const newArg = { ...target, value: '' };
+ partialUpdate({
+ arguments: state.arguments.map(arg => (arg.alias !== target.alias ? arg : newArg))
+ });
+ setSelectedArgument(newArg);
+ },
+ [partialUpdate, state.arguments]
+ );
- const handleReset = useCallback(
- () => {
+ const handleReset = useCallback(() => {
setArgumentValue(selectedArgument?.value ?? '');
}, [selectedArgument]);
const handleAssignArgument = useCallback(
- (target: IArgumentValue, value: string) => {
- const newArg = { ...target, value: value }
- partialUpdate({
- arguments: state.arguments.map((arg) => (arg.alias !== target.alias ? arg : newArg))
- });
- setSelectedArgument(newArg);
- }, [partialUpdate, state.arguments]);
+ (target: IArgumentValue, value: string) => {
+ const newArg = { ...target, value: value };
+ partialUpdate({
+ arguments: state.arguments.map(arg => (arg.alias !== target.alias ? arg : newArg))
+ });
+ setSelectedArgument(newArg);
+ },
+ [partialUpdate, state.arguments]
+ );
const columns = useMemo(
- () => [
- argumentsHelper.accessor('alias', {
- id: 'alias',
- header: 'Имя',
- size: 40,
- minSize: 40,
- maxSize: 40,
- cell: props =>
-
- {props.getValue()}
-
- }),
- argumentsHelper.accessor(arg => arg.value || 'свободный аргумент', {
- id: 'value',
- header: 'Значение',
- size: 200,
- minSize: 200,
- maxSize: 200,
- }),
- argumentsHelper.accessor(arg => arg.typification, {
- id: 'type',
- header: 'Типизация',
- size: 150,
- minSize: 150,
- maxSize: 150,
- enableHiding: true,
- cell: props =>
-
- {props.getValue()}
-
- }),
- argumentsHelper.display({
- id: 'actions',
- size: 50,
- minSize: 50,
- maxSize: 50,
- cell: props =>
-
- {props.row.original.value ?
- }
- noHover
- onClick={() => handleClearArgument(props.row.original)}
- /> : null}
-
- })
- ], [handleClearArgument]);
+ () => [
+ argumentsHelper.accessor('alias', {
+ id: 'alias',
+ header: 'Имя',
+ size: 40,
+ minSize: 40,
+ maxSize: 40,
+ cell: props => {props.getValue()}
+ }),
+ argumentsHelper.accessor(arg => arg.value || 'свободный аргумент', {
+ id: 'value',
+ header: 'Значение',
+ size: 200,
+ minSize: 200,
+ maxSize: 200
+ }),
+ argumentsHelper.accessor(arg => arg.typification, {
+ id: 'type',
+ header: 'Типизация',
+ size: 150,
+ minSize: 150,
+ maxSize: 150,
+ enableHiding: true,
+ cell: props => (
+ {props.getValue()}
+ )
+ }),
+ argumentsHelper.display({
+ id: 'actions',
+ size: 50,
+ minSize: 50,
+ maxSize: 50,
+ cell: props => (
+
+ {props.row.original.value ? (
+ }
+ noHover
+ onClick={() => handleClearArgument(props.row.original)}
+ />
+ ) : null}
+
+ )
+ })
+ ],
+ [handleClearArgument]
+ );
const conditionalRowStyles = useMemo(
- (): IConditionalStyle[] => [{
- when: (arg: IArgumentValue) => arg.alias === selectedArgument?.alias,
- style: { backgroundColor: colors.bgSelected },
- }], [selectedArgument, colors]);
+ (): IConditionalStyle[] => [
+ {
+ when: (arg: IArgumentValue) => arg.alias === selectedArgument?.alias,
+ style: { backgroundColor: colors.bgSelected }
+ }
+ ],
+ [selectedArgument, colors]
+ );
return (
- <>
-
- Аргументы отсутствуют
-
- }
- onRowClicked={handleSelectArgument}
- />
-
-
-
- {selectedArgument?.alias || 'ARG'}
-
-
=
-
setArgumentValue(newValue)}
+ <>
+ Аргументы отсутствуют}
+ onRowClicked={handleSelectArgument}
/>
-
-
}
- disabled={!argumentValue || !selectedArgument}
- onClick={() => handleAssignArgument(selectedArgument!, argumentValue)}
- />
-
}
- />
-
}
- onClick={() => selectedArgument ? handleClearArgument(selectedArgument) : undefined}
+
+
+
+ {selectedArgument?.alias || 'ARG'}
+
+
=
+
setArgumentValue(newValue)}
/>
+
+
+ }
+ disabled={!argumentValue || !selectedArgument}
+ onClick={() => handleAssignArgument(selectedArgument!, argumentValue)}
+ />
+ }
+ />
+ }
+ onClick={() => (selectedArgument ? handleClearArgument(selectedArgument) : undefined)}
+ />
+
-
-
+
-
- >);
+
+ >
+ );
}
-export default ArgumentsTab;
\ No newline at end of file
+export default ArgumentsTab;
diff --git a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ConstituentaTab.tsx b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ConstituentaTab.tsx
index 84c01636..d2155ab0 100644
--- a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ConstituentaTab.tsx
+++ b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/ConstituentaTab.tsx
@@ -11,58 +11,62 @@ import { labelCstType } from '@/utils/labels';
import { SelectorCstType } from '@/utils/selectors';
interface ConstituentaTabProps {
- state: ICstCreateData
- partialUpdate: Dispatch>
+ state: ICstCreateData;
+ partialUpdate: Dispatch>;
}
-function ConstituentaTab({state, partialUpdate}: ConstituentaTabProps) {
+function ConstituentaTab({ state, partialUpdate }: ConstituentaTabProps) {
return (
- <>
-
-
partialUpdate({ cst_type: data?.value ?? CstType.TERM})}
+ <>
+
+ partialUpdate({ cst_type: data?.value ?? CstType.TERM })}
+ />
+ partialUpdate({ alias: event.target.value })}
+ />
+
+
-