Skip to content

Commit

Permalink
Merge pull request #56 from Diary-SPO/fix-mark
Browse files Browse the repository at this point in the history
little fixes
  • Loading branch information
scffs authored Sep 13, 2023
2 parents 1ee7998 + c93fa65 commit c68793f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 13 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions frontend/src/methods/bridge/appStorageSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const appStorageSet = async (key: string, value: string): Promise<boolean
if (data.result) {
return data.result;
}

return false;
} catch (error) {
console.error(error);
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/methods/server/getLessons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { getUserId } from '../bridge/getUserId';
import { getCookie } from '../bridge/getCookie';

export const getLessons = async (startDate?: Date, endDate?: Date): Promise<Day[] | 418 | 429> => {
const cookie = await getCookie();
const id = await getUserId();
const cookie = await getCookie() || localStorage.getItem('cookie');
const id = await getUserId() || localStorage.getItem('id');

if (!id) {
return 418;
}

if (!cookie) {
return 418;
}
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/methods/server/getPerformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { getCookie } from '../bridge/getCookie';
import { getUserId } from '../bridge/getUserId';

export const getPerformance = async (): Promise<PerformanceCurrent | 418 | 429> => {
const cookie = await getCookie();
const id = await getUserId();
console.log('getUserId', id);
const cookie = await getCookie() || localStorage.getItem('cookie');
const id = await getUserId() || localStorage.getItem('id');

if (!cookie) {
return 418;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/utils/logOut.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { clearVkStorage } from '../views/Settings';

const logOut = async () => {
localStorage.setItem('savedMarks', '')
localStorage.setItem('lastRequestTime ', '')
await clearVkStorage();
location.reload();
};
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/views/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ const LoginForm: FC<{ id: string }> = ({ id }) => {
setPopout(<ScreenSpinner state='loading' />);
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
login,
password: passwordHashed,
isRemember: true,
}),
});

if (response.status === 401) {
console.log('401');
setIsLoading(false);
Expand All @@ -109,15 +114,16 @@ const LoginForm: FC<{ id: string }> = ({ id }) => {
}

try {
localStorage.setItem('id', String(dataResp.data.tenants.SPO_23.studentRole.id));
localStorage.setItem('cookie', dataResp.cookie);

await appStorageSet('cookie', dataResp.cookie);
await appStorageSet('id', String(dataResp.data.tenants.SPO_23.studentRole.id));

await appStorageSet('firstName', String(dataResp.data.tenants.SPO_23.firstName));
await appStorageSet('lastName', String(dataResp.data.tenants.SPO_23.lastName));
await appStorageSet('firstName', String(dataResp.data.tenants.SPO_23.firstName));
await appStorageSet('middleName', String(dataResp.data.tenants.SPO_23.middleName));
await appStorageSet('org', String(dataResp.data.tenants.SPO_23.settings.organization.abbreviation));
await appStorageSet('city', String(dataResp.data.tenants.SPO_23.settings.organization.address.settlement));

await appStorageSet('group', String(dataResp.data.tenants.SPO_23.students[0].groupName));

setIsLoading(false);
Expand Down
4 changes: 2 additions & 2 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig({
},
rollupOptions: {
logLevel: 'debug',
input: 'index-b4.html',
input: 'index-b5.html',
output: {
manualChunks: {
react: ['react', 'react-dom'],
Expand All @@ -36,5 +36,5 @@ export default defineConfig({
},
// Указывать только для dev сборки.
// Либо index'у вернуть его исходное имя, а переименовывать только при деплое
base: 'index-b4.html',
base: 'index-b5.html',
})
6 changes: 3 additions & 3 deletions frontend/vk-hosting-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"static_path": "dist",
"app_id": 51723411,
"endpoints": {
"mobile": "index-b4.html",
"mvk": "index-b4.html",
"web": "index-b4.html"
"mobile": "index-b5.html",
"mvk": "index-b5.html",
"web": "index-b5.html"
}
}

0 comments on commit c68793f

Please sign in to comment.