mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
fix: preserve account access compatibility
This commit is contained in:
1 parent
e4e773d543
commit
4923db6464
23 files changed
+288
-14
No files matched your search
@@ -39,6 +39,7 @@ const OWNER = {
|
||||
access: "read" as const,
|
||||
level: "read" as const,
|
||||
sections: null,
|
||||
recordKind: "shared" as const,
|
||||
canWrite: false,
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ const OWNER = {
|
||||
access: "write" as const,
|
||||
level: "write" as const,
|
||||
sections: null,
|
||||
recordKind: "shared" as const,
|
||||
canWrite: true,
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ const GRANDMOTHER = {
|
||||
access: "read" as const,
|
||||
level: "read" as const,
|
||||
sections: null,
|
||||
recordKind: "shared" as const,
|
||||
canWrite: false,
|
||||
};
|
||||
const FATHER = {
|
||||
@@ -36,6 +37,7 @@ const FATHER = {
|
||||
access: "write" as const,
|
||||
level: "write" as const,
|
||||
sections: null,
|
||||
recordKind: "shared" as const,
|
||||
canWrite: true,
|
||||
};
|
||||
|
||||
|
||||
@@ -97,6 +97,12 @@ export function LookingAfterCard() {
|
||||
<span className="text-muted-foreground block truncate text-xs">
|
||||
{levelLabel(entry, t)}
|
||||
</span>
|
||||
<span className="text-muted-foreground block truncate text-xs">
|
||||
{recordKindLabel(entry, t)}
|
||||
</span>
|
||||
<span className="text-muted-foreground block truncate text-xs">
|
||||
{scopeLabel(entry, t)}
|
||||
</span>
|
||||
</span>
|
||||
{switchAccount.isPending && (
|
||||
<Loader2
|
||||
@@ -128,7 +134,34 @@ function levelLabel(
|
||||
entry: AccountAccessEntry,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
if (entry.level === "manage") {
|
||||
return t("recordSharing.row.canManage");
|
||||
}
|
||||
return entry.canWrite
|
||||
? t("recordSharing.lookingAfter.levelWrite")
|
||||
: t("recordSharing.lookingAfter.levelRead");
|
||||
}
|
||||
|
||||
function recordKindLabel(
|
||||
entry: AccountAccessEntry,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
return entry.recordKind === "managed"
|
||||
? t("recordSharing.lookingAfter.kindManaged")
|
||||
: t("recordSharing.lookingAfter.kindShared");
|
||||
}
|
||||
|
||||
function scopeLabel(
|
||||
entry: AccountAccessEntry,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
if (entry.sections === null) {
|
||||
return t("recordSharing.row.entireRecord");
|
||||
}
|
||||
if (entry.sections.length === 0) {
|
||||
return t("recordSharing.row.noSections");
|
||||
}
|
||||
return entry.sections
|
||||
.map((domain) => t(`recordSharing.section.${domain}.label`))
|
||||
.join(", ");
|
||||
}
|
||||
@@ -117,6 +117,7 @@ const OWNER_READ: AccountAccessEntry = {
|
||||
access: "read" as const,
|
||||
level: "read" as const,
|
||||
sections: null,
|
||||
recordKind: "shared" as const,
|
||||
canWrite: false,
|
||||
};
|
||||
const OWNER_WRITE: AccountAccessEntry = {
|
||||
|
||||
@@ -59,6 +59,7 @@ const OWNER = {
|
||||
access: "read" as const,
|
||||
level: "read" as const,
|
||||
sections: null,
|
||||
recordKind: "shared" as const,
|
||||
canWrite: false,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user