Spaces:
Sleeping
Sleeping
from navigation import make_sidebar | |
import streamlit as st | |
import yaml | |
import datetime | |
import pytz | |
import time | |
make_sidebar() | |
# Sample job data | |
with open(f'data/jobs/jobs.yaml', 'r') as file: | |
jobs = yaml.safe_load(file) | |
st.title("Job Details") | |
hide_st_style = """ | |
<style> | |
#MainMenu {visibility: hidden;} | |
footer {visibility: hidden;} | |
header {visibility: hidden;} | |
</style> | |
""" | |
st.markdown(hide_st_style, unsafe_allow_html=True) | |
# Show job details if a button was clicked | |
if st.session_state.selected_job: | |
selected_title = st.session_state.selected_job | |
st.subheader(f"Details for {selected_title}") | |
for key,value in jobs[selected_title].items(): | |
st.write(f"**{key}**: {value}") | |
with open(f'data/jobs/individual/{st.session_state.selected_job}/status.yaml', 'r') as file: | |
jobs_info = yaml.safe_load(file) | |
if st.session_state.user in list(jobs_info["applicants"].keys()): | |
st.info("You already have applied the job !!") | |
else: | |
if st.button("Apply now"): | |
with open(f'data/jobs/individual/{st.session_state.selected_job}/status.yaml', 'r') as file: | |
jobs_info = yaml.safe_load(file) | |
applied_time = datetime.datetime.now(pytz.timezone('Asia/Kolkata')) | |
jobs_info["applicants"][st.session_state.user] = {'applied_date':applied_time} | |
with open(f'data/jobs/individual/{st.session_state.selected_job}/status.yaml', 'w') as file: | |
yaml.dump(jobs_info, file, default_flow_style=False) | |
with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'r') as file: | |
user_jobs_info = yaml.safe_load(file) | |
if "jobs" in list(user_jobs_info.keys()): | |
user_jobs_info['jobs'][st.session_state.selected_job] = {"paid":"pending","status":"pending","applied_date":applied_time} | |
else: | |
user_jobs_info['jobs'] = {st.session_state.selected_job:{"paid":"pending","status":"pending","applied_date":applied_time}} | |
with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'w') as file: | |
yaml.dump(user_jobs_info, file, default_flow_style=False) | |
st.success("Your application is applied succesfully !!") | |
time.sleep(0.5) | |
st.info("Redirecting to Jobs Finder!! ") | |
time.sleep(1.5) | |
st.switch_page("pages/page1.py") |