feat: wire as-of date into organization and seatmap views
This commit is contained in:
@@ -7,6 +7,7 @@ let isListMode = false;
|
||||
let emptyStateMessage = '서버에 조직 데이터가 없습니다. 상단의 업로드 버튼으로 초기 데이터를 넣어주세요.';
|
||||
let photoPreviewObjectUrl = null;
|
||||
let seatMapLayoutCache = null;
|
||||
let activeAsOfDate = '';
|
||||
const seatMapOfficeKeys = ['technical-development-center', 'hanmac-building-6f', 'hanmac-building-7f'];
|
||||
|
||||
const levelOrder = ['부서', '그룹', '디비전', '팀', '셀'];
|
||||
@@ -117,6 +118,14 @@ async function apiFetch(url, options = {}) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
function withAsOf(url) {
|
||||
if (!activeAsOfDate) {
|
||||
return url;
|
||||
}
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
return `${url}${separator}as_of=${encodeURIComponent(activeAsOfDate)}`;
|
||||
}
|
||||
|
||||
async function uploadProfilePhoto(file, memberName) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
@@ -140,7 +149,7 @@ async function loadMembers(message) {
|
||||
if (message) {
|
||||
emptyStateMessage = message;
|
||||
}
|
||||
const payload = await apiFetch('/api/members');
|
||||
const payload = await apiFetch(withAsOf('/api/members'));
|
||||
setMembers(payload.items || []);
|
||||
if (!members.length) {
|
||||
emptyStateMessage = '서버에 조직 데이터가 없습니다. 상단의 업로드 버튼으로 초기 데이터를 넣어주세요.';
|
||||
@@ -160,7 +169,7 @@ async function loadSeatMapLayouts(force = false) {
|
||||
if (!seatMap?.id) {
|
||||
return null;
|
||||
}
|
||||
return await apiFetch(`/api/seat-maps/${seatMap.id}/layout`);
|
||||
return await apiFetch(withAsOf(`/api/seat-maps/${seatMap.id}/layout`));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -666,6 +675,15 @@ window.addEventListener('message', (event) => {
|
||||
if (!data || typeof data !== 'object') {
|
||||
return;
|
||||
}
|
||||
if (data.type === 'date-range') {
|
||||
const nextAsOfDate = String(data.endDate || '').slice(0, 10);
|
||||
if (nextAsOfDate !== activeAsOfDate) {
|
||||
activeAsOfDate = nextAsOfDate;
|
||||
seatMapLayoutCache = null;
|
||||
loadMembers().catch(() => { });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data.type === 'seatmap-layout-updated') {
|
||||
handleSeatMapLayoutUpdated();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user