Fixed minor bugs during code cleaning

This commit is contained in:
Vladyslav Matsiiako
2023-01-17 19:03:43 -08:00
parent 7ae73d1b62
commit 18fbe82535
13 changed files with 38 additions and 33 deletions
+3 -2
View File
@@ -190,7 +190,8 @@ const Layout = ({ children }: LayoutProps) => {
userWorkspaces.length === 0 &&
router.asPath !== '/noprojects' &&
!router.asPath.includes('home') &&
!router.asPath.includes('settings')
!router.asPath.includes('settings') ||
router.asPath === '/dashboard/undefined'
) {
router.push('/noprojects');
} else if (router.asPath !== '/noprojects') {
@@ -259,7 +260,7 @@ const Layout = ({ children }: LayoutProps) => {
</div>
{Object.keys(workspaceMapping).length > 0 ? (
<Listbox
selected={workspaceSelected}
isSelected={workspaceSelected}
onChange={setWorkspaceSelected}
data={Object.keys(workspaceMapping)}
buttonAction={openModal}
+12 -12
View File
@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Listbox, Transition } from '@headlessui/react';
interface ListBoxProps {
selected: string;
isSelected: string;
onChange: (arg: string) => void;
data: string[] | null;
text?: string;
@@ -15,7 +15,7 @@ interface ListBoxProps {
/**
* This is the component that we use for drop down lists.
* @param {object} obj
* @param {string} obj.selected - the item that is currently selected
* @param {string} obj.isSelected - the item that is currently selected
* @param {function} obj.onChange - what happends if you select the item inside a list
* @param {string[]} obj.data - all the options available
* @param {string} obj.text - the text that shows us in front of the select option
@@ -23,7 +23,7 @@ interface ListBoxProps {
* @returns
*/
const ListBox = ({
selected,
isSelected,
onChange,
data,
text,
@@ -31,7 +31,7 @@ const ListBox = ({
isFull
}: ListBoxProps): JSX.Element => {
return (
<Listbox value={selected} onChange={onChange}>
<Listbox value={isSelected} onChange={onChange}>
<div className="relative">
<Listbox.Button
className={`text-gray-400 relative ${
@@ -40,9 +40,9 @@ const ListBox = ({
>
<div className="flex flex-row">
{text}
<span className="ml-1 cursor-pointer block truncate font-semibold text-gray-300 capitalize">
<span className="ml-1 cursor-pointer block truncate font-semibold text-gray-300">
{' '}
{selected}
{isSelected}
</span>
</div>
{data && (
@@ -62,22 +62,22 @@ const ListBox = ({
{data.map((person, personIdx) => (
<Listbox.Option
key={`${person}.${personIdx + 1}`}
className={({ active, selected: isSelected }) =>
`my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md capitalize ${
isSelected ? 'bg-white/10 text-gray-400 font-bold' : ''
className={({ active, selected }) =>
`my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md ${
selected ? 'bg-white/10 text-gray-400 font-bold' : ''
} ${
active && !isSelected
active && !selected
? 'bg-white/5 text-mineshaft-200 cursor-pointer'
: 'text-gray-400'
} `
}
value={person}
>
{({ selected: isSelected }) => (
{({ selected }) => (
<>
<span
className={`block truncate text-primary${
isSelected ? 'font-medium' : 'font-normal'
selected ? 'font-medium' : 'font-normal'
}`}
>
{person}
@@ -126,7 +126,7 @@ const AddApiKeyDialog = ({
</div>
<div className='max-h-28'>
<ListBox
selected={apiKeyExpiresIn}
isSelected={apiKeyExpiresIn}
onChange={setApiKeyExpiresIn}
data={[
'1 day',
@@ -107,7 +107,7 @@ const AddProjectMemberDialog = ({
</div>
<div className="max-h-28">
{data?.length > 0 && (
<ListBox selected={email || data[0]} onChange={setEmail} data={data} isFull />
<ListBox isSelected={email || data[0]} onChange={setEmail} data={data} isFull />
)}
</div>
<div className="max-w-max">
@@ -170,7 +170,7 @@ const AddServiceTokenDialog = ({
</div>
<div className='max-h-28 mb-2'>
<ListBox
selected={
isSelected={
selectedServiceTokenEnv?.name
? selectedServiceTokenEnv?.name
: environments[0]?.name
@@ -192,7 +192,7 @@ const AddServiceTokenDialog = ({
</div>
<div className='max-h-28'>
<ListBox
selected={serviceTokenExpiresIn}
isSelected={serviceTokenExpiresIn}
onChange={setServiceTokenExpiresIn}
data={[
'1 day',
@@ -152,7 +152,7 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg }
((myRole === 'admin' && row.role !== 'owner') || myRole === 'owner') &&
myUser !== row.email ? (
<Listbox
selected={row.role}
isSelected={row.role}
onChange={(e) => handleRoleUpdate(index, e)}
data={
myRole === 'owner' ? ['owner', 'admin', 'member'] : ['admin', 'member']
@@ -163,7 +163,7 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg }
row.status !== 'invited' &&
row.status !== 'verified' && (
<Listbox
selected={row.role}
isSelected={row.role}
text="Role: "
onChange={() => {
throw new Error('Function not implemented.');
@@ -94,7 +94,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
<div className="text-gray-400 text-xs font-semibold mb-2 w-60">ENVIRONMENT</div>
<ListBox
data={!integration.isActive ? ['Development', 'Preview', 'Production'] : null}
selected={integrationTarget}
isSelected={integrationTarget}
onChange={setIntegrationTarget}
isFull
/>
@@ -110,7 +110,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
? ['Production', 'Deploy previews', 'Branch deploys', 'Local development']
: null
}
selected={integrationContext}
isSelected={integrationContext}
onChange={setIntegrationContext}
/>
</div>
@@ -134,7 +134,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
<p className="text-gray-400 text-xs font-semibold mb-2">ENVIRONMENT</p>
<ListBox
data={!integration.isActive ? environments.map(({ name }) => name) : null}
selected={integrationEnvironment.name}
isSelected={integrationEnvironment.name}
onChange={(envName) =>
setIntegrationEnvironment(
environments.find(({ name }) => envName === name) || {
@@ -159,7 +159,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
<div className="text-gray-400 text-xs font-semibold mb-2">APP</div>
<ListBox
data={!integration.isActive ? apps.map((app) => app.name) : null}
selected={integrationApp}
isSelected={integrationApp}
onChange={(app) => {
setIntegrationApp(app);
}}
@@ -204,7 +204,11 @@ const attemptLogin = async (
}
if (isLogin) {
router.push(`/dashboard/${localStorage.getItem('projectData.id')}`);
if (localStorage.getItem('projectData.id') !== "undefined") {
router.push(`/dashboard/${localStorage.getItem('projectData.id')}`);
} else {
router.push("/noprojects");
}
}
} catch (error) {
console.log(error);