Skip to content

Commit

Permalink
fixes after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Dec 13, 2024
1 parent 56728a8 commit ea97aca
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/common/hooks/useComplexLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const useComplexLookup = ({
const {
setComplexValue,
resetComplexValue: resetMarcPreviewData,
metaData: marcPreviewMetadata,
resetMetaData: resetMarcPreviewMetadata,
metadata: marcPreviewMetadata,
resetMetadata: resetMarcPreviewMetadata,
} = useMarcPreviewState();
const { resetIsMarcPreviewOpen } = useUIState();
const { isModalOpen, setIsModalOpen, openModal } = useModalControls();
Expand Down
2 changes: 1 addition & 1 deletion src/common/hooks/useContainerEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type IUseContainerEvents =

export const useContainerEvents = ({ onTriggerModal, watchEditedState = false }: IUseContainerEvents = {}) => {
const { hasNavigationOrigin } = useConfigState();
const { isEditedRecord: isEdited } = useStatusState();
const { isRecordEdited: isEdited } = useStatusState();
const { customEvents } = useConfigState();
const {
BLOCK_NAVIGATION,
Expand Down
2 changes: 1 addition & 1 deletion src/common/hooks/useProfileSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const useProfileSchema = () => {
const { selectedEntriesService, schemaWithDuplicatesService } = useServicesContext() as Required<ServicesParams>;
const { setCollapsibleEntries } = useUIState();
const { setUserValues, setSelectedEntries } = useInputsState();
const { setIsEditedRecord: setIsEdited } = useStatusState();
const { setIsRecordEdited: setIsEdited } = useStatusState();
const { schema, setSchema } = useProfileState();

const getSchemaWithCopiedEntries = (entry: SchemaEntry, selectedEntries: string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/hooks/useRecordControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useRecordControls = () => {
const { setSelectedProfile } = useProfileState();
const { setIsDuplicateImportedResourceModalOpen, setCurrentlyEditedEntityBfid, setCurrentlyPreviewedEntityBfid } =
useUIState();
const { setRecordStatus, setLastSavedRecordId, setIsEditedRecord: setIsEdited, addStatusMessagesItem } = useStatusState();
const { setRecordStatus, setLastSavedRecordId, setIsRecordEdited: setIsEdited, addStatusMessagesItem } = useStatusState();
const profile = PROFILE_BFIDS.MONOGRAPH;
const currentRecordId = getRecordId(record);
const { getProfiles } = useConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type MarcPreviewComplexLookupProps = {
export const MarcPreviewComplexLookup: FC<MarcPreviewComplexLookupProps> = ({ onClose }) => {
const { onAssignRecord } = useSearchContext();
const { isMarcPreviewOpen } = useUIState();
const { complexValue: marcPreviewData, metaData: marcPreviewMetadata } = useMarcPreviewState();
const { complexValue: marcPreviewData, metadata: marcPreviewMetadata } = useMarcPreviewState();

const renderCloseButton = () => (
<Button data-testid="nav-close-button" type={ButtonType.Icon} onClick={onClose} className="nav-close">
Expand Down
4 changes: 2 additions & 2 deletions src/components/ComplexLookupField/ModalComplexLookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const ModalComplexLookup: FC<ModalComplexLookupProps> = memo(
const {
setComplexValue,
resetComplexValue: resetMarcPreviewValue,
setMetaData: setMarcMetadata,
resetMetaData: clearMarcMetadata,
setMetadata: setMarcMetadata,
resetMetadata: clearMarcMetadata,
} = useMarcPreviewState();
const { fetchMarcData } = useMarcData(setComplexValue);

Expand Down
2 changes: 1 addition & 1 deletion src/components/DeleteRecord/DeleteRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useInputsState, useStatusState } from '@src/store';

const DeleteRecord: FC = () => {
const { record } = useInputsState();
const { isEditedRecord: isEdited } = useStatusState();
const { isRecordEdited: isEdited } = useStatusState();
const resourceRoutePattern = useRoutePathPattern(RESOURCE_URLS);
const { deleteRecord } = useRecordControls();
const { isModalOpen, setIsModalOpen, openModal } = useModalControls();
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditSection/EditSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EditSection = memo(() => {
const resourceTemplates = selectedProfile?.json.Profile.resourceTemplates;
const { userValues, addUserValuesItem, selectedRecordBlocks, record, selectedEntries, setSelectedEntries } =
useInputsState();
const { isEditedRecord: isEdited, setIsEditedRecord: setIsEdited } = useStatusState();
const { isRecordEdited: isEdited, setIsRecordEdited: setIsEdited } = useStatusState();
const { collapsedEntries, setCollapsedEntries, collapsibleEntries, currentlyEditedEntityBfid } = useUIState();
const { generateRecord } = useRecordGeneration();

Expand Down
2 changes: 1 addition & 1 deletion src/components/Prompt/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Prompt: FC<Props> = ({ when: shouldPrompt }) => {
setIsModalOpen: setIsSwitchToNewRecordModalOpen,
openModal: openSwitchToNewRecordModal,
} = useModalControls();
const { setIsEditedRecord: setIsEdited, setRecordStatus } = useStatusState();
const { setIsRecordEdited: setIsEdited, setRecordStatus } = useStatusState();
const [forceNavigateTo, setForceNavigateTo] = useState<{
pathname: string;
search: string;
Expand Down
4 changes: 2 additions & 2 deletions src/components/SaveRecord/SaveRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { QueryParams } from '@common/constants/routes.constants';
import { useStatusState } from '@src/store';

const SaveRecord = ({ primary = false }) => {
const { isEditedRecord } = useStatusState();
const { isRecordEdited } = useStatusState();
const { saveRecord } = useRecordControls();
const { hasBeenSaved } = useRecordStatus();
const [searchParams] = useSearchParams();
Expand All @@ -18,7 +18,7 @@ const SaveRecord = ({ primary = false }) => {
data-testid={`save-record${primary ? '-and-close' : '-and-keep-editing'}`}
type={primary ? ButtonType.Primary : ButtonType.Highlighted}
onClick={() => saveRecord({ isNavigatingBack: primary })}
disabled={!searchParams.get(QueryParams.CloneOf) && !hasBeenSaved && !isEditedRecord}
disabled={!searchParams.get(QueryParams.CloneOf) && !hasBeenSaved && !isRecordEdited}
>
<FormattedMessage id={!primary ? 'ld.saveAndKeepEditing' : 'ld.saveAndClose'} />
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/store/stores/marcPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type MarcPreviewMetaData = MarcPreviewMetadata | null;

export type MarcPreviewState = SliceState<'basicValue', any> &
SliceState<'complexValue', MarcPreviewData> &
SliceState<'metaData', MarcPreviewMetaData>;
SliceState<'metadata', MarcPreviewMetaData>;

const STORE_NAME = 'MarcPreview';

Expand All @@ -17,7 +17,7 @@ const sliceConfigs: SliceConfigs = {
complexValue: {
initialValue: null,
},
metaData: {
metadata: {
initialValue: null,
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/store/stores/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type SliceState } from '../utils/slice';
type LastSavedRecordId = string | null;

export type StatusState = SliceState<'lastSavedRecordId', LastSavedRecordId> &
SliceState<'isEditedRecord', boolean> &
SliceState<'isRecordEdited', boolean> &
SliceState<'recordStatus', RecordStatus> &
SliceState<'statusMessages', StatusEntry[], StatusEntry>;

Expand All @@ -14,7 +14,7 @@ const sliceConfigs: SliceConfigs = {
lastSavedRecordId: {
initialValue: null,
},
isEditedRecord: {
isRecordEdited: {
initialValue: false,
},
recordStatus: {
Expand Down
4 changes: 2 additions & 2 deletions src/test/__tests__/common/hooks/useContainerEvents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const mockEvents = {
jest.mock('@common/constants/build.constants', () => ({ IS_EMBEDDED_MODE: true }));

describe('useContainerEvents', () => {
const renderUseContainerEventsHook = (isEditedRecord: boolean) => {
const renderUseContainerEventsHook = (isRecordEdited: boolean) => {
(domHelper.dispatchEventWrapper as jest.Mock) = mockDispatchEventWrapper;

setInitialGlobalState([
{
store: useStatusStore,
state: { isEditedRecord },
state: { isRecordEdited },
},
{
store: useConfigStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('MarcPreviewComplexLookup', () => {
setInitialGlobalState([
{
store: useMarcPreviewStore,
state: { complexValue: marcPreviewData, metaData: marcPreviewMetadata },
state: { complexValue: marcPreviewData, metadata: marcPreviewMetadata },
},
{
store: useUIStore,
Expand Down
4 changes: 2 additions & 2 deletions src/test/__tests__/components/SaveRecord.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { useStatusStore } from '@src/store';
import { setInitialGlobalState } from '@src/test/__mocks__/store';

describe('SaveRecord', () => {
function renderSaveRecordComponent(isEditedRecord = true) {
function renderSaveRecordComponent(isRecordEdited = true) {
setInitialGlobalState([
{
store: useStatusStore,
state: { isEditedRecord },
state: { isRecordEdited },
},
]);

Expand Down

0 comments on commit ea97aca

Please sign in to comment.