|
@@ -1,18 +1,27 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
-import PropTypes from 'prop-types';
|
|
|
|
|
import { format } from 'date-fns';
|
|
import { format } from 'date-fns';
|
|
|
import { UserPicture } from '@growi/ui';
|
|
import { UserPicture } from '@growi/ui';
|
|
|
import { pagePathUtils } from '@growi/core';
|
|
import { pagePathUtils } from '@growi/core';
|
|
|
|
|
+import type { IUser } from '@growi/core';
|
|
|
|
|
+import Link from 'next/link';
|
|
|
|
|
|
|
|
-const { userPageRoot } = pagePathUtils;
|
|
|
|
|
|
|
+type AuthorInfoProps = {
|
|
|
|
|
+ date: Date,
|
|
|
|
|
+ user: IUser,
|
|
|
|
|
+ mode: 'create' | 'update',
|
|
|
|
|
+ locate: 'subnav' | 'footer',
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-const formatType = 'yyyy/MM/dd HH:mm';
|
|
|
|
|
-const AuthorInfo = (props) => {
|
|
|
|
|
|
|
+export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
|
|
|
const {
|
|
const {
|
|
|
- mode, user, date, locate,
|
|
|
|
|
|
|
+ date, user, mode = 'create', locate = 'subnav',
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
+ console.log(mode, locate)
|
|
|
|
|
+
|
|
|
|
|
+ const { userPageRoot } = pagePathUtils;
|
|
|
|
|
+ const formatType = 'yyyy/MM/dd HH:mm';
|
|
|
|
|
+
|
|
|
const infoLabelForSubNav = mode === 'create'
|
|
const infoLabelForSubNav = mode === 'create'
|
|
|
? 'Created by'
|
|
? 'Created by'
|
|
|
: 'Updated by';
|
|
: 'Updated by';
|
|
@@ -23,7 +32,11 @@ const AuthorInfo = (props) => {
|
|
|
? 'Created at'
|
|
? 'Created at'
|
|
|
: 'Last revision posted at';
|
|
: 'Last revision posted at';
|
|
|
const userLabel = user != null
|
|
const userLabel = user != null
|
|
|
- ? <a href={userPageRoot(user)}>{user.name}</a>
|
|
|
|
|
|
|
+ ? (
|
|
|
|
|
+ <Link href={userPageRoot(user)}>
|
|
|
|
|
+ <a>{user.name}</a>
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ )
|
|
|
: <i>Unknown</i>;
|
|
: <i>Unknown</i>;
|
|
|
|
|
|
|
|
if (locate === 'footer') {
|
|
if (locate === 'footer') {
|
|
@@ -61,18 +74,3 @@ const AuthorInfo = (props) => {
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
-AuthorInfo.propTypes = {
|
|
|
|
|
- date: PropTypes.instanceOf(Date),
|
|
|
|
|
- user: PropTypes.object,
|
|
|
|
|
- mode: PropTypes.oneOf(['create', 'update']),
|
|
|
|
|
- locate: PropTypes.oneOf(['subnav', 'footer']),
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-AuthorInfo.defaultProps = {
|
|
|
|
|
- mode: 'create',
|
|
|
|
|
- locate: 'subnav',
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-export default AuthorInfo;
|
|
|