Commit a2fad30c authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

feat: implement UUID generation function for appId in CreateProfileModal

parent 8982954e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -108,6 +108,17 @@ const initialForm = (): FormState => ({
});


function generateUUID(): string {
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
    return crypto.randomUUID();
  }
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
    const r = (Math.random() * 16) | 0;
    const v = c === "x" ? r : (r & 0x3) | 0x8;
    return v.toString(16);
  });
}

const packageTypeOptions = ["HELM", "CONTAINER", "QCOW2", "OVA"].map((v) => ({ label: v, value: v }));
const repoTypeOptions = ["PUBLICREPO", "PRIVATEREPO"].map((v) => ({ label: v, value: v }));
const protocolOptions = ["TCP", "UDP", "ANY"].map((v) => ({ label: v, value: v }));
@@ -202,7 +213,7 @@ export const CreateProfileModal = ({ open, onClose, onCreated }: Props) => {

    setSubmitting(true);

    const appId = crypto.randomUUID();
    const appId = generateUUID();

    const body: Record<string, unknown> = {
      appId,