Skip to content

Commit

Permalink
feat(seaside): #195 fix user created timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
Marthym committed Jan 16, 2024
1 parent bac8df7 commit 4eb0011
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 1 addition & 8 deletions seaside/src/administration/component/UserAdminTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<td>{{ vUser.data.name }}</td>
<td>{{ vUser.data.mail }}</td>
<td>{{ roleFromPermission(vUser.data.roles) }}</td>
<td>{{ dateToString(vUser.data._createdAt) }}</td>
<td>{{ vUser.data._createdAt }}</td>
<td>
<div class="join justify-end w-full">
<button class="btn btn-sm btn-square btn-ghost join-item" @click.prevent="onUserEdit(vUser.data)">
Expand Down Expand Up @@ -176,13 +176,6 @@ export default class UserAdminTab extends Vue {
);
}
dateToString(date: string): string {
return new Date(date).toLocaleDateString(navigator.languages, {
timeZone: 'UTC',
year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit',
});
}
private roleFromPermission(perm: string[]): string {
const first = perm.slice(0, 1).join();
const idx = first.indexOf(':');
Expand Down
9 changes: 8 additions & 1 deletion seaside/src/security/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ export function userList(page = 0, query: URLSearchParams = new URLSearchParams(
map(response => ({
currentPage: resolvedPage,
totalPage: Math.ceil(response.totalCount / Number(resolvedPerPage)),
data: response.entities,
data: response.entities.map(user => ({
...user,
_createdAt: utcToZonedTime(user._createdAt),
})),
}),
),
take(1),
);
}

function utcToZonedTime(utcDate: string): string {
return new Date(utcDate).toLocaleString();
}

const USER_CREATE_REQUEST = `#graphql
mutation CreateNewUser ($user: UserForm) {
userCreate(user: $user) {
Expand Down

0 comments on commit 4eb0011

Please sign in to comment.