Skip to content

Commit

Permalink
trailing comma "all"
Browse files Browse the repository at this point in the history
  • Loading branch information
fizfakovets committed Mar 5, 2024
1 parent b2810e6 commit ec97b4b
Show file tree
Hide file tree
Showing 73 changed files with 327 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"trailingComma": "none",
"trailingComma": "all",
"arrowParens": "avoid",
"bracketSpacing": true,
"useTabs": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --host --port 443",
"dev": "vite",
"build": "vite build",
"build:development": "vite build --mode development",
"build:testing": "vite build --mode testing",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ onMounted(async () => {
if (profileStore.marketingId) {
marketingApi.writeAction({
action: 'app loaded',
user_id: profileStore.marketingId
user_id: profileStore.marketingId,
});
}
});
Expand Down
16 changes: 8 additions & 8 deletions src/api/BaseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class BaseApi {
protected async get<Response, Params = never>(
path: string,
params?: Params,
headers: Record<string, string> = {}
headers: Record<string, string> = {},
): Promise<AxiosResponse<Response>> {
if (!headers.Authorization) {
headers.Authorization = localStorage.getItem('token') ?? '';
Expand All @@ -26,29 +26,29 @@ export class BaseApi {
params,
headers,
paramsSerializer: {
serialize: params => queryString.stringify(params, { arrayFormat: 'none' })
}
serialize: params => queryString.stringify(params, { arrayFormat: 'none' }),
},
});
}

protected async post<Response, Body = never>(
path: string,
body?: Body,
headers: Record<string, string> = {}
headers: Record<string, string> = {},
): Promise<AxiosResponse<Response>> {
if (!headers.Authorization) {
headers.Authorization = localStorage.getItem('token') ?? '';
}

return axios.post<Response, AxiosResponse<Response>, Body>(`${this.url}${path}`, body, {
headers
headers,
});
}

