|
|
|
|
@ -19,24 +19,25 @@ export function UserProvider({children}) { |
|
|
|
|
|
|
|
|
|
const [userId, setUserId] = useState(null); |
|
|
|
|
const [sessionId, setSessionId] = useState(null); |
|
|
|
|
const [password, setPassword] = useState(null); |
|
|
|
|
// const [password, setPassword] = useState(null); |
|
|
|
|
const [choice, setChoice] = useState(null); |
|
|
|
|
const [summary, setSummary] = useState(null); |
|
|
|
|
|
|
|
|
|
const refChoice=useRef(); |
|
|
|
|
const refPassword=useRef(); |
|
|
|
|
|
|
|
|
|
const {data}=useData(); |
|
|
|
|
|
|
|
|
|
function getSessionId(){ |
|
|
|
|
return `${SessionTime[sessionId]!=null? SessionTime[sessionId][0].replace(':',''):'no-session'}`; |
|
|
|
|
} |
|
|
|
|
function getFileId(pass){ |
|
|
|
|
function getFileId(){ |
|
|
|
|
if(!userId){ |
|
|
|
|
if(data?.id){ |
|
|
|
|
return `PC${data.id.toString().padStart(2,'0')}`; |
|
|
|
|
return `${refPassword.current||''}_PC${data.id.toString().padStart(2,'0')}`; |
|
|
|
|
} |
|
|
|
|
return `${password||moment().format('hhmmss')}_testuser`; |
|
|
|
|
}return `${password||pass||'0000'}_${userId}`; |
|
|
|
|
return `${refPassword.current||moment().format('hhmmss')}_testuser`; |
|
|
|
|
}return `${refPassword.current||'0000'}_${userId}`; |
|
|
|
|
} |
|
|
|
|
function getDataId(){ |
|
|
|
|
if(!userId) return `${moment().format('YYYYMM')}/${moment().format("MMDD")}/${getSessionId()}/testuser_${moment().format('hhmmss')}`; |
|
|
|
|
@ -46,7 +47,10 @@ export function UserProvider({children}) { |
|
|
|
|
function getUploadFolder(){ |
|
|
|
|
return `${moment().format("YYYYMM")}/${moment().format("MMDD")}/${getSessionId()}`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function setPassword(pass){ |
|
|
|
|
refPassword.current=pass; |
|
|
|
|
console.log("Password changed:", pass); |
|
|
|
|
} |
|
|
|
|
function reset(){ |
|
|
|
|
setUserId(null); |
|
|
|
|
setSessionId(null); |
|
|
|
|
@ -76,7 +80,7 @@ export function UserProvider({children}) { |
|
|
|
|
moment().format("YYYY/MM/DD"), |
|
|
|
|
getSessionId(), |
|
|
|
|
userId, |
|
|
|
|
password |
|
|
|
|
refPassword.current |
|
|
|
|
).then(() => { |
|
|
|
|
console.log("Data written to Google Sheet successfully"); |
|
|
|
|
}) |
|
|
|
|
@ -87,7 +91,7 @@ export function UserProvider({children}) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
console.log("User ID changed:", password, sessionId, userId); |
|
|
|
|
console.log("User ID changed:", refPassword.current, sessionId, userId); |
|
|
|
|
if(!userId) return; |
|
|
|
|
|
|
|
|
|
const data={ |
|
|
|
|
@ -110,7 +114,7 @@ export function UserProvider({children}) { |
|
|
|
|
console.error("Error updating user data:", error); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
},[password, choice, summary]); |
|
|
|
|
},[choice, summary, refPassword.current]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
|
|
|