-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding suggest and approve endpoint for the map
- Loading branch information
Nicolas Burtey
committed
Feb 3, 2024
1 parent
f548dc8
commit c4f66a6
Showing
27 changed files
with
418 additions
and
207 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mutation merchantMapDelete($input: MerchantMapDeleteInput!) { | ||
merchantMapDelete(input: $input) { | ||
errors { | ||
message | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
mutation merchantMapValidate($input: MerchantMapValidateInput!) { | ||
merchantMapValidate(input: $input) { | ||
errors { | ||
message | ||
} | ||
merchant { | ||
id | ||
validated | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query merchantsPendingApproval { | ||
merchantsPendingApproval { | ||
id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
bats/admin-gql/business-update-map-info.gql → bats/gql/merchant-map-suggest.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
mutation businessUpdateMapInfo($input: BusinessUpdateMapInfoInput!) { | ||
businessUpdateMapInfo(input: $input) { | ||
mutation merchantMapSuggest($input: MerchantMapSuggestInput!) { | ||
merchantMapSuggest(input: $input) { | ||
errors { | ||
message | ||
} | ||
merchant { | ||
id | ||
validated | ||
title | ||
coordinates { | ||
latitude | ||
longitude | ||
} | ||
username | ||
validated | ||
createdAt | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { MerchantsRepository } from "@/services/mongoose" | ||
|
||
export const approveMerchantById = async ( | ||
id: MerchantId, | ||
): Promise<BusinessMapMarker | ApplicationError> => { | ||
const merchantsRepo = MerchantsRepository() | ||
|
||
const merchant = await merchantsRepo.findById(id) | ||
if (merchant instanceof Error) return merchant | ||
|
||
merchant.validated = true | ||
return merchantsRepo.update(merchant) | ||
} |
8 changes: 3 additions & 5 deletions
8
...app/merchants/delete-business-map-info.ts → .../src/app/merchants/delete-merchant-map.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { MerchantsRepository } from "@/services/mongoose" | ||
|
||
export * from "./update-business-map-info" | ||
export * from "./delete-business-map-info" | ||
export * from "./suggest-merchant-map" | ||
export * from "./delete-merchant-map" | ||
export * from "./approve-merchant-map" | ||
|
||
const merchants = MerchantsRepository() | ||
|
||
export const getMerchantsMapMarkers = async () => { | ||
return merchants.listForMap() | ||
} | ||
|
||
export const getMerchantsPendingApproval = async () => { | ||
return merchants.listPendingApproval() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { checkedCoordinates, checkedMapTitle, checkedToUsername } from "@/domain/accounts" | ||
import { AccountsRepository, MerchantsRepository } from "@/services/mongoose" | ||
|
||
export const suggestMerchantMap = async ({ | ||
username, | ||
coordinates: { latitude, longitude }, | ||
title, | ||
}: { | ||
username: string | ||
coordinates: { latitude: number; longitude: number } | ||
title: string | ||
}): Promise<BusinessMapMarker | ApplicationError> => { | ||
const merchantsRepo = MerchantsRepository() | ||
|
||
const usernameChecked = checkedToUsername(username) | ||
if (usernameChecked instanceof Error) return usernameChecked | ||
|
||
const coordinates = checkedCoordinates({ latitude, longitude }) | ||
if (coordinates instanceof Error) return coordinates | ||
|
||
const titleChecked = checkedMapTitle(title) | ||
if (titleChecked instanceof Error) return titleChecked | ||
|
||
const accountRepository = AccountsRepository() | ||
const account = await accountRepository.findByUsername(usernameChecked) | ||
if (account instanceof Error) { | ||
return account | ||
} | ||
|
||
return merchantsRepo.create({ | ||
username: usernameChecked, | ||
coordinates, | ||
title: titleChecked, | ||
validated: false, | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
core/api/src/graphql/admin/root/mutation/delete-business-map.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.