-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: payment failed banners and ui block
- Loading branch information
1 parent
2b8a610
commit 916698d
Showing
10 changed files
with
187 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ApiV3Instance as axios } from 'api'; | ||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; | ||
import { AxiosError } from 'axios'; | ||
import { ErrorResponse, SuccessResponse } from 'types/api'; | ||
import { LicenseV3ResponseModel } from 'types/api/licenses/getAll'; | ||
|
||
const getAllLicensesV3 = async (): Promise< | ||
SuccessResponse<LicenseV3ResponseModel> | ErrorResponse | ||
> => { | ||
try { | ||
const response = await axios.get('/licenses'); | ||
return { | ||
statusCode: 200, | ||
error: null, | ||
message: response.data.status, | ||
payload: response.data.data, | ||
}; | ||
} catch (error) { | ||
return ErrorResponseHandler(error as AxiosError); | ||
} | ||
}; | ||
|
||
export default getAllLicensesV3; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const LICENSE_STATE = { | ||
ISSUED: 'ISSUED', | ||
ACTIVE: 'ACTIVE', | ||
TRIAL_ENDED: 'TRIAL_ENDED', | ||
PAYMENT_FAILED: 'PAYMENT_FAILED', | ||
EXPIRED: 'EXPIRED', | ||
CANCELLED: 'CANCELLED', | ||
INACTIVE: 'INACTIVE', | ||
}; | ||
|
||
export const LICENSE_STATUS = { | ||
VALID: 'VALID', | ||
SUSPENDED: 'SUSPENDED', | ||
INACTIVE: 'INACTIVE', | ||
}; | ||
|
||
export const LICENSE_EVENTS = { | ||
FAILED_PAYMENT: 'FAILED_PAYMENT', | ||
END_FAILED_PAYMENT_GRACE: 'END_FAILED_PAYMENT_GRACE', | ||
}; |
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,6 @@ | ||
import { LICENSE_STATE, LICENSE_STATUS } from './constant'; | ||
import useLicense from './useLicenseV3'; | ||
|
||
export default useLicense; | ||
|
||
export { LICENSE_STATE, LICENSE_STATUS }; |
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,25 @@ | ||
import getAllLicensesV3 from 'api/licenses/getAllLicensesV3'; | ||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; | ||
import { useQuery, UseQueryResult } from 'react-query'; | ||
import { useSelector } from 'react-redux'; | ||
import { AppState } from 'store/reducers'; | ||
import { ErrorResponse, SuccessResponse } from 'types/api'; | ||
import { LicenseV3ResponseModel } from 'types/api/licenses/getAll'; | ||
import AppReducer from 'types/reducer/app'; | ||
|
||
const useLicenseV3 = (): UseLicense => { | ||
const { user } = useSelector<AppState, AppReducer>((state) => state.app); | ||
|
||
return useQuery({ | ||
queryFn: getAllLicensesV3, | ||
queryKey: [REACT_QUERY_KEY.GET_ALL_LICENCES_V3, user?.email], | ||
enabled: !!user?.email, | ||
}); | ||
}; | ||
|
||
type UseLicense = UseQueryResult< | ||
SuccessResponse<LicenseV3ResponseModel> | ErrorResponse, | ||
unknown | ||
>; | ||
|
||
export default useLicenseV3; |
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