@oaknational/oak-pupil-client
v2.12.1
Published
React Client for Oak Pupil API
Downloads
517
Keywords
Readme
Oak Pupil Client
The Pupil Client is a React TypeScript client to interface with the Oak Pupil API.
Installation
To integrate the Oak Pupil Client into your project, you will need React 18 later. Install the package using NPM or your preferred package manager:
npm i @oaknational/oak-pupil-client
Usage
Setting up the client
Wrap your app with the provider
import { OakPupilClientProvider } from "@oaknational/oak-pupil-client";
export const MyView = ({ children }: { children: React.ReactNode }) => {
return (
<OakPupilClientProvider
config={{
getLessonAttemptUrl: "https://example.com/get-lessom-attempt",
logLessonAttemptUrl: "http://example.com/log-lesson-attempt",
}}
>
{children}
</OakPupilClientProvider>
);
};
Using the Hook
For components that need to interact with the state, the useOakPupil hook can be utilised. This hook provides access to the current state, allowing users to log and retrieve lesson attempts.
import { useOakPupil } from "@oaknational/oak-pupil-client";
function MyComponent() {
const { state } = useOakPupil();
useEffect(() => {
if (requiresInteraction) {
showCookieBanner(); // you're expected to handle any UI and its associated state
}
}, [requiresInteraction]);
}
External Contributions
Security and Bug Bounty
Please see our security.txt file.
Contributing to the Code
While the Oak Pupil Client is currently not open for direct contributions, we encourage you to report any issues or suggest enhancements through the GitHub issue tracker. Your feedback is invaluable in making this tool more effective for developers.
Open Source Acknowledgements
As with all web projects we are dependent on open source libraries maintained by others. While it is not practical to acknowledge them all, we would nevertheless like to express our gratitude for the contributions and efforts of the OSS community. Our dependency list can be found in our package.json file.
License
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation. Where any Oak National Academy trademarks or logos are included, these are not released under the MIT License, and should be used in line with Oak National Academy brand guidelines.
Any documentation included is © Oak National Academy and available under the terms of the Open Government Licence v3.0, except where otherwise stated.