-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dm): adding nuveri and axs changes
- Loading branch information
Showing
43 changed files
with
494 additions
and
116 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
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
50 changes: 50 additions & 0 deletions
50
...s/mutations/useCreateBusinessReportBatchMutation/useCreateBusinessReportBatchMutation.tsx
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,50 @@ | ||
import { t } from 'i18next'; | ||
import { toast } from 'sonner'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { HttpError } from '@/common/errors/http-error'; | ||
import { TBusinessReportType } from '@/domains/business-reports/types'; | ||
import { createBusinessReportBatch } from '@/domains/business-reports/fetchers'; | ||
import { useCustomerQuery } from '@/domains/customer/hook/queries/useCustomerQuery/useCustomerQuery'; | ||
import { isObject } from '@ballerine/common'; | ||
|
||
export const useCreateBusinessReportBatchMutation = ({ | ||
reportType, | ||
onSuccess, | ||
}: { | ||
reportType: TBusinessReportType; | ||
onSuccess?: <TData>(data: TData) => void; | ||
}) => { | ||
const queryClient = useQueryClient(); | ||
|
||
const { data: customer } = useCustomerQuery(); | ||
|
||
return useMutation({ | ||
mutationFn: (merchantSheet: File) => | ||
createBusinessReportBatch({ | ||
reportType, | ||
merchantSheet, | ||
isExample: customer?.config?.isExample ?? false, | ||
}), | ||
onSuccess: data => { | ||
void queryClient.invalidateQueries(); | ||
|
||
toast.success(t(`toast:batch_business_report_creation.success`)); | ||
|
||
onSuccess?.(data); | ||
}, | ||
onError: (error: unknown) => { | ||
if (error instanceof HttpError && error.code === 400) { | ||
toast.error(error.message); | ||
|
||
return; | ||
} | ||
|
||
toast.error( | ||
t(`toast:batch_business_report_creation.error`, { | ||
errorMessage: isObject(error) && 'message' in error ? error.message : error, | ||
}), | ||
); | ||
}, | ||
}); | ||
}; |
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
78 changes: 78 additions & 0 deletions
78
...e-v2/src/pages/MerchantMonitoringUploadMultiple/MerchantMonitoringUploadMultiple.page.tsx
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,78 @@ | ||
import { Input } from '@ballerine/ui'; | ||
import { Link } from 'react-router-dom'; | ||
import { ChevronLeft, Download } from 'lucide-react'; | ||
import React, { FunctionComponent } from 'react'; | ||
|
||
import { Card } from '@/common/components/atoms/Card/Card'; | ||
import { Form } from '@/common/components/organisms/Form/Form'; | ||
import { FormItem } from '@/common/components/organisms/Form/Form.Item'; | ||
import { FormField } from '@/common/components/organisms/Form/Form.Field'; | ||
import { FormLabel } from '@/common/components/organisms/Form/Form.Label'; | ||
import { CardContent } from '@/common/components/atoms/Card/Card.Content'; | ||
import { FormControl } from '@/common/components/organisms/Form/Form.Control'; | ||
import { Button, buttonVariants } from '@/common/components/atoms/Button/Button'; | ||
import { FormDescription } from '@/common/components/organisms/Form/Form.Description'; | ||
import { useMerchantMonitoringUploadMultiplePageLogic } from '@/pages/MerchantMonitoringUploadMultiple/hooks/useMerchantMonitoringUploadMultiplePageLogic/useMerchantMonitoringUploadMultiplePageLogic'; | ||
|
||
export const MerchantMonitoringUploadMultiplePage: FunctionComponent = () => { | ||
const { form, onSubmit, onChange, locale, csvTemplateUrl } = | ||
useMerchantMonitoringUploadMultiplePageLogic(); | ||
|
||
return ( | ||
<section className="flex h-full flex-col px-6 pb-6 pt-10"> | ||
<div> | ||
<Link | ||
to={`/${locale}/merchant-monitoring`} | ||
className={buttonVariants({ | ||
variant: 'ghost', | ||
className: 'mb-6 flex items-center space-x-[1px] pe-3 ps-1 font-semibold', | ||
})} | ||
> | ||
<ChevronLeft size={18} /> <span>Back to Reports</span> | ||
</Link> | ||
</div> | ||
<h1 className="pb-5 text-2xl font-bold">Upload Multiple Merchants</h1> | ||
<Card> | ||
<CardContent className={`px-10 pt-8`}> | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="merchantSheet" | ||
render={() => ( | ||
<FormItem className={`max-w-[250px]`}> | ||
<FormLabel>Upload Merchants Sheet</FormLabel> | ||
<FormControl> | ||
<Input | ||
type="file" | ||
accept=".csv" | ||
onChange={onChange} | ||
id={`merchantSheet`} | ||
name={`merchantSheet`} | ||
className="flex items-center" | ||
/> | ||
</FormControl> | ||
<FormDescription>File should follow the CSV template</FormDescription> | ||
</FormItem> | ||
)} | ||
/> | ||
<div className={`flex space-x-[54px]`}> | ||
<Button type="submit" size={`wide`}> | ||
Start Analyzing | ||
</Button> | ||
<a | ||
href={csvTemplateUrl} | ||
download="batch-report-template.csv" | ||
className={'flex items-center space-x-2 text-[#007AFF] hover:underline'} | ||
> | ||
<Download className={`d-6`} /> | ||
<span className={`text-sm font-medium leading-5`}>Download CSV template</span> | ||
</a> | ||
</div> | ||
</form> | ||
</Form> | ||
</CardContent> | ||
</Card> | ||
</section> | ||
); | ||
}; |
Oops, something went wrong.