Makes campaigns load all types of docs and then link to the docs
This commit is contained in:
@@ -29,7 +29,9 @@ const AuthContext = createContext<AuthContextValue | undefined>(undefined);
|
||||
*/
|
||||
export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [user, setUser] = useState<AuthRecord | null>(pb.authStore.record);
|
||||
const [user, setUser] = useState<AuthRecord | null>(
|
||||
pb.authStore.isValid ? pb.authStore.record : null,
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
AnyDocument,
|
||||
DocumentId,
|
||||
DocumentType,
|
||||
Relationship,
|
||||
RelationshipType,
|
||||
} from "@/lib/types";
|
||||
@@ -30,3 +31,13 @@ export const initialState = (): DocumentState =>
|
||||
({
|
||||
documents: {},
|
||||
}) as DocumentState;
|
||||
|
||||
export const getAllDocumentsOfType = <T extends DocumentType>(
|
||||
docType: T,
|
||||
state: DocumentState,
|
||||
): (AnyDocument & { type: T })[] =>
|
||||
Object.values(state.documents).flatMap((docRecord) =>
|
||||
docRecord.type === "ready" && docRecord.value.doc.type === docType
|
||||
? [docRecord.value.doc as AnyDocument & { type: T }]
|
||||
: [],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user