File size: 526 Bytes
6aa76ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import type { EnvVarInfo } from "./api";

/** Reconcile a successful DELETE /api/env response with the Keys page state. */
export function removeDeletedEnvVarFromState(
  vars: Record<string, EnvVarInfo> | null,
  key: string,
): Record<string, EnvVarInfo> | null {
  const info = vars?.[key];
  if (!vars || !info) return vars;

  if (info.custom) {
    const updated = { ...vars };
    delete updated[key];
    return updated;
  }

  return {
    ...vars,
    [key]: { ...info, is_set: false, redacted_value: null },
  };
}