Feat/startup config api (#518)

* feat: add api for config

* feat: add data service to client

* feat: update client pages with values from config endpoint

* test: update tests

* Update configurations and documentation to remove VITE_SHOW_GOOGLE_LOGIN_OPTION and change VITE_APP_TITLE to APP_TITLE

* include APP_TITLE with startup config

* Add test for new route

* update backend-review pipeline

* comment out test until we can figure out testing routes in CI

* update: .env.example

---------

Co-authored-by: fuegovic <32828263+fuegovic@users.noreply.github.com>
This commit is contained in:
Dan Orlando 2023-06-15 09:36:34 -07:00 committed by GitHub
parent 2da81db440
commit 3634d8691a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 419 additions and 75 deletions

View file

@ -1,11 +1,11 @@
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useForm } from 'react-hook-form';
import { useRegisterUserMutation, TRegisterUser } from '~/data-provider';
import { SHOW_GOOGLE_LOGIN_OPTION, DOMAIN_SERVER } from '~/utils/envConstants';
import { useRegisterUserMutation, TRegisterUser, useGetStartupConfig } from '~/data-provider';
function Registration() {
const navigate = useNavigate();
const { data: startupConfig } = useGetStartupConfig();
const {
register,
@ -34,6 +34,12 @@ function Registration() {
});
};
useEffect(() => {
if (startupConfig?.registrationEnabled === false) {
navigate('/login');
}
}, [startupConfig, navigate]);
return (
<div className="flex min-h-screen flex-col items-center justify-center bg-white pt-6 sm:pt-0">
<div className="mt-6 w-96 overflow-hidden bg-white px-6 py-4 sm:max-w-md sm:rounded-lg">
@ -266,7 +272,7 @@ function Registration() {
Login
</a>
</p>
{SHOW_GOOGLE_LOGIN_OPTION && (
{startupConfig?.googleLoginEnabled && (
<>
<div className="relative mt-6 flex w-full items-center justify-center border border-t uppercase">
<div className="absolute bg-white px-3 text-xs">Or</div>
@ -275,7 +281,7 @@ function Registration() {
<div className="mt-4 flex gap-x-2">
<a
aria-label="Login with Google"
href={`${DOMAIN_SERVER}/oauth/google`}
href={`${startupConfig.serverDomain}/oauth/google`}
className="justify-left flex w-full items-center space-x-3 rounded-md border border-gray-300 px-5 py-3 hover:bg-gray-50 focus:ring-2 focus:ring-violet-600 focus:ring-offset-1"
>
<svg