chore: threads global updatedAt through to edit view
This commit is contained in:
@@ -34,7 +34,7 @@ const DefaultGlobalView: React.FC<Props> = (props) => {
|
||||
const { t, i18n } = useTranslation('general');
|
||||
|
||||
const {
|
||||
global, data, onSave, permissions, action, apiURL, initialState, isLoading,
|
||||
global, data, onSave, permissions, action, apiURL, initialState, isLoading, updatedAt,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
@@ -170,10 +170,10 @@ const DefaultGlobalView: React.FC<Props> = (props) => {
|
||||
</a>
|
||||
</li>
|
||||
)}
|
||||
{data.updatedAt && (
|
||||
{updatedAt && (
|
||||
<li>
|
||||
<div className={`${baseClass}__label`}>{t('lastModified')}</div>
|
||||
<div>{format(new Date(data.updatedAt as string), dateFormat)}</div>
|
||||
<div>{format(new Date(updatedAt as string), dateFormat)}</div>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
@@ -22,6 +22,7 @@ const GlobalView: React.FC<IndexProps> = (props) => {
|
||||
const { setStepNav } = useStepNav();
|
||||
const { user } = useAuth();
|
||||
const [initialState, setInitialState] = useState<Fields>();
|
||||
const [updatedAt, setUpdatedAt] = useState<string>();
|
||||
const { getVersions, preferencesKey, docPermissions, getDocPermissions } = useDocumentInfo();
|
||||
const { getPreference } = usePreferences();
|
||||
const { t } = useTranslation();
|
||||
@@ -51,6 +52,7 @@ const GlobalView: React.FC<IndexProps> = (props) => {
|
||||
const onSave = useCallback(async (json) => {
|
||||
getVersions();
|
||||
getDocPermissions();
|
||||
setUpdatedAt(json?.result?.updatedAt);
|
||||
const state = await buildStateFromSchema({ fieldSchema: fields, data: json.result, operation: 'update', user, locale, t });
|
||||
setInitialState(state);
|
||||
}, [getVersions, fields, user, locale, t, getDocPermissions]);
|
||||
@@ -93,6 +95,7 @@ const GlobalView: React.FC<IndexProps> = (props) => {
|
||||
onSave,
|
||||
apiURL: `${serverURL}${api}/globals/${slug}${global.versions?.drafts ? '?draft=true' : ''}`,
|
||||
action: `${serverURL}${api}/globals/${slug}?locale=${locale}&depth=0&fallback-locale=null`,
|
||||
updatedAt: updatedAt || dataToRender?.updatedAt,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -17,4 +17,5 @@ export type Props = {
|
||||
initialState: Fields
|
||||
isLoading: boolean
|
||||
autosaveEnabled: boolean
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ const EditView: React.FC<IndexProps> = (props) => {
|
||||
hasSavePermission,
|
||||
apiURL,
|
||||
action,
|
||||
updatedAt,
|
||||
updatedAt: updatedAt || dataToRender?.updatedAt,
|
||||
}}
|
||||
/>
|
||||
</EditDepthContext.Provider>
|
||||
|
||||
Reference in New Issue
Block a user