Skip to content

Commit

Permalink
Merge pull request #1317 from Chia-Network/readonly-fix
Browse files Browse the repository at this point in the history
fix: leftnav readonly layout and date fix
  • Loading branch information
TheLastCicada authored Aug 28, 2024
2 parents fa2be77 + 3b84822 commit 5c555ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
30 changes: 9 additions & 21 deletions src/renderer/api/cadt/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
import initialState from '@/store/slices/app/app.initialstate';

const projectsTag = 'projects';
const organizationsTag = 'organizations';
const unitsTag = 'units';
const auditTag = 'audit';
const issuancesTag = 'issuances';
const stagedProjectsTag = 'stagedProjects';
const stagedUnitsTag = 'stagedUnits';
const offerTag = 'offer';
const importedOfferTag = 'importedTransferTag';
export const projectsTag = 'projects';
export const organizationsTag = 'organizations';
export const unitsTag = 'units';
export const auditTag = 'audit';
export const issuancesTag = 'issuances';
export const stagedProjectsTag = 'stagedProjects';
export const stagedUnitsTag = 'stagedUnits';
export const offerTag = 'offer';
export const importedOfferTag = 'importedTransferTag';

const baseQuery = fetchBaseQuery({
baseUrl: '/',
Expand Down Expand Up @@ -62,15 +62,3 @@ export const cadtApi = createApi({
],
endpoints: () => ({}),
});

export {
projectsTag,
organizationsTag,
unitsTag,
auditTag,
stagedProjectsTag,
stagedUnitsTag,
issuancesTag,
offerTag,
importedOfferTag,
};
2 changes: 1 addition & 1 deletion src/renderer/api/cadt/v1/system/system.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const systemApi = cadtApi.injectEndpoints({
}),
transformResponse: (response: BaseQueryResult<Health>, meta): ServerHealth => {
const isHealthy = response?.message === 'OK';
const readOnly = meta?.response?.headers.get('cw-readonly') === 'true';
const readOnly = meta?.response?.headers.get('cw-read-only') === 'true';
return { isHealthy, readOnly };
},
}),
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/components/blocks/widgets/SyncIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BiRefresh } from 'react-icons/bi';
import { useLocation } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { FormattedMessage } from 'react-intl';
import { projectsTag, stagedProjectsTag, stagedUnitsTag, unitsTag } from '@/api/cadt/v1';

interface SyncIndicatorProps {
detailed: boolean;
Expand Down Expand Up @@ -68,11 +69,11 @@ const SyncIndicator: React.FC<SyncIndicatorProps> = ({ detailed, orgUid }) => {
setShowRefreshBadge(true);

if (location.pathname.includes('projects')) {
dispatch(invalidateProjectApiTag(['projects', 'stagedProjects']));
dispatch(invalidateProjectApiTag([projectsTag, stagedProjectsTag]));
}

if (location.pathname.includes('units')) {
dispatch(invalidateUnitsApiTag(['units', 'stagedUnits']));
dispatch(invalidateUnitsApiTag([unitsTag, stagedUnitsTag]));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/form/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormikValues, useFormikContext } from 'formik';
import { Checkbox, Datepicker, Label, Textarea, TextInput } from 'flowbite-react';
import { TagInput } from './TagInput';
import { Select, SelectOption } from '@/components';
import dayjs from 'dayjs';

interface FieldProps {
name: string;
Expand Down Expand Up @@ -71,7 +72,7 @@ const Field: React.FC<FieldProps> = ({
</a>
);
case 'date':
return <p className="dark:text-white"> dayjs(new Date(initialValue)).format('MMMM D, YYYY'); </p>;
return `${dayjs(new Date(initialValue)).format('MMMM D, YYYY')}`;
case 'tag':
return (
<TagInput defaultValue={initialValue} onChange={(tags) => setFieldValue(name, tags)} readonly={readonly} />
Expand Down

0 comments on commit 5c555ea

Please sign in to comment.