🐛 fix: Add copy subscription functionality to user subscription dashboard and improve localization for new features

This commit is contained in:
web
2025-09-14 23:09:59 -07:00
parent 1d52642cb7
commit e2a357fea7
30 changed files with 137 additions and 63 deletions
+20 -1
View File
@@ -1,3 +1,5 @@
import { NEXT_PUBLIC_API_URL, NEXT_PUBLIC_SITE_URL } from '@/config/constants';
import { extractDomain } from '@workspace/ui/utils';
import { create } from 'zustand';
export interface GlobalStore {
@@ -5,9 +7,10 @@ export interface GlobalStore {
user?: API.User;
setCommon: (common: Partial<API.GetGlobalConfigResponse>) => void;
setUser: (user?: API.User) => void;
getUserSubscribeUrls: (uuid: string, type?: string) => string[];
}
export const useGlobalStore = create<GlobalStore>((set) => ({
export const useGlobalStore = create<GlobalStore>((set, get) => ({
common: {
site: {
host: '',
@@ -77,6 +80,22 @@ export const useGlobalStore = create<GlobalStore>((set) => ({
},
})),
setUser: (user) => set({ user }),
getUserSubscribeUrls: (uuid: string, type?: string) => {
const { pan_domain, subscribe_domain, subscribe_path } = get().common.subscribe || {};
const domains = subscribe_domain
? subscribe_domain.split('\n')
: [extractDomain(NEXT_PUBLIC_API_URL || NEXT_PUBLIC_SITE_URL || '', pan_domain)];
return domains.map((domain) => {
if (pan_domain) {
if (type) return `https://${uuid}.${type}.${domain}`;
return `https://${uuid}.${domain}`;
} else {
if (type) return `https://${domain}${subscribe_path}?token=${uuid}&type=${type}`;
return `https://${domain}${subscribe_path}?token=${uuid}`;
}
});
},
}));
export default useGlobalStore;