Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/allow user select multiple addresses #639

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class FakeDataCarriers {
return {
carrier: {
isDeleted: false,
firstName,
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
status: faker.random.number({
min: 0,
Expand Down Expand Up @@ -56,7 +56,8 @@ export default class FakeDataCarriers {
this.getCloseCoordinate(lng),
this.getCloseCoordinate(lat)
]
}
},
default: false
}
},
password: '123456'
Expand Down Expand Up @@ -93,7 +94,8 @@ export default class FakeDataCarriers {
this.getCloseCoordinate(lng),
this.getCloseCoordinate(lat)
]
}
},
default: false
}
},
password: '123456'
Expand Down Expand Up @@ -129,7 +131,8 @@ export default class FakeDataCarriers {
this.getCloseCoordinate(lng),
this.getCloseCoordinate(lat)
]
}
},
default: false
}
},
password: '123456'
Expand Down Expand Up @@ -164,7 +167,8 @@ export default class FakeDataCarriers {
this.getCloseCoordinate(lng),
this.getCloseCoordinate(lat)
]
}
},
default: false
}
},
password: '123456'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default class FakeDataInvites {
loc: {
type: 'Point',
coordinates: [lng + 0.05, lat - 0.01]
}
},
default: false
},
apartment: '3'
};
Expand All @@ -38,7 +39,8 @@ export default class FakeDataInvites {
loc: {
type: 'Point',
coordinates: [lng + 0.09, lat - 0.1]
}
},
default: false
},
apartment: '2'
};
Expand All @@ -53,7 +55,8 @@ export default class FakeDataInvites {
loc: {
type: 'Point',
coordinates: [lng, lat - 0.01]
}
},
default: false
},
apartment: '6'
};
Expand All @@ -68,7 +71,8 @@ export default class FakeDataInvites {
loc: {
type: 'Point',
coordinates: [lng + 0.06, lat]
}
},
default: false
},
apartment: '6'
};
Expand All @@ -92,7 +96,8 @@ export default class FakeDataInvites {
loc: {
type: 'Point',
coordinates: [lng, lat]
}
},
default: false
},
apartment: faker.random.number(199).toString()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export class AdminStorageService extends StorageService {
loc: {
type: 'Point',
coordinates: [lng, lat]
}
},
default: false
})
: null;
}
29 changes: 16 additions & 13 deletions admin/website-angular/src/app/@core/data/fakeDataServices/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ export default class FakeDataUsers {
phone: faker.phone.phoneNumber(),
image: faker.image.avatar(),
apartment: faker.random.number(199).toString(),
geoLocation: {
countryId: faker.random.number(200) as Country,
city: faker.address.city(),
postcode: faker.address.zipCode(),
streetAddress: faker.address.streetAddress(),
house: faker.random.number(199).toString(),
loc: {
type: 'Point',
coordinates: [
environment.DEFAULT_LONGITUDE,
environment.DEFAULT_LATITUDE
]
geoLocation: [
{
countryId: faker.random.number(200) as Country,
city: faker.address.city(),
postcode: faker.address.zipCode(),
streetAddress: faker.address.streetAddress(),
house: faker.random.number(199).toString(),
loc: {
type: 'Point',
coordinates: [
environment.DEFAULT_LONGITUDE,
environment.DEFAULT_LATITUDE
]
},
default: true
}
},
],
isBanned: Math.random() < 0.01
},
password: '123456'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng, lat]
}
},
default: false
},
_createdAt: this._getRandomDateRange()
},
Expand Down Expand Up @@ -90,7 +91,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng + 0.05, lat + 0.09]
}
},
default: false
},
_createdAt: this._getRandomDateRange()
},
Expand Down Expand Up @@ -124,7 +126,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng - 0.05, lat - 0.09]
}
},
default: false
},
_createdAt: this._getRandomDateRange()
},
Expand Down Expand Up @@ -158,7 +161,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng + 0.08, lat + 0.07]
}
},
default: false
},
_createdAt: this._getRandomDateRange()
} as any,
Expand Down Expand Up @@ -192,7 +196,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng - 0.08, lat - 0.07]
}
},
default: false
},
_createdAt: this._getRandomDateRange()
} as any,
Expand All @@ -212,7 +217,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng, lat]
}
},
default: false
};
} else {
console.warn(NEED_DEFAULT_SETTINGS_MESSAGE);
Expand All @@ -231,7 +237,8 @@ export default class FakeDataWarehouses {
loc: {
type: 'Point',
coordinates: [lng + 0.05, lat - 0.08]
}
},
default: false
};
} else {
console.warn(NEED_DEFAULT_SETTINGS_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ export class InvitesRequestsService {
loc: {
coordinates: [Number(lng), Number(lat)],
type: 'Point'
}
},
default: false
};

const inviteRequest: IInviteRequestCreateObject = {
Expand Down
3 changes: 2 additions & 1 deletion admin/website-angular/src/app/@core/data/invites.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export class InvitesService {
loc: {
coordinates: [Number(lng), Number(lat)],
type: 'Point'
}
},
default: false
};

const invite: IInviteCreateObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export class ByCodeModalComponent {
const user = await this.userAuthRouter.register({
user: {
apartment: invite.apartment,
geoLocation: invite.geoLocation
geoLocation: [invite.geoLocation]
}
});
this.toasterService.pop(
'success',
`Successful logen with code`
`Successful login with code`
);
this.activeModal.close(user);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class CarrierLocationComponent implements OnInit, OnDestroy {

ngOnInit(): void {
this.loadMap();

this.loadRoot();
}

Expand All @@ -50,9 +49,12 @@ export class CarrierLocationComponent implements OnInit, OnDestroy {
const [carrierLng, carrierLat] = this.order.carrier[
'geoLocation'
].loc.coordinates;
const [userLng, userLat] = this.order.user[
'geoLocation'
].loc.coordinates;
// for a user, we need to load default address
const [
userLng,
userLat
] = this.order.user.getDefaultGeolocation().loc.coordinates;

const origin = new google.maps.LatLng(carrierLat, carrierLng);
const destination = new google.maps.LatLng(userLat, userLng);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class UserWarehouseLocationComponent
const warehouse = this.order.warehouse;

this.userMarker = this.addMarker(
user['geoLocation'],
user.getDefaultGeolocation(),
this.map,
userIcon
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class UserMutationComponent {
const user = await this.userAuthRouter.register({
user: {
...this.basicInfoForm.getValue(),
geoLocation: location,
geoLocation: [location],
apartment: this.locationForm.getApartment()
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ export class CustomerEditComponent implements OnInit {
this._currentCustomer = customer;

// GeoJSON use reversed order of lat => lng
const geoLocationInput = customer.geoLocation;
const geoLocationInput = customer.getDefaultGeolocation();
geoLocationInput.loc.coordinates.reverse();

this.basicInfoForm.setValue(customer);
this.locationForm.setValue(geoLocationInput);
this._emitMapCoordinates([
customer.geoLocation.coordinates.lat,
customer.geoLocation.coordinates.lng
customer.getDefaultGeolocation().coordinates.lat,
customer.getDefaultGeolocation().coordinates.lng
]);
});
}
Expand All @@ -99,13 +99,15 @@ export class CustomerEditComponent implements OnInit {
protected async updateCustomer() {
const geoLocationInput = this.locationForm.getValue();
geoLocationInput.loc.coordinates.reverse();
this._currentCustomer.setDefaultLocation(geoLocationInput);
const allCustomerAddresses = this._currentCustomer.customerAddress;
try {
this.loading = true;
const customer = await this._customerRouter.updateUser(
this._currentCustomer.id,
{
...this.basicInfoForm.getValue(),
geoLocation: geoLocationInput as IGeoLocation
geoLocation: allCustomerAddresses
}
);
this.loading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class CustomerLocationComponent implements OnDestroy, OnInit {
.pipe(first())
.toPromise();
const coordinates = new google.maps.LatLng(
user['geoLocation'].coordinates.lat,
user['geoLocation'].coordinates.lng
user.getDefaultGeolocation().coordinates.lat,
user.getDefaultGeolocation().coordinates.lng
);
this.showMap(coordinates);
this.marker = this.addMarker(coordinates, this.map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class CustomerProductsComponent implements OnDestroy, OnInit {
}

this.availableProductsSubscription$ = this.geoLocationProductService
.getGeoLocationProducts(user.geoLocation)
.getGeoLocationProducts(user.getDefaultGeolocation())
.subscribe((products) => {
this.availableProducts = products;
this.sourceSmartTable.load(products);
Expand Down
4 changes: 3 additions & 1 deletion backend/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ export class ApplicationModule implements NestModule, OnModuleInit {
server.applyMiddleware({app, path: graphqlPath});

*/

log.info(
`GraphQL playground available at http://localhost:${port}/graphql`
);
console.log(
`GraphQL playground available at http://localhost:${port}/graphql`
);
}

/*
Expand Down
3 changes: 2 additions & 1 deletion backend/api/src/services/invites/InvitesRequestsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ export class InvitesRequestsService extends DBService<InviteRequest>
type: 'Point',
coordinates: [defaultLng, defaultLat]
},
streetAddress: faker.address.streetAddress()
streetAddress: faker.address.streetAddress(),
default: true
};
return GeoLocation;
}
Expand Down
Loading