-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from AngleProtocol/feat/opportunity-page
Feat/opportunity page
- Loading branch information
Showing
27 changed files
with
454 additions
and
173 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -173,5 +173,5 @@ export default createConfig({ | |
[zksync.id]: http(), | ||
[optimism.id]: http(), | ||
}, | ||
} | ||
}, | ||
}); |
Submodule dappkit
updated
28 files
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,17 +1,54 @@ | ||
import type { Campaign } from "@angleprotocol/merkl-api"; | ||
import { api } from "../index.server"; | ||
|
||
class CampaignService { | ||
export abstract class CampaignService { | ||
/** | ||
* Retrieves opportunities query params from page request | ||
* @param request request containing query params such as chains, status, pagination... | ||
* @param override params for which to override value | ||
* @returns query | ||
*/ | ||
static #getQueryFromRequest( | ||
request: Request, | ||
override?: Parameters<typeof api.v4.opportunities.index.get>[0]["query"], | ||
) { | ||
const status = new URL(request.url).searchParams.get("status"); | ||
const action = new URL(request.url).searchParams.get("action"); | ||
const chainId = new URL(request.url).searchParams.get("chain"); | ||
const page = new URL(request.url).searchParams.get("page"); | ||
|
||
const items = new URL(request.url).searchParams.get("items"); | ||
const search = new URL(request.url).searchParams.get("search"); | ||
const [sort, order] = new URL(request.url).searchParams.get("sort")?.split("-") ?? []; | ||
|
||
const filters = Object.assign( | ||
{ status, action, chainId, items, sort, order, name: search, page }, | ||
override ?? {}, | ||
page !== null && { page: Number(page) - 1 }, | ||
); | ||
|
||
const query = Object.entries(filters).reduce( | ||
(_query, [key, filter]) => Object.assign(_query, filter == null ? {} : { [key]: filter }), | ||
{}, | ||
); | ||
|
||
return query; | ||
} | ||
|
||
// ------ Fetch all campaigns | ||
async get(): Promise<Campaign[]> { | ||
static async get(): Promise<Campaign[]> { | ||
const { data } = await api.v4.campaigns.index.get({ query: {} }); | ||
|
||
return data; | ||
} | ||
|
||
static async getByParams(query: Parameters<typeof api.v4.campaigns.index.get>[0]["query"]): Promise<Campaign[]> { | ||
const { data } = await api.v4.campaigns.index.get({ query }); | ||
return data; | ||
} | ||
|
||
// ------ Fetch a campaign by ID | ||
async getByID(Id: string): Promise<Campaign> { | ||
return "To implements"; | ||
static async getByID(Id: string): Promise<Campaign | null> { | ||
return null; | ||
} | ||
} | ||
|
||
export const campaignService = new CampaignService(); |
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
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
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
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
Oops, something went wrong.