Skip to content

Commit 24292d8

Browse files
committed
chore: reuse interfaces among different files
1 parent 0412a94 commit 24292d8

File tree

8 files changed

+594
-593
lines changed

8 files changed

+594
-593
lines changed

src/constants/languageColors.ts

Lines changed: 561 additions & 0 deletions
Large diffs are not rendered by default.

src/types/models.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export interface UserData {
2+
id: string;
3+
name: string;
4+
username: string;
5+
email?: string;
6+
displayName?: string;
7+
title?: string;
8+
gitAccount?: string;
9+
admin?: boolean;
10+
}
11+
12+
export interface Commit {
13+
commitTs?: number;
14+
message: string;
15+
committer: string;
16+
tree?: string;
17+
parent?: string;
18+
author: string;
19+
authorEmail: string;
20+
commitTimestamp?: number;
21+
}

src/ui/components/Navbars/DashboardNavbarLinks.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ import { AccountCircle } from '@material-ui/icons';
1616
import { getUser } from '../../services/user';
1717
import axios from 'axios';
1818
import { getCookie } from '../../utils';
19+
import { UserData } from '../../../types/models';
1920

2021
const useStyles = makeStyles(styles);
21-
interface UserData {
22-
id: string;
23-
name: string;
24-
email: string;
25-
}
2622

27-
export default function DashboardNavbarLinks() {
23+
const DashboardNavbarLinks: React.FC = () => {
2824
const classes = useStyles();
2925
const navigate = useNavigate();
3026
const [openProfile, setOpenProfile] = useState<HTMLElement | null>(null);
@@ -127,4 +123,4 @@ export default function DashboardNavbarLinks() {
127123
</div>
128124
</div>
129125
);
130-
}
126+
};

src/ui/services/user.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import axios, { AxiosError, AxiosResponse } from 'axios';
22
import { getCookie } from '../utils';
3-
4-
export interface UserData {
5-
username: string;
6-
email?: string;
7-
displayName?: string;
8-
title?: string;
9-
gitAccount?: string;
10-
admin?: boolean;
11-
}
3+
import { UserData } from '../../types/models';
124

135
type SetStateCallback<T> = (value: T | ((prevValue: T) => T)) => void;
146

src/ui/views/PushDetails/PushDetails.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,7 @@ import { getPush, authorisePush, rejectPush, cancelPush } from '../../services/g
2222
import { CheckCircle, Visibility, Cancel, Block } from '@material-ui/icons';
2323
import Snackbar from '@material-ui/core/Snackbar';
2424
import Tooltip from '@material-ui/core/Tooltip';
25-
26-
interface CommitData {
27-
commitTs?: number;
28-
commitTimestamp?: number;
29-
committer: string;
30-
author: string;
31-
authorEmail?: string;
32-
message: string;
33-
}
25+
import { CommitData } from '../../../types/models';
3426

3527
interface Reviewer {
3628
username: string;

src/ui/views/RepoDetails/Components/AddUser.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ import Snackbar from '@material-ui/core/Snackbar';
1616
import { addUser } from '../../../services/repo';
1717
import { getUsers } from '../../../services/user';
1818
import { PersonAdd } from '@material-ui/icons';
19-
20-
interface User {
21-
username: string;
22-
gitAccount: string;
23-
}
19+
import { UserData } from '../../../../types/models';
2420

2521
interface AddUserDialogProps {
2622
repoName: string;
@@ -38,7 +34,7 @@ const AddUserDialog: React.FC<AddUserDialogProps> = ({
3834
onClose,
3935
}) => {
4036
const [username, setUsername] = useState<string>('');
41-
const [data, setData] = useState<User[]>([]);
37+
const [data, setData] = useState<UserData[]>([]);
4238
const [, setAuth] = useState<boolean>(true);
4339
const [isLoading, setIsLoading] = useState<boolean>(false);
4440
const [isError, setIsError] = useState<boolean>(false);

0 commit comments

Comments
 (0)