Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / frontend/src/lib/orgQueries.ts |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | frontend/src/lib/orgQueries.ts |
| Original SHA-256 | 8dc87c15bb45af857e49f95066e258e15a0e3afd8ec5e77e72021581bfbb4972 |
| Git blob SHA | 82fc2c485df9951ef029727a0d0e2a2486f8ddaa |
| Reading-copy SHA-256 | 8dc87c15bb45af857e49f95066e258e15a0e3afd8ec5e77e72021581bfbb4972 |
Every recorded occurrence
These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / frontend/src/lib/orgQueries.ts | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / frontend/src/lib/orgQueries.ts | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓50 lines · 1.8 KB
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { orgApi } from './org'
// Branding changes rarely and is read by the shell on every screen, so it is cached for the session.
export function useOrgBranding() {
return useQuery({ queryKey: ['org', 'branding'], queryFn: orgApi.branding, staleTime: 5 * 60_000 })
}
export function useSetDisplayName() {
const qc = useQueryClient()
return useMutation({
mutationFn: (name: string) => orgApi.setDisplayName(name),
onSuccess: () => void qc.invalidateQueries({ queryKey: ['org', 'branding'] }),
})
}
export function useUploadLogo() {
const qc = useQueryClient()
return useMutation({
mutationFn: async (file: File) => {
// Sent as a raw body, not multipart. The server ignores the declared type entirely and derives the
// format by decoding the bytes, so there is nothing to gain from a form envelope.
const csrf = await fetch('/api/auth/csrf', { credentials: 'include' })
.then((r) => r.json())
.then((j: { csrf_token: string }) => j.csrf_token)
const res = await fetch('/api/org/logo', {
method: 'PUT',
credentials: 'include',
headers: { 'X-CSRF-Token': csrf, 'Content-Type': 'application/octet-stream' },
body: file,
})
if (!res.ok) {
const body = (await res.json().catch(() => ({}))) as { error?: string }
throw new Error(body.error ?? `upload failed with ${res.status}`)
}
return res.json()
},
onSuccess: () => void qc.invalidateQueries({ queryKey: ['org', 'branding'] }),
})
}
export function useClearLogo() {
const qc = useQueryClient()
return useMutation({
mutationFn: () => orgApi.clearLogo(),
onSuccess: () => void qc.invalidateQueries({ queryKey: ['org', 'branding'] }),
})
}