Merge branch 'dev' into feat/login-page-customization

This commit is contained in:
miloschwartz
2025-12-17 11:41:17 -05:00
660 changed files with 19695 additions and 12803 deletions

View File

@@ -34,40 +34,43 @@ export function useCertificate({
pollingInterval = 5000
}: UseCertificateProps): UseCertificateReturn {
const api = createApiClient(useEnvContext());
const [cert, setCert] = useState<GetCertificateResponse | null>(null);
const [certLoading, setCertLoading] = useState(false);
const [certError, setCertError] = useState<string | null>(null);
const [refreshing, setRefreshing] = useState(false);
const fetchCert = useCallback(async (showLoading = true) => {
if (!orgId || !domainId || !fullDomain) return;
if (showLoading) {
setCertLoading(true);
}
setCertError(null);
try {
const res = await api.get<AxiosResponse<GetCertificateResponse>>(
`/org/${orgId}/certificate/${domainId}/${fullDomain}`
);
const certData = res.data.data;
if (certData) {
setCert(certData);
}
} catch (error: any) {
console.error("Failed to fetch certificate:", error);
setCertError("Failed to fetch certificate");
} finally {
const fetchCert = useCallback(
async (showLoading = true) => {
if (!orgId || !domainId || !fullDomain) return;
if (showLoading) {
setCertLoading(false);
setCertLoading(true);
}
}
}, [api, orgId, domainId, fullDomain]);
setCertError(null);
try {
const res = await api.get<
AxiosResponse<GetCertificateResponse>
>(`/org/${orgId}/certificate/${domainId}/${fullDomain}`);
const certData = res.data.data;
if (certData) {
setCert(certData);
}
} catch (error: any) {
console.error("Failed to fetch certificate:", error);
setCertError("Failed to fetch certificate");
} finally {
if (showLoading) {
setCertLoading(false);
}
}
},
[api, orgId, domainId, fullDomain]
);
const refreshCert = useCallback(async () => {
if (!cert) return;
setRefreshing(true);
setCertError(null);
try {

View File

@@ -4,7 +4,7 @@ import { useContext } from "react";
export function useClientContext() {
const context = useContext(ClientContext);
if (context === undefined) {
throw new Error('useSiteContext must be used within a SiteProvider');
throw new Error("useSiteContext must be used within a SiteProvider");
}
return context;
}
}

View File

@@ -4,7 +4,9 @@ import { useContext } from "react";
export function useDomainContext() {
const context = useContext(DomainContext);
if (context === undefined) {
throw new Error('useDomainContext must be used within a DomainProvider');
throw new Error(
"useDomainContext must be used within a DomainProvider"
);
}
return context;
}
}

View File

@@ -7,14 +7,16 @@ import { useContext } from "react";
export function useRemoteExitNodeContext() {
if (build == "oss") {
return {
return {
remoteExitNode: {} as GetRemoteExitNodeResponse,
updateRemoteExitNode: () => {},
updateRemoteExitNode: () => {}
};
}
const context = useContext(RemoteExitNodeContext);
if (context === undefined) {
throw new Error("useRemoteExitNodeContext must be used within a RemoteExitNodeProvider");
throw new Error(
"useRemoteExitNodeContext must be used within a RemoteExitNodeProvider"
);
}
return context;
}

View File

@@ -4,7 +4,7 @@ import { useContext } from "react";
export function useSiteContext() {
const context = useContext(SiteContext);
if (context === undefined) {
throw new Error('useSiteContext must be used within a SiteProvider');
throw new Error("useSiteContext must be used within a SiteProvider");
}
return context;
}
}

View File

@@ -19,7 +19,7 @@ const actionTypes = {
ADD_TOAST: "ADD_TOAST",
UPDATE_TOAST: "UPDATE_TOAST",
DISMISS_TOAST: "DISMISS_TOAST",
REMOVE_TOAST: "REMOVE_TOAST",
REMOVE_TOAST: "REMOVE_TOAST"
} as const;
let count = 0;
@@ -64,7 +64,7 @@ const addToRemoveQueue = (toastId: string) => {
toastTimeouts.delete(toastId);
dispatch({
type: "REMOVE_TOAST",
toastId: toastId,
toastId: toastId
});
}, TOAST_REMOVE_DELAY);
@@ -76,7 +76,7 @@ export const reducer = (state: State, action: Action): State => {
case "ADD_TOAST":
return {
...state,
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)
};
case "UPDATE_TOAST":
@@ -84,7 +84,7 @@ export const reducer = (state: State, action: Action): State => {
...state,
toasts: state.toasts.map((t) =>
t.id === action.toast.id ? { ...t, ...action.toast } : t
),
)
};
case "DISMISS_TOAST": {
@@ -106,22 +106,22 @@ export const reducer = (state: State, action: Action): State => {
t.id === toastId || toastId === undefined
? {
...t,
open: false,
open: false
}
: t
),
)
};
}
case "REMOVE_TOAST":
if (action.toastId === undefined) {
return {
...state,
toasts: [],
toasts: []
};
}
return {
...state,
toasts: state.toasts.filter((t) => t.id !== action.toastId),
toasts: state.toasts.filter((t) => t.id !== action.toastId)
};
}
};
@@ -145,7 +145,7 @@ function toast({ ...props }: Toast) {
const update = (props: ToasterToast) =>
dispatch({
type: "UPDATE_TOAST",
toast: { ...props, id },
toast: { ...props, id }
});
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
@@ -157,14 +157,14 @@ function toast({ ...props }: Toast) {
open: true,
onOpenChange: (open) => {
if (!open) dismiss();
},
},
}
}
});
return {
id: id,
dismiss,
update,
update
};
}
@@ -185,7 +185,7 @@ function useToast() {
...state,
toast,
dismiss: (toastId?: string) =>
dispatch({ type: "DISMISS_TOAST", toastId }),
dispatch({ type: "DISMISS_TOAST", toastId })
};
}