-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ui-fixes * reset gmaps input * job-form-width-fix * job-form-fixes * loading-spinner-skills-dropwdown * extract out skills combobox * cron-jobs-fix * default values for email host and port + fix cron job schedule time to 45 mins
- Loading branch information
1 parent
d9e8b62
commit 0156bc3
Showing
13 changed files
with
743 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use server'; | ||
/* eslint-disable no-console */ | ||
import { NextResponse } from 'next/server'; | ||
import { bearerToken } from '@/config/skillapi.auth.token'; | ||
|
||
var cron = require('node-cron'); | ||
|
||
const url = 'https://auth.emsicloud.com/connect/token'; | ||
|
||
async function startAuthTokenCronJob() { | ||
// don't run the cron job if its already running | ||
await fetchAuthTokenCronJob(); | ||
// Schedule the cron to run every 45 minutes , the token resets after one hour | ||
cron.schedule('*/45 * * * *', async () => { | ||
await fetchAuthTokenCronJob(); | ||
}); | ||
return NextResponse.json({ data: 'Success', status: 200 }); | ||
} | ||
|
||
const options = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
body: new URLSearchParams({ | ||
client_id: process.env.LIGHTCAST_CLIENT_ID ?? '', | ||
client_secret: process.env.LIGHTCAST_CLIENT_SECRET ?? '', | ||
grant_type: 'client_credentials', | ||
scope: 'emsi_open', | ||
}), | ||
}; | ||
|
||
async function fetchAuthTokenCronJob() { | ||
console.log('Fetching updated Lightcast token at ' + new Date()); | ||
try { | ||
const response = await fetch(url, options); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! Status: ${response.status}`); | ||
} | ||
const data = await response.json(); | ||
bearerToken.value = data.access_token; | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
} | ||
|
||
export async function getBearerToken() { | ||
return bearerToken.value; | ||
} | ||
|
||
startAuthTokenCronJob(); |
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,109 @@ | ||
import * as React from 'react'; | ||
import { Check, ChevronsUpDown } from 'lucide-react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
import { Button } from '@/components/ui/button'; | ||
import { | ||
Command, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandInput, | ||
CommandItem, | ||
CommandList, | ||
} from '@/components/ui/command'; | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from '@/components/ui/popover'; | ||
import { LoadingSpinner } from './loading-spinner'; | ||
|
||
export type TcomboBoxValue = { value: string; label: string }; | ||
|
||
export function Combobox({ | ||
dropdownValues, | ||
setComboBoxInputValue, | ||
isLoading, | ||
setComboBoxSelectedValues, | ||
comboBoxSelectedValues, | ||
}: { | ||
comboBoxSelectedValues: string[]; | ||
isLoading: boolean; | ||
setComboBoxInputValue: React.Dispatch<React.SetStateAction<string>>; | ||
dropdownValues: TcomboBoxValue[]; | ||
setComboBoxSelectedValues: React.Dispatch<React.SetStateAction<string[]>>; | ||
}) { | ||
const [open, setOpen] = React.useState(false); | ||
const [value, setValue] = React.useState(''); | ||
|
||
return ( | ||
<Popover open={open} onOpenChange={setOpen}> | ||
<PopoverTrigger asChild> | ||
<Button | ||
variant="outline" | ||
role="combobox" | ||
aria-expanded={open} | ||
className="w-full justify-between bg-gray-800 border-none text-white" | ||
> | ||
Search skillset ... | ||
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="min-w-full p-0"> | ||
<Command> | ||
<CommandInput | ||
className="w-full" | ||
onValueChange={(value) => { | ||
setComboBoxInputValue(value); | ||
}} | ||
placeholder="Search skillset ..." | ||
/> | ||
<CommandList> | ||
{isLoading ? ( | ||
<CommandEmpty> | ||
<LoadingSpinner></LoadingSpinner> | ||
</CommandEmpty> | ||
) : ( | ||
<> | ||
{!dropdownValues.length && ( | ||
<CommandEmpty>No framework found.</CommandEmpty> | ||
)} | ||
|
||
<CommandGroup> | ||
{dropdownValues.map((item) => ( | ||
<CommandItem | ||
key={item.value} | ||
value={item.value} | ||
onSelect={(currentValue) => { | ||
setValue(currentValue === value ? '' : currentValue); | ||
setOpen(false); | ||
setComboBoxSelectedValues((prev) => { | ||
const foundSelectedValueIndex = prev.findIndex( | ||
(val) => val === item.value | ||
); | ||
if (foundSelectedValueIndex < 0) { | ||
return [...prev, currentValue]; | ||
} else return prev; | ||
}); | ||
}} | ||
> | ||
<Check | ||
className={cn( | ||
'mr-2 h-4 w-4', | ||
comboBoxSelectedValues.includes(item.value) | ||
? 'opacity-100' | ||
: 'opacity-0' | ||
)} | ||
/> | ||
{item.label} | ||
</CommandItem> | ||
))} | ||
</CommandGroup> | ||
</> | ||
)} | ||
</CommandList> | ||
</Command> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} |
Oops, something went wrong.