mirror of
https://github.com/unraid/api.git
synced 2026-01-04 23:50:37 -06:00
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added comprehensive activation code customization service with dynamic theming, partner branding, and UI updates. - Introduced new GraphQL types and public queries for activation code, partner info, and theme data. - Implemented new web UI stores and components for activation modal, partner logos, and theme management. - **Improvements** - Removed legacy activation code scripts, PHP components, and plugin references, streamlining activation logic. - Enhanced configuration and environment support for activation and theming features. - Improved error handling, validation, and type safety in activation and customization modules. - **Bug Fixes** - Fixed color code validation and path handling in customization service. - **Chores** - Added pre-commit linting hooks and related configuration. - Cleaned up test and development environment files. - **Tests** - Added extensive tests covering activation customization service initialization, data handling, and file modifications. - Removed obsolete tests related to legacy activation code store. - **Refactor** - Migrated activation and partner branding logic from legacy scripts and PHP to TypeScript services and GraphQL resolvers. - Reorganized store and component architecture for activation-related features. - **Style** - Updated UI components for improved branding, theming, accessibility, and layout consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Zack Spear <hi@zackspear.com>
114 lines
2.7 KiB
TypeScript
114 lines
2.7 KiB
TypeScript
import { computed } from 'vue';
|
|
import { createPinia, defineStore, setActivePinia, storeToRefs } from 'pinia';
|
|
|
|
import { PURCHASE_CALLBACK } from '~/helpers/urls';
|
|
|
|
import { useActivationCodeDataStore } from '~/components/Activation/store/activationCodeData';
|
|
import { useCallbackActionsStore } from '~/store/callbackActions';
|
|
import { useServerStore } from '~/store/server';
|
|
|
|
/**
|
|
* @see https://stackoverflow.com/questions/73476371/using-pinia-with-vue-js-web-components
|
|
* @see https://github.com/vuejs/pinia/discussions/1085
|
|
*/
|
|
setActivePinia(createPinia());
|
|
|
|
export const usePurchaseStore = defineStore('purchase', () => {
|
|
const callbackStore = useCallbackActionsStore();
|
|
const serverStore = useServerStore();
|
|
|
|
const serverPurchasePayload = computed(() => serverStore.serverPurchasePayload);
|
|
const inIframe = computed(() => serverStore.inIframe);
|
|
const sendType = computed(() => callbackStore.sendType);
|
|
|
|
const activate = () => {
|
|
const { activationCode } = storeToRefs(useActivationCodeDataStore());
|
|
|
|
callbackStore.send(
|
|
PURCHASE_CALLBACK.toString(),
|
|
[
|
|
{
|
|
/**
|
|
* @todo Remove the type cast once the payload type can be more specific.
|
|
*/
|
|
server: {
|
|
...serverPurchasePayload.value,
|
|
activationCodeData: activationCode.value,
|
|
},
|
|
type: 'activate',
|
|
},
|
|
],
|
|
inIframe.value ? 'newTab' : undefined,
|
|
sendType.value
|
|
);
|
|
};
|
|
const redeem = () => {
|
|
callbackStore.send(
|
|
PURCHASE_CALLBACK.toString(),
|
|
[
|
|
{
|
|
server: {
|
|
...serverPurchasePayload.value,
|
|
},
|
|
type: 'redeem',
|
|
},
|
|
],
|
|
inIframe.value ? 'newTab' : undefined,
|
|
sendType.value
|
|
);
|
|
};
|
|
const purchase = () => {
|
|
callbackStore.send(
|
|
PURCHASE_CALLBACK.toString(),
|
|
[
|
|
{
|
|
server: {
|
|
...serverPurchasePayload.value,
|
|
},
|
|
type: 'purchase',
|
|
},
|
|
],
|
|
inIframe.value ? 'newTab' : undefined,
|
|
sendType.value
|
|
);
|
|
};
|
|
const upgrade = () => {
|
|
callbackStore.send(
|
|
PURCHASE_CALLBACK.toString(),
|
|
[
|
|
{
|
|
server: {
|
|
...serverPurchasePayload.value,
|
|
},
|
|
type: 'upgrade',
|
|
},
|
|
],
|
|
inIframe.value ? 'newTab' : undefined,
|
|
sendType.value
|
|
);
|
|
};
|
|
const renew = () => {
|
|
callbackStore.send(
|
|
PURCHASE_CALLBACK.toString(),
|
|
[
|
|
{
|
|
server: {
|
|
...serverPurchasePayload.value,
|
|
},
|
|
type: 'renew',
|
|
},
|
|
],
|
|
inIframe.value ? 'newTab' : undefined,
|
|
sendType.value
|
|
);
|
|
};
|
|
|
|
return {
|
|
activate,
|
|
redeem,
|
|
purchase,
|
|
upgrade,
|
|
renew,
|
|
};
|
|
});
|