-
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 #269 from wallotapp/263-change-visionary-scholarsh…
…ip-module-into-an-api-feature Change visionary scholarship module into an API feature
- Loading branch information
Showing
33 changed files
with
389 additions
and
9 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...dVisionaryScholarshipConfirmationEmail.ts → ...dVisionaryScholarshipConfirmationEmail.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
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 @@ | ||
export * from './models/index.js'; |
1 change: 1 addition & 0 deletions
1
packages/javascript-sdk/scholarshipApplications/models/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './scholarshipApplicationProperties.js'; |
48 changes: 48 additions & 0 deletions
48
packages/javascript-sdk/scholarshipApplications/models/scholarshipApplicationProperties.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as yup from 'yup'; | ||
import { | ||
GeneralizedApiResourceCreateParamsRequiredFieldEnum, | ||
GeneralizedApiResourceProperties, | ||
CreateParams, | ||
UpdateParams, | ||
YupHelpers, | ||
getApiResourceSpec, | ||
getEnum, | ||
} from 'ergonomic'; | ||
import { | ||
apiYupHelpers, | ||
idPrefixByResourceName, | ||
} from '../../utils/apiYupHelpers.js'; | ||
|
||
export const ScholarshipApplicationCategoryEnum = getEnum(['default']); | ||
export type ScholarshipApplicationCategory = | ||
keyof typeof ScholarshipApplicationCategoryEnum.obj; | ||
|
||
const createParamsRequiredFieldEnum = getEnum([ | ||
...GeneralizedApiResourceCreateParamsRequiredFieldEnum.arr, | ||
] as const); | ||
type T = keyof typeof createParamsRequiredFieldEnum.obj; | ||
|
||
const _object = 'scholarship_application'; | ||
const properties = { | ||
...GeneralizedApiResourceProperties, | ||
_id: apiYupHelpers.id(_object), | ||
_object: YupHelpers.constant(_object), | ||
category: ScholarshipApplicationCategoryEnum.getDefinedSchema(), | ||
// Add more properties here | ||
} as const; | ||
type U = typeof properties; | ||
|
||
export const scholarshipApplicationsApi = getApiResourceSpec<keyof U, U, T>({ | ||
createParamsRequiredFieldEnum, | ||
idPrefix: idPrefixByResourceName[_object], | ||
properties, | ||
} as const); | ||
export type ScholarshipApplication = yup.InferType< | ||
typeof scholarshipApplicationsApi.apiResourceJsonSchema | ||
>; | ||
export type CreateScholarshipApplicationParams = CreateParams< | ||
ScholarshipApplication, | ||
T | ||
>; | ||
export type UpdateScholarshipApplicationParams = | ||
UpdateParams<ScholarshipApplication>; |
29 changes: 29 additions & 0 deletions
29
packages/javascript-sdk/scholarshipApplications/test/exampleScholarshipApplication.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
ScholarshipApplication, | ||
scholarshipApplicationsApi, | ||
} from '../models/index.js'; | ||
|
||
describe('ScholarshipApplication', () => { | ||
test('exampleScholarshipApplication', () => { | ||
const { apiResourceDefaultJson } = scholarshipApplicationsApi; | ||
const exampleScholarshipApplication: ScholarshipApplication = { | ||
...apiResourceDefaultJson, | ||
category: 'default', | ||
name: 'My ScholarshipApplication', | ||
}; | ||
expect(exampleScholarshipApplication).toEqual< | ||
typeof exampleScholarshipApplication | ||
>({ | ||
_id: expect.any(String), | ||
_date_last_modified: expect.any(String), | ||
_created_by: expect.any(String), | ||
_object: 'scholarship_application', | ||
category: 'default', | ||
_archived: false, | ||
_date_created: expect.any(String), | ||
_deleted: false, | ||
description: '', | ||
name: 'My ScholarshipApplication', | ||
}); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/javascript-sdk/utils/visionaryScholarships/visionaryScholarshipApplicationSchema.ts
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/react-sdk/src/features/scholarshipApplications/README.md
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,22 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [ScholarshipApplications feature](#scholarshipapplications-feature) | ||
- [Definition](#definition) | ||
- [Example ScholarshipApplication Resource](#example-scholarshipapplication-resource) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# ScholarshipApplications feature | ||
|
||
<-- Add a brief description of what a ScholarshipApplication is here --> | ||
|
||
## Definition | ||
|
||
<-- Add a detailed description of a ScholarshipApplication here --> | ||
|
||
## Example ScholarshipApplication Resource | ||
|
||
```json | ||
<-- Add an example ScholarshipApplication resource here --> | ||
``` |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/api/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/api` Directory](#featuresscholarshipapplicationsapi-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/api` Directory | ||
|
||
The api folder should contain exported API request declarations and api hooks related to the ScholarshipApplications feature. |
13 changes: 13 additions & 0 deletions
13
packages/react-sdk/src/features/scholarshipApplications/api/createScholarshipApplication.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { generalizedFirestoreDocumentCreateOperation } from 'ergonomic-react/src/features/data'; | ||
import { | ||
CreateScholarshipApplicationParams, | ||
ScholarshipApplication, | ||
scholarshipApplicationsApi, | ||
} from '@wallot/js'; | ||
import { GeneralizedApiResourceSpec } from 'ergonomic'; | ||
|
||
export const createScholarshipApplication = | ||
generalizedFirestoreDocumentCreateOperation< | ||
CreateScholarshipApplicationParams, | ||
ScholarshipApplication | ||
>(scholarshipApplicationsApi as unknown as GeneralizedApiResourceSpec); |
8 changes: 8 additions & 0 deletions
8
...ges/react-sdk/src/features/scholarshipApplications/api/queryScholarshipApplicationPage.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { GeneralizedApiResourceSpec } from 'ergonomic'; | ||
import { generalizedFirestoreCollectionPageQuery } from 'ergonomic-react/src/features/data'; | ||
import { ScholarshipApplication, scholarshipApplicationsApi } from '@wallot/js'; | ||
|
||
export const queryScholarshipApplicationPage = | ||
generalizedFirestoreCollectionPageQuery<ScholarshipApplication>( | ||
scholarshipApplicationsApi as unknown as GeneralizedApiResourceSpec, | ||
); |
11 changes: 11 additions & 0 deletions
11
packages/react-sdk/src/features/scholarshipApplications/api/updateScholarshipApplication.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { generalizedFirestoreDocumentUpdateOperation } from 'ergonomic-react/src/features/data'; | ||
import { | ||
UpdateScholarshipApplicationParams, | ||
scholarshipApplicationsApi, | ||
} from '@wallot/js'; | ||
import { GeneralizedApiResourceSpec } from 'ergonomic'; | ||
|
||
export const updateScholarshipApplication = | ||
generalizedFirestoreDocumentUpdateOperation<UpdateScholarshipApplicationParams>( | ||
scholarshipApplicationsApi as unknown as GeneralizedApiResourceSpec, | ||
); |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/assets/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/assets` Directory](#featuresscholarshipapplicationsassets-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/assets` Directory | ||
|
||
The assets folder should contain all the static files related to the ScholarshipApplications feature. |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/components/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/components` Directory](#featuresscholarshipapplicationscomponents-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/components` Directory | ||
|
||
The components folder should contain all the components specific to the ScholarshipApplications feature. |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/hooks/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/hooks` Directory](#featuresscholarshipapplicationshooks-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/hooks` Directory | ||
|
||
The hooks folder should contain all the React hooks specific to the ScholarshipApplications feature. |
30 changes: 30 additions & 0 deletions
30
...dk/src/features/scholarshipApplications/hooks/useCreateScholarshipApplicationMutation.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,30 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { createScholarshipApplication } from '@wallot/react/src/features/scholarshipApplications/api/createScholarshipApplication'; | ||
import { | ||
CreateScholarshipApplicationMutationData, | ||
CreateScholarshipApplicationMutationError, | ||
CreateScholarshipApplicationMutationParams, | ||
UseCreateScholarshipApplicationMutationOptions, | ||
} from '@wallot/react/src/features/scholarshipApplications/types/ScholarshipApplicationReactTypes'; | ||
|
||
export function useCreateScholarshipApplicationMutation( | ||
options?: UseCreateScholarshipApplicationMutationOptions, | ||
) { | ||
return useMutation< | ||
CreateScholarshipApplicationMutationData, | ||
CreateScholarshipApplicationMutationError, | ||
CreateScholarshipApplicationMutationParams | ||
>( | ||
(params: CreateScholarshipApplicationMutationParams) => | ||
createScholarshipApplication(params), | ||
{ | ||
onError: (error: CreateScholarshipApplicationMutationError) => { | ||
console.error('Create operation failed:', error); | ||
}, | ||
onSuccess: (data: CreateScholarshipApplicationMutationData) => { | ||
console.log('Create operation successful', data); | ||
}, | ||
...options, | ||
}, | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
...act-sdk/src/features/scholarshipApplications/hooks/useQueryScholarshipApplicationPage.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,36 @@ | ||
import * as R from 'ramda'; | ||
import * as ReactQuery from '@tanstack/react-query'; | ||
import { queryScholarshipApplicationPage } from '@wallot/react/src/features/scholarshipApplications/api/queryScholarshipApplicationPage'; | ||
import { | ||
UseQueryScholarshipApplicationPageQueryKeyFn, | ||
UseQueryScholarshipApplicationPageOptionsFn, | ||
UseQueryScholarshipApplicationPageProps, | ||
} from '@wallot/react/src/features/scholarshipApplications/types/ScholarshipApplicationReactTypes'; | ||
|
||
export const getQueryScholarshipApplicationPageReactQueryKey: UseQueryScholarshipApplicationPageQueryKeyFn = | ||
(params) => | ||
[ | ||
'scholarship_application', | ||
JSON.stringify(R.omit(['startAfterDocumentReference'], params)), | ||
] as const; | ||
|
||
export const getQueryScholarshipApplicationPageReactQueryOptions: UseQueryScholarshipApplicationPageOptionsFn = | ||
(props) => ({ | ||
queryFn: () => queryScholarshipApplicationPage(props.firestoreQueryOptions), | ||
queryKey: getQueryScholarshipApplicationPageReactQueryKey( | ||
props.firestoreQueryOptions, | ||
), | ||
...(props.reactQueryOptions ?? {}), | ||
}); | ||
|
||
export function useQueryScholarshipApplicationPage({ | ||
firestoreQueryOptions, | ||
reactQueryOptions = {}, | ||
}: UseQueryScholarshipApplicationPageProps) { | ||
return ReactQuery.useQuery( | ||
getQueryScholarshipApplicationPageReactQueryOptions({ | ||
firestoreQueryOptions, | ||
reactQueryOptions, | ||
}), | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
...dk/src/features/scholarshipApplications/hooks/useUpdateScholarshipApplicationMutation.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,30 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { updateScholarshipApplication } from '@wallot/react/src/features/scholarshipApplications/api/updateScholarshipApplication'; | ||
import { | ||
UpdateScholarshipApplicationMutationData, | ||
UpdateScholarshipApplicationMutationError, | ||
UpdateScholarshipApplicationMutationParams, | ||
UseUpdateScholarshipApplicationMutationOptions, | ||
} from '@wallot/react/src/features/scholarshipApplications/types/ScholarshipApplicationReactTypes'; | ||
|
||
export function useUpdateScholarshipApplicationMutation( | ||
options?: UseUpdateScholarshipApplicationMutationOptions, | ||
) { | ||
return useMutation< | ||
UpdateScholarshipApplicationMutationData, | ||
UpdateScholarshipApplicationMutationError, | ||
UpdateScholarshipApplicationMutationParams | ||
>( | ||
(params: UpdateScholarshipApplicationMutationParams) => | ||
updateScholarshipApplication(params), | ||
{ | ||
onError: (error: UpdateScholarshipApplicationMutationError) => { | ||
console.error('Update operation failed:', error); | ||
}, | ||
onSuccess: (data: UpdateScholarshipApplicationMutationData) => { | ||
console.log('Update operation successful', data); | ||
}, | ||
...options, | ||
}, | ||
); | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/react-sdk/src/features/scholarshipApplications/index.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,4 @@ | ||
export * from '@wallot/react/src/features/scholarshipApplications/hooks/useCreateScholarshipApplicationMutation'; | ||
export * from '@wallot/react/src/features/scholarshipApplications/hooks/useQueryScholarshipApplicationPage'; | ||
export * from '@wallot/react/src/features/scholarshipApplications/hooks/useUpdateScholarshipApplicationMutation'; | ||
export * from '@wallot/react/src/features/scholarshipApplications/types/ScholarshipApplicationReactTypes'; |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/routes/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/routes` Directory](#featuresscholarshipapplicationsroutes-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/routes` Directory | ||
|
||
The routes folder should contain all the route components for the ScholarshipApplications feature pages. |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/stores/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/stores` Directory](#featuresscholarshipapplicationsstores-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/stores` Directory | ||
|
||
The stores folder should contain all the state stores for the ScholarshipApplications feature. |
10 changes: 10 additions & 0 deletions
10
packages/react-sdk/src/features/scholarshipApplications/types/README.md
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,10 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [`features/scholarshipApplications/types` Directory](#featuresscholarshipapplicationstypes-directory) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# `features/scholarshipApplications/types` Directory | ||
|
||
The types folder should contain all the TypeScript types for the ScholarshipApplications feature domain. |
Oops, something went wrong.