feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
export type GuideSelection = {
|
||||
slug: string;
|
||||
sha256: string;
|
||||
instruments: string[];
|
||||
};
|
||||
|
||||
export function guideUrl(
|
||||
base: string,
|
||||
selection: GuideSelection,
|
||||
choosingDossier = false,
|
||||
): string {
|
||||
const query = new URLSearchParams();
|
||||
if (choosingDossier) {
|
||||
query.set('investment_guide[slug]', selection.slug);
|
||||
query.set('investment_guide[sha256]', selection.sha256);
|
||||
selection.instruments.forEach((code) =>
|
||||
query.append('investment_guide[instruments][]', code),
|
||||
);
|
||||
} else {
|
||||
query.set('current', '1');
|
||||
query.set('selection', '1');
|
||||
query.set('sha256', selection.sha256);
|
||||
selection.instruments.forEach((code) =>
|
||||
query.append('instruments[]', code),
|
||||
);
|
||||
}
|
||||
return `${base}?${query}`;
|
||||
}
|
||||
|
||||
export function guideChoices(form: HTMLFormElement): string[] {
|
||||
return new FormData(form)
|
||||
.getAll('instruments[]')
|
||||
.filter((v): v is string => typeof v === 'string');
|
||||
}
|
||||
Reference in New Issue
Block a user