protected async delete<Response, Params = never>(
path: string,
params?: Params,
headers: Record<string, string> = {}
headers: Record<string, string> = {},
): Promise<AxiosResponse<Response>> {
if (!headers.Authorization) {
headers.Authorization = localStorage.getItem('token') ?? '';
Expand All @@ -60,14 +60,14 @@ export class BaseApi {
protected async patch<Response, Body>(
path: string,
body: Body,
headers: Record<string, string> = {}
headers: Record<string, string> = {},
): Promise<AxiosResponse<Response>> {
if (!headers.Authorization) {
headers.Authorization = localStorage.getItem('token') ?? '';
}

return axios.patch<Response, AxiosResponse<Response>, Body>(`${this.url}${path}`, body, {
headers
headers,
});
}
}
2 changes: 1 addition & 1 deletion src/api/EntityBaseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class EntityBaseApi<
E extends Entity,
GetAllP extends GetAllParams = never,
ModifyB = Omit<E, 'id'>,
GetP = never
GetP = never,
> extends BaseApi {
constructor(path: string) {
super(path);
Expand Down
2 changes: 1 addition & 1 deletion src/api/achievement/AchievementApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AchievementApi extends BaseApi {
form.append('picture_file', picture);

return this.post<AchievementGet, AchievementCreate>('/achievement', { name, description }).then(
resp => this.patch<AchievementGet, FormData>(`/achievement/${resp.data.id}/picture`, form)
resp => this.patch<AchievementGet, FormData>(`/achievement/${resp.data.id}/picture`, form),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/auth/AuthEmailApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class AuthEmailApi extends AuthBaseApi {
public async requestResetForgottenPassword(body: RequestResetForgottenPasswordBody) {
return this.post<DefaultResponse, RequestResetForgottenPasswordBody>(
'/reset/password/restore',
body
body,
);
}

public async resetPassword(body: ResetPasswordParams, token: string) {
return this.post<DefaultResponse, ResetPasswordParams>('/reset/password', body, {
'reset-token': token
'reset-token': token,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/auth/AuthGroupApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum GroupInfo {
Children = 'child',
Scopes = 'scopes',
IndirectScopes = 'indirect_scopes',
Users = 'users'
Users = 'users',
}

type GetGroupResponse<Info extends GroupInfo> = Group & {
Expand Down
2 changes: 1 addition & 1 deletion src/api/auth/AuthUserApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AuthBaseApi } from './AuthBaseApi';
export enum UserInfo {
Groups = 'groups',
IndirectGroups = 'indirect_groups',
Scopes = 'scopes'
Scopes = 'scopes',
}

class AuthUserApi extends AuthBaseApi {
Expand Down
6 changes: 3 additions & 3 deletions src/api/auth/UserSessionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export enum MySessionInfo {
IndirectGroups = 'indirect_groups',
SessionScopes = 'session_scopes',
UserScopes = 'user_scopes',
AuthMethods = 'auth_methods'
AuthMethods = 'auth_methods',
}

export enum AuthMethod {
Expand All @@ -24,7 +24,7 @@ export enum AuthMethod {
MyMsu = 'my_msu_auth',
Physics = 'physics_auth',
Telegram = 'telegram_auth',
VK = 'vk_auth'
VK = 'vk_auth',
}

interface SessionResponse {
Expand All @@ -37,7 +37,7 @@ interface SessionResponse {
export enum SessionInfo {
SessionScopes = 'session_scopes',
Token = 'token',
Expires = 'expires'
Expires = 'expires',
}

class UserSessionApi extends AuthBaseApi {
Expand Down
6 changes: 3 additions & 3 deletions src/api/controllers/TimetableApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class TimetableApi {
const { data } = await timetableEventApi.getAll({
start: stringifyDateIso(date),
end: stringifyDateIso(getDateWithDayOffset(date, 1)),
group_id: groupId
group_id: groupId,
});
setDay(date, data.items);
}
Expand All @@ -56,7 +56,7 @@ export class TimetableApi {
const { data } = await timetableEventApi.getAll({
start: stringifyDateIso(new Date()),
end: stringifyDateIso(getDateWithDayOffset(new Date(), 1)),
lecturer_id: lecturerId
lecturer_id: lecturerId,
});
if (data.items.length) {
setLecturers(data.items[0].lecturer);
Expand All @@ -69,7 +69,7 @@ export class TimetableApi {
const { data } = await timetableEventApi.getAll({
start: stringifyDateIso(new Date()),
end: stringifyDateIso(getDateWithDayOffset(new Date(), 1)),
room_id: roomId
room_id: roomId,
});
if (data.items.length) {
setRooms(data.items[0].room);
Expand Down
6 changes: 3 additions & 3 deletions src/api/controllers/UserdataApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export class UserdataApi {
static getUser = apply(
async (id: number) => await userdataUserApi.getById(id),
[checkToken],
[showErrorToast]
[showErrorToast],
);

static getCategories = apply(
async () => await userdataCategoryApi.getAllWithParams(),
[checkToken],
[showErrorToast]
[showErrorToast],
);

static patchUserById = apply(
async (id: number, body: UserdataUpdateUser) => await userdataUserApi.patchById(id, body),
[checkToken],
[showErrorToast]
[showErrorToast],
);
}
36 changes: 18 additions & 18 deletions src/api/controllers/auth/AuthApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
authEmailApi,
authScopeApi,
authUserApi,
userSessionApi
userSessionApi,
} from '@/api/auth';
import router from '@/router';
import { scopename } from '@/models/ScopeName';
Expand All @@ -28,7 +28,7 @@ export class AuthApi {
const { data } = await authUserApi.getUser(id, info);
setUsers([data]);
},
[scoped, scopename.auth.user.read]
[scoped, scopename.auth.user.read],
);

static getUsers = apply(
Expand All @@ -37,7 +37,7 @@ export class AuthApi {
const { data } = await authUserApi.getUsers(info);
setUsers(data.items);
},
[scoped, scopename.auth.user.read]
[scoped, scopename.auth.user.read],
);

static logout = apply(async () => {
Expand All @@ -46,7 +46,7 @@ export class AuthApi {
profileStore.deleteToken();
router.push('/auth');
toastStore.push({
title: 'Вы успешно вышли из аккаунта!'
title: 'Вы успешно вышли из аккаунта!',
});
}, [showErrorToast]);

Expand All @@ -65,15 +65,15 @@ export class AuthApi {

LocalStorage.set<string[]>(
LocalStorageItem.TokenScopes,
data.session_scopes.map(s => s.name)
data.session_scopes.map(s => s.name),
);
profileStore.updateTokenScopes();

return promise;
},

[showErrorToast],
[checkToken]
[checkToken],
);

static loginEmail = apply(
Expand All @@ -88,12 +88,12 @@ export class AuthApi {
profileStore.updateToken();

toastStore.push({
title: 'Вы успешно вошли в аккаунт'
title: 'Вы успешно вошли в аккаунт',
});

return promise;
},
[showErrorToast]
[showErrorToast],
);

static registerEmail = apply(
Expand All @@ -105,14 +105,14 @@ export class AuthApi {

toastStore.push(
{
title: data.message
title: data.message,
},
null
null,
);

return promise;
},
[showErrorToast]
[showErrorToast],
);

static getSessions = apply(
Expand All @@ -121,7 +121,7 @@ export class AuthApi {
return data;
},
[showErrorToast],
[checkToken]
[checkToken],
);

static deleteSession = apply(
Expand All @@ -130,15 +130,15 @@ export class AuthApi {
return data;
},
[checkToken],
[showErrorToast]
[showErrorToast],
);

static requestResetForgottenPassword = apply(
async (email: string) => {
const data = await authEmailApi.requestResetForgottenPassword({ email });
return data;
},
[showErrorToast]
[showErrorToast],
);

static requestResetPassword = apply(
Expand All @@ -147,23 +147,23 @@ export class AuthApi {
return data;
},
[showErrorToast],
[checkToken]
[checkToken],
);

static resetPassword = apply(
async (new_password: string, token: string) => {
const data = await authEmailApi.resetPassword({ new_password }, token);
return data;
},
[showErrorToast]
[showErrorToast],
);

static resetEmail = apply(
async (token: string) => {
const data = await authEmailApi.resetEmail({ token });
return data;
},
[showErrorToast]
[showErrorToast],
);

static requestResetEmail = apply(
Expand All @@ -172,6 +172,6 @@ export class AuthApi {
return data;
},
[checkToken],
[showErrorToast]
[showErrorToast],
);
}
Loading

0 comments on commit ec97b4b

Please sign in to comment.