-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
179 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const useIsAuthenticated = () => { | ||
const prefix = 'useIsAuthenticated' | ||
const isAuthenticated = useState<boolean>(`${prefix}.isAuthenticated`, () => true) | ||
return isAuthenticated | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const useSignIn = async () => { | ||
const [ | ||
{ msalSignIn }, | ||
pactaClient, | ||
{ refreshMaybeMe }, | ||
] = await Promise.all([ | ||
useMSAL(), | ||
usePACTA(), | ||
useSession(), | ||
]) | ||
|
||
const signIn = () => msalSignIn() | ||
.then(() => pactaClient.userAuthenticationFollowup()) | ||
.then(() => refreshMaybeMe()) | ||
|
||
return { signIn } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
export const useTime = () => { | ||
const { locale: i18nLocale, t } = useI18n() | ||
const defaultLocale = 'en-US' | ||
const locale = computed(() => i18nLocale.value || defaultLocale) | ||
|
||
const prefix = 'useTime' | ||
const tt = (key: string) => t(`${prefix}.${key}`) | ||
|
||
const humanReadableDateLong = (t: Date): ComputedRef<string> => { | ||
return computed(() => { | ||
if (new Date().getDate() === t.getDate()) { | ||
return tt('today') | ||
} | ||
return t.toLocaleString(locale.value, { dateStyle: 'long' }) | ||
}) | ||
} | ||
|
||
const humanReadableDate = (t: Date): ComputedRef<string> => { | ||
return computed(() => { | ||
if (new Date().getDate() === t.getDate()) { | ||
return tt('today') | ||
} | ||
return t.toLocaleString(locale.value, { dateStyle: 'short' }) | ||
}) | ||
} | ||
|
||
const humanReadableTime = (t: Date): ComputedRef<string> => { | ||
return computed(() => { | ||
if (new Date().getDate() === t.getDate()) { | ||
return t.toLocaleTimeString(locale.value, { timeStyle: 'short' }) | ||
} | ||
return t.toLocaleString(locale.value, { dateStyle: 'short', timeStyle: 'short' }) | ||
}) | ||
} | ||
|
||
const humanReadableDateLongFromStandardString = (s: string): ComputedRef<string> => { | ||
return humanReadableDateLong(new Date(Date.parse(s))) | ||
} | ||
|
||
const humanReadableDateFromStandardString = (s: string): ComputedRef<string> => { | ||
return humanReadableDate(new Date(Date.parse(s))) | ||
} | ||
|
||
const humanReadableTimeFromStandardString = (asStr: string): ComputedRef<string> => { | ||
return humanReadableTime(new Date(Date.parse(asStr))) | ||
} | ||
|
||
const humanReadableTimeWithSeconds = (t: Date): ComputedRef<string> => { | ||
return computed(() => { | ||
const now = new Date() | ||
if (now.getDate() === t.getDate()) { | ||
if (now.getHours() === t.getHours()) { | ||
return t.toLocaleTimeString(locale.value, { hour: 'numeric', minute: '2-digit', second: '2-digit' }) | ||
} | ||
return t.toLocaleTimeString(locale.value, { timeStyle: 'short' }) | ||
} | ||
return t.toLocaleString(locale.value, { dateStyle: 'short', timeStyle: 'short' }) | ||
}) | ||
} | ||
|
||
return { | ||
humanReadableDateFromStandardString, | ||
humanReadableDateLongFromStandardString, | ||
humanReadableTimeFromStandardString, | ||
humanReadableTimeWithSeconds, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.