Skip to content

Commit 1817e32

Browse files
committed
Project create. branch name added
1 parent 6a9e745 commit 1817e32

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

src/contexts/project.context.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ async function getProjectList(dispatch: Dispatch) {
109109
});
110110
}
111111

112-
async function createProject(dispatch: Dispatch, project: { name: string }) {
112+
async function createProject(
113+
dispatch: Dispatch,
114+
project: { name: string; mainBranchName: string }
115+
) {
113116
dispatch({ type: "request" });
114117

115118
projectsService

src/pages/ProjectListPage.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const ProjectsListPage = () => {
3636

3737
const [createDialogOpen, setCreateDialogOpen] = React.useState(false);
3838
const [newProjectName, setNewProjectName] = React.useState<string>("");
39+
const [
40+
newProjectMainBranchName,
41+
setNewProjectMainBranchName,
42+
] = React.useState<string>("");
3943

4044
useEffect(() => {
4145
getProjectList(projectDispatch);
@@ -89,6 +93,17 @@ const ProjectsListPage = () => {
8993
value={newProjectName}
9094
onChange={(event) => setNewProjectName(event.target.value)}
9195
/>
96+
<TextField
97+
margin="dense"
98+
id="branchName"
99+
label="Main branch"
100+
type="text"
101+
fullWidth
102+
value={newProjectMainBranchName}
103+
onChange={(event) =>
104+
setNewProjectMainBranchName(event.target.value)
105+
}
106+
/>
92107
</DialogContent>
93108
<DialogActions>
94109
<Button onClick={handleCreateClose} color="primary">
@@ -98,8 +113,10 @@ const ProjectsListPage = () => {
98113
onClick={() => {
99114
createProject(projectDispatch, {
100115
name: newProjectName,
116+
mainBranchName: newProjectMainBranchName,
101117
}).then((project) => {
102118
setNewProjectName("");
119+
setNewProjectMainBranchName("");
103120
handleCreateClose();
104121
});
105122
}}
@@ -117,14 +134,12 @@ const ProjectsListPage = () => {
117134
<Typography>Key: {project.id}</Typography>
118135
<Typography>Name: {project.name}</Typography>
119136
<Typography>Main branch: {project.mainBranchName}</Typography>
120-
<Typography>Created: {formatDateTime(project.createdAt)}</Typography>
137+
<Typography>
138+
Created: {formatDateTime(project.createdAt)}
139+
</Typography>
121140
</CardContent>
122141
<CardActions>
123-
<Button
124-
color="primary"
125-
component={Link}
126-
to={`${project.id}`}
127-
>
142+
<Button color="primary" component={Link} to={`${project.id}`}>
128143
Builds
129144
</Button>
130145
<Button

src/services/projects.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ function remove(id: string): Promise<number> {
2828
);
2929
}
3030

31-
function create(project: { name: string }): Promise<Project> {
31+
function create(project: {
32+
name: string;
33+
mainBranchName: string;
34+
}): Promise<Project> {
3235
const requestOptions = {
3336
method: "POST",
3437
headers: { "Content-Type": "application/json", ...authHeader() },

0 commit comments

Comments
 (0)