diff --git a/src/app/organization/offices/create-office/create-office.component.html b/src/app/organization/offices/create-office/create-office.component.html
new file mode 100644
index 000000000..47be8051e
--- /dev/null
+++ b/src/app/organization/offices/create-office/create-office.component.html
@@ -0,0 +1,59 @@
+
diff --git a/src/app/organization/offices/create-office/create-office.component.scss b/src/app/organization/offices/create-office/create-office.component.scss
new file mode 100644
index 000000000..1915ad6d3
--- /dev/null
+++ b/src/app/organization/offices/create-office/create-office.component.scss
@@ -0,0 +1,3 @@
+.container {
+ max-width: 37rem;
+}
diff --git a/src/app/organization/offices/create-office/create-office.component.spec.ts b/src/app/organization/offices/create-office/create-office.component.spec.ts
new file mode 100644
index 000000000..b5c5e596d
--- /dev/null
+++ b/src/app/organization/offices/create-office/create-office.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { CreateOfficeComponent } from './create-office.component';
+
+describe('CreateOfficeComponent', () => {
+ let component: CreateOfficeComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ CreateOfficeComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(CreateOfficeComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/organization/offices/create-office/create-office.component.ts b/src/app/organization/offices/create-office/create-office.component.ts
new file mode 100644
index 000000000..a28727c5c
--- /dev/null
+++ b/src/app/organization/offices/create-office/create-office.component.ts
@@ -0,0 +1,81 @@
+/** Angular Imports */
+import { Component, OnInit } from '@angular/core';
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import { Router, ActivatedRoute } from '@angular/router';
+import { DatePipe } from '@angular/common';
+
+/** Custom Services */
+import { OrganizationService } from '../../organization.service';
+
+/**
+ * Create Office component.
+ */
+@Component({
+ selector: 'mifosx-create-office',
+ templateUrl: './create-office.component.html',
+ styleUrls: ['./create-office.component.scss']
+})
+export class CreateOfficeComponent implements OnInit {
+
+ /** Office form. */
+ officeForm: FormGroup;
+ /** Office Data */
+ officeData: any;
+ /** Minimum Date allowed. */
+ minDate = new Date(2000, 0, 1);
+ /** Maximum Date allowed. */
+ maxDate = new Date();
+
+ /**
+ * Retrieves the offices data from `resolve`.
+ * @param {FormBuilder} formBuilder Form Builder.
+ * @param {OrganizationService} organizationService Organization Service.
+ * @param {ActivatedRoute} route Activated Route.
+ * @param {Router} router Router for navigation.
+ * @param {DatePipe} datePipe Date Pipe to format date.
+ */
+ constructor(private formBuilder: FormBuilder,
+ private organizationService: OrganizationService,
+ private router: Router,
+ private route: ActivatedRoute,
+ private datePipe: DatePipe) {
+ this.route.data.subscribe((data: { offices: any }) => {
+ this.officeData = data.offices;
+ });
+ }
+
+ ngOnInit() {
+ this.createofficeForm();
+ }
+
+ /**
+ * Creates the Office Form
+ */
+ createofficeForm() {
+ this.officeForm = this.formBuilder.group({
+ 'name': ['', Validators.required],
+ 'parentId': ['', Validators.required],
+ 'openingDate': ['', Validators.required],
+ 'externalId': [''],
+ });
+ }
+
+ /**
+ * Submits the office form and creates office.
+ * if successful redirects to offices
+ */
+ submit() {
+ const prevOpeningDate: Date = this.officeForm.value.openingDate;
+ // TODO: Update once language and date settings are setup
+ const dateFormat = 'yyyy-MM-dd';
+ this.officeForm.patchValue({
+ openingDate: this.datePipe.transform(prevOpeningDate, dateFormat)
+ });
+ const office = this.officeForm.value;
+ office.locale = 'en';
+ office.dateFormat = dateFormat;
+ this.organizationService.createOffice(office).subscribe(response => {
+ this.router.navigate(['../'], { relativeTo: this.route });
+ });
+ }
+}
diff --git a/src/app/organization/offices/offices.component.html b/src/app/organization/offices/offices.component.html
index cab6452c0..50e48c9c8 100644
--- a/src/app/organization/offices/offices.component.html
+++ b/src/app/organization/offices/offices.component.html
@@ -5,7 +5,7 @@
Tree View
